Check USB device path access when prompting users to select a device.
[chromium-blink-merge.git] / chrome / browser / browsing_data / mock_browsing_data_file_system_helper.cc
blobf8eecb495e9117dbfc89d62488ee059f711b11e4
1 // Copyright (c) 2012 The Chromium Authors. All rights reserved.
2 // Use of this source code is governed by a BSD-style license that can be
3 // found in the LICENSE file.
5 #include "chrome/browser/browsing_data/mock_browsing_data_file_system_helper.h"
7 #include "base/callback.h"
8 #include "base/logging.h"
9 #include "testing/gtest/include/gtest/gtest.h"
11 MockBrowsingDataFileSystemHelper::MockBrowsingDataFileSystemHelper(
12 Profile* profile) {
15 MockBrowsingDataFileSystemHelper::~MockBrowsingDataFileSystemHelper() {
18 void MockBrowsingDataFileSystemHelper::StartFetching(
19 const base::Callback<void(const std::list<FileSystemInfo>&)>& callback) {
20 ASSERT_FALSE(callback.is_null());
21 ASSERT_TRUE(callback_.is_null());
22 callback_ = callback;
25 void MockBrowsingDataFileSystemHelper::DeleteFileSystemOrigin(
26 const GURL& origin) {
27 ASSERT_FALSE(callback_.is_null());
28 std::string key = origin.spec();
29 ASSERT_TRUE(file_systems_.find(key) != file_systems_.end());
30 last_deleted_origin_ = origin;
31 file_systems_[key] = false;
34 void MockBrowsingDataFileSystemHelper::AddFileSystem(
35 const GURL& origin, bool has_persistent, bool has_temporary,
36 bool has_syncable) {
37 BrowsingDataFileSystemHelper::FileSystemInfo info(origin);
38 if (has_persistent)
39 info.usage_map[storage::kFileSystemTypePersistent] = 0;
40 if (has_temporary)
41 info.usage_map[storage::kFileSystemTypeTemporary] = 0;
42 if (has_syncable)
43 info.usage_map[storage::kFileSystemTypeSyncable] = 0;
44 response_.push_back(info);
45 file_systems_[origin.spec()] = true;
48 void MockBrowsingDataFileSystemHelper::AddFileSystemSamples() {
49 AddFileSystem(GURL("http://fshost1:1/"), false, true, false);
50 AddFileSystem(GURL("http://fshost2:2/"), true, false, true);
51 AddFileSystem(GURL("http://fshost3:3/"), true, true, true);
54 void MockBrowsingDataFileSystemHelper::Notify() {
55 callback_.Run(response_);
58 void MockBrowsingDataFileSystemHelper::Reset() {
59 for (std::map<const std::string, bool>::iterator i = file_systems_.begin();
60 i != file_systems_.end(); ++i)
61 i->second = true;
64 bool MockBrowsingDataFileSystemHelper::AllDeleted() {
65 for (std::map<const std::string, bool>::const_iterator i =
66 file_systems_.begin();
67 i != file_systems_.end(); ++i) {
68 if (i->second)
69 return false;
71 return true;