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_cache_storage_helper.cc
blobd954c570feddc21d8153d33e420d9ff9d7b8081e
1 // Copyright 2015 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_cache_storage_helper.h"
7 #include "base/callback.h"
8 #include "base/logging.h"
9 #include "chrome/browser/profiles/profile.h"
10 #include "content/public/browser/browser_context.h"
11 #include "content/public/browser/storage_partition.h"
12 #include "testing/gtest/include/gtest/gtest.h"
14 MockBrowsingDataCacheStorageHelper::MockBrowsingDataCacheStorageHelper(
15 Profile* profile)
16 : BrowsingDataCacheStorageHelper(
17 content::BrowserContext::GetDefaultStoragePartition(profile)
18 ->GetCacheStorageContext()) {}
20 MockBrowsingDataCacheStorageHelper::~MockBrowsingDataCacheStorageHelper() {}
22 void MockBrowsingDataCacheStorageHelper::StartFetching(
23 const FetchCallback& callback) {
24 ASSERT_FALSE(callback.is_null());
25 ASSERT_TRUE(callback_.is_null());
26 callback_ = callback;
29 void MockBrowsingDataCacheStorageHelper::DeleteCacheStorage(
30 const GURL& origin) {
31 ASSERT_FALSE(callback_.is_null());
32 ASSERT_TRUE(origins_.find(origin) != origins_.end());
33 origins_[origin] = false;
36 void MockBrowsingDataCacheStorageHelper::AddCacheStorageSamples() {
37 const GURL kOrigin1("https://cshost1:1/");
38 const GURL kOrigin2("https://cshost2:2/");
39 content::CacheStorageUsageInfo info1(kOrigin1, 1, base::Time());
40 response_.push_back(info1);
41 origins_[kOrigin1] = true;
42 content::CacheStorageUsageInfo info2(kOrigin2, 2, base::Time());
43 response_.push_back(info2);
44 origins_[kOrigin2] = true;
47 void MockBrowsingDataCacheStorageHelper::Notify() {
48 callback_.Run(response_);
51 void MockBrowsingDataCacheStorageHelper::Reset() {
52 for (auto& pair : origins_)
53 pair.second = true;
56 bool MockBrowsingDataCacheStorageHelper::AllDeleted() {
57 for (const auto& pair : origins_) {
58 if (pair.second)
59 return false;
61 return true;