Check USB device path access when prompting users to select a device.
[chromium-blink-merge.git] / chrome / browser / browsing_data / mock_browsing_data_service_worker_helper.cc
blobf54fad3b4fe0c520c3e4272fe3e22d1229280e97
1 // Copyright 2014 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_service_worker_helper.h"
7 #include <vector>
9 #include "base/callback.h"
10 #include "base/logging.h"
11 #include "chrome/browser/profiles/profile.h"
12 #include "content/public/browser/browser_context.h"
13 #include "content/public/browser/storage_partition.h"
14 #include "testing/gtest/include/gtest/gtest.h"
16 MockBrowsingDataServiceWorkerHelper::MockBrowsingDataServiceWorkerHelper(
17 Profile* profile)
18 : BrowsingDataServiceWorkerHelper(
19 content::BrowserContext::GetDefaultStoragePartition(profile)->
20 GetServiceWorkerContext()) {
23 MockBrowsingDataServiceWorkerHelper::~MockBrowsingDataServiceWorkerHelper() {
26 void MockBrowsingDataServiceWorkerHelper::StartFetching(const base::Callback<
27 void(const std::list<content::ServiceWorkerUsageInfo>&)>& callback) {
28 ASSERT_FALSE(callback.is_null());
29 ASSERT_TRUE(callback_.is_null());
30 callback_ = callback;
33 void MockBrowsingDataServiceWorkerHelper::DeleteServiceWorkers(
34 const GURL& origin) {
35 ASSERT_FALSE(callback_.is_null());
36 ASSERT_TRUE(origins_.find(origin) != origins_.end());
37 origins_[origin] = false;
40 void MockBrowsingDataServiceWorkerHelper::AddServiceWorkerSamples() {
41 const GURL kOrigin1("https://swhost1:1/");
42 std::vector<GURL> scopes1;
43 scopes1.push_back(GURL("https://swhost1:1/app1/*"));
44 scopes1.push_back(GURL("https://swhost1:1/app2/*"));
45 const GURL kOrigin2("https://swhost2:2/");
46 std::vector<GURL> scopes2;
47 scopes2.push_back(GURL("https://swhost2:2/*"));
49 content::ServiceWorkerUsageInfo info1(kOrigin1, scopes1);
50 response_.push_back(info1);
51 origins_[kOrigin1] = true;
53 content::ServiceWorkerUsageInfo info2(kOrigin2, scopes2);
54 response_.push_back(info2);
55 origins_[kOrigin2] = true;
58 void MockBrowsingDataServiceWorkerHelper::Notify() {
59 callback_.Run(response_);
62 void MockBrowsingDataServiceWorkerHelper::Reset() {
63 for (std::map<GURL, bool>::iterator i = origins_.begin();
64 i != origins_.end(); ++i)
65 i->second = true;
68 bool MockBrowsingDataServiceWorkerHelper::AllDeleted() {
69 for (std::map<GURL, bool>::const_iterator i = origins_.begin();
70 i != origins_.end(); ++i)
71 if (i->second)
72 return false;
73 return true;