Disable view source for Developer Tools.
[chromium-blink-merge.git] / chrome / browser / browsing_data / mock_browsing_data_local_storage_helper.cc
blobcf9cd28b8e12fed683dffd0f2784878ba8b613ba
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_local_storage_helper.h"
7 #include "base/callback.h"
8 #include "base/logging.h"
10 MockBrowsingDataLocalStorageHelper::MockBrowsingDataLocalStorageHelper(
11 Profile* profile)
12 : BrowsingDataLocalStorageHelper(profile) {
15 MockBrowsingDataLocalStorageHelper::~MockBrowsingDataLocalStorageHelper() {
18 void MockBrowsingDataLocalStorageHelper::StartFetching(
19 const base::Callback<void(const std::list<LocalStorageInfo>&)>& callback) {
20 callback_ = callback;
23 void MockBrowsingDataLocalStorageHelper::DeleteOrigin(
24 const GURL& origin) {
25 CHECK(origins_.find(origin) != origins_.end());
26 last_deleted_origin_ = origin;
27 origins_[origin] = false;
30 void MockBrowsingDataLocalStorageHelper::AddLocalStorageSamples() {
31 const GURL kOrigin1("http://host1:1/");
32 const GURL kOrigin2("http://host2:2/");
33 response_.push_back(
34 BrowsingDataLocalStorageHelper::LocalStorageInfo(
35 kOrigin1, 1, base::Time()));
36 origins_[kOrigin1] = true;
37 response_.push_back(
38 BrowsingDataLocalStorageHelper::LocalStorageInfo(
39 kOrigin2, 2, base::Time()));
40 origins_[kOrigin2] = true;
43 void MockBrowsingDataLocalStorageHelper::Notify() {
44 CHECK_EQ(false, callback_.is_null());
45 callback_.Run(response_);
48 void MockBrowsingDataLocalStorageHelper::Reset() {
49 for (std::map<const GURL, bool>::iterator i = origins_.begin();
50 i != origins_.end(); ++i)
51 i->second = true;
54 bool MockBrowsingDataLocalStorageHelper::AllDeleted() {
55 for (std::map<const GURL, bool>::const_iterator i =
56 origins_.begin(); i != origins_.end(); ++i)
57 if (i->second)
58 return false;
59 return true;