| OLD | NEW |
| 1 // Copyright (c) 2012 The Chromium Authors. All rights reserved. | 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 | 2 // Use of this source code is governed by a BSD-style license that can be |
| 3 // found in the LICENSE file. | 3 // found in the LICENSE file. |
| 4 | 4 |
| 5 #include "chrome/browser/browsing_data/mock_browsing_data_flash_lso_helper.h" | 5 #include "chrome/browser/browsing_data/mock_browsing_data_flash_lso_helper.h" |
| 6 | 6 |
| 7 #include <algorithm> | 7 #include <algorithm> |
| 8 | 8 |
| 9 #include "testing/gtest/include/gtest/gtest.h" | 9 #include "testing/gtest/include/gtest/gtest.h" |
| 10 | 10 |
| 11 MockBrowsingDataFlashLSOHelper::MockBrowsingDataFlashLSOHelper( | 11 MockBrowsingDataFlashLSOHelper::MockBrowsingDataFlashLSOHelper( |
| 12 content::BrowserContext* browser_context) { | 12 content::BrowserContext* browser_context) { |
| 13 } | 13 } |
| 14 void MockBrowsingDataFlashLSOHelper::StartFetching( | 14 void MockBrowsingDataFlashLSOHelper::StartFetching( |
| 15 const GetSitesWithFlashDataCallback& callback) { | 15 const GetSitesWithFlashDataCallback& callback) { |
| 16 ASSERT_FALSE(callback.is_null()); | 16 ASSERT_FALSE(callback.is_null()); |
| 17 ASSERT_TRUE(callback_.is_null()); | 17 ASSERT_TRUE(callback_.is_null()); |
| 18 callback_ = callback; | 18 callback_ = callback; |
| 19 } | 19 } |
| 20 | 20 |
| 21 void MockBrowsingDataFlashLSOHelper::DeleteFlashLSOsForSite( | 21 void MockBrowsingDataFlashLSOHelper::DeleteFlashLSOsForSite( |
| 22 const std::string& site) { | 22 const std::string& site, const base::Closure& callback) { |
| 23 std::vector<std::string>::iterator entry = | 23 std::vector<std::string>::iterator entry = |
| 24 std::find(domains_.begin(), domains_.end(), site); | 24 std::find(domains_.begin(), domains_.end(), site); |
| 25 ASSERT_TRUE(entry != domains_.end()); | 25 ASSERT_TRUE(entry != domains_.end()); |
| 26 domains_.erase(entry); | 26 domains_.erase(entry); |
| 27 if (!callback.is_null()) |
| 28 callback.Run(); |
| 27 } | 29 } |
| 28 | 30 |
| 29 void MockBrowsingDataFlashLSOHelper::AddFlashLSODomain( | 31 void MockBrowsingDataFlashLSOHelper::AddFlashLSODomain( |
| 30 const std::string& domain) { | 32 const std::string& domain) { |
| 31 domains_.push_back(domain); | 33 domains_.push_back(domain); |
| 32 } | 34 } |
| 33 | 35 |
| 34 void MockBrowsingDataFlashLSOHelper::Notify() { | 36 void MockBrowsingDataFlashLSOHelper::Notify() { |
| 35 callback_.Run(domains_); | 37 callback_.Run(domains_); |
| 36 callback_ = GetSitesWithFlashDataCallback(); | 38 callback_ = GetSitesWithFlashDataCallback(); |
| 37 } | 39 } |
| 38 | 40 |
| 39 bool MockBrowsingDataFlashLSOHelper::AllDeleted() { | 41 bool MockBrowsingDataFlashLSOHelper::AllDeleted() { |
| 40 return domains_.empty(); | 42 return domains_.empty(); |
| 41 } | 43 } |
| 42 | 44 |
| 43 MockBrowsingDataFlashLSOHelper::~MockBrowsingDataFlashLSOHelper() { | 45 MockBrowsingDataFlashLSOHelper::~MockBrowsingDataFlashLSOHelper() { |
| 44 } | 46 } |
| OLD | NEW |