Only grant permissions to new extensions from sync if they have the expected version
[chromium-blink-merge.git] / chrome / browser / browsing_data / mock_browsing_data_file_system_helper.cc
blobeb9514ca52057f53c322ead66e01d08517af0dfd
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 "base/stl_util.h"
10 #include "testing/gtest/include/gtest/gtest.h"
12 MockBrowsingDataFileSystemHelper::MockBrowsingDataFileSystemHelper(
13 Profile* profile) {
16 MockBrowsingDataFileSystemHelper::~MockBrowsingDataFileSystemHelper() {
19 void MockBrowsingDataFileSystemHelper::StartFetching(
20 const FetchCallback& callback) {
21 ASSERT_FALSE(callback.is_null());
22 ASSERT_TRUE(callback_.is_null());
23 callback_ = callback;
26 void MockBrowsingDataFileSystemHelper::DeleteFileSystemOrigin(
27 const GURL& origin) {
28 ASSERT_FALSE(callback_.is_null());
29 std::string key = origin.spec();
30 ASSERT_TRUE(ContainsKey(file_systems_, key));
31 last_deleted_origin_ = origin;
32 file_systems_[key] = false;
35 void MockBrowsingDataFileSystemHelper::AddFileSystem(
36 const GURL& origin, bool has_persistent, bool has_temporary,
37 bool has_syncable) {
38 BrowsingDataFileSystemHelper::FileSystemInfo info(origin);
39 if (has_persistent)
40 info.usage_map[storage::kFileSystemTypePersistent] = 0;
41 if (has_temporary)
42 info.usage_map[storage::kFileSystemTypeTemporary] = 0;
43 if (has_syncable)
44 info.usage_map[storage::kFileSystemTypeSyncable] = 0;
45 response_.push_back(info);
46 file_systems_[origin.spec()] = true;
49 void MockBrowsingDataFileSystemHelper::AddFileSystemSamples() {
50 AddFileSystem(GURL("http://fshost1:1/"), false, true, false);
51 AddFileSystem(GURL("http://fshost2:2/"), true, false, true);
52 AddFileSystem(GURL("http://fshost3:3/"), true, true, true);
55 void MockBrowsingDataFileSystemHelper::Notify() {
56 callback_.Run(response_);
59 void MockBrowsingDataFileSystemHelper::Reset() {
60 for (auto& pair : file_systems_)
61 pair.second = true;
64 bool MockBrowsingDataFileSystemHelper::AllDeleted() {
65 for (const auto& pair : file_systems_) {
66 if (pair.second)
67 return false;
69 return true;