| 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 // Defines the Chrome Extensions BrowsingData API functions, which entail | 5 // Defines the Chrome Extensions BrowsingData API functions, which entail |
| 6 // clearing browsing data, and clearing the browser's cache (which, let's be | 6 // clearing browsing data, and clearing the browser's cache (which, let's be |
| 7 // honest, are the same thing), as specified in the extension API JSON. | 7 // honest, are the same thing), as specified in the extension API JSON. |
| 8 | 8 |
| 9 #include "chrome/browser/extensions/api/browsing_data/browsing_data_api.h" | 9 #include "chrome/browser/extensions/api/browsing_data/browsing_data_api.h" |
| 10 | 10 |
| 11 #include <string> | 11 #include <string> |
| 12 #include <utility> | 12 #include <utility> |
| 13 | 13 |
| 14 #include "base/strings/stringprintf.h" | 14 #include "base/strings/stringprintf.h" |
| 15 #include "base/values.h" | 15 #include "base/values.h" |
| 16 #include "chrome/browser/browsing_data/browsing_data_helper.h" | 16 #include "chrome/browser/browsing_data/browsing_data_helper.h" |
| 17 #include "chrome/browser/browsing_data/browsing_data_remover.h" | 17 #include "chrome/browser/browsing_data/browsing_data_remover.h" |
| 18 #include "chrome/browser/browsing_data/browsing_data_remover_factory.h" | 18 #include "chrome/browser/browsing_data/browsing_data_remover_factory.h" |
| 19 #include "chrome/browser/plugins/plugin_data_remover_helper.h" | 19 #include "chrome/browser/plugins/plugin_data_remover_helper.h" |
| 20 #include "chrome/browser/plugins/plugin_prefs.h" | 20 #include "chrome/browser/plugins/plugin_prefs.h" |
| 21 #include "chrome/browser/profiles/profile.h" | 21 #include "chrome/browser/profiles/profile.h" |
| 22 #include "chrome/browser/ui/browser.h" | 22 #include "chrome/browser/ui/browser.h" |
| 23 #include "chrome/common/pref_names.h" | 23 #include "chrome/common/pref_names.h" |
| 24 #include "components/browsing_data/pref_names.h" |
| 24 #include "content/public/browser/browser_thread.h" | 25 #include "content/public/browser/browser_thread.h" |
| 25 #include "extensions/common/error_utils.h" | 26 #include "extensions/common/error_utils.h" |
| 26 #include "extensions/common/extension.h" | 27 #include "extensions/common/extension.h" |
| 27 | 28 |
| 28 using content::BrowserThread; | 29 using content::BrowserThread; |
| 29 | 30 |
| 30 namespace extension_browsing_data_api_constants { | 31 namespace extension_browsing_data_api_constants { |
| 31 | 32 |
| 32 // Parameter name keys. | 33 // Parameter name keys. |
| 33 const char kDataRemovalPermittedKey[] = "dataRemovalPermitted"; | 34 const char kDataRemovalPermittedKey[] = "dataRemovalPermitted"; |
| (...skipping 102 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 136 origin_types->SetBoolean( | 137 origin_types->SetBoolean( |
| 137 extension_browsing_data_api_constants::kUnprotectedWebKey, | 138 extension_browsing_data_api_constants::kUnprotectedWebKey, |
| 138 prefs->GetBoolean(prefs::kDeleteCookies)); | 139 prefs->GetBoolean(prefs::kDeleteCookies)); |
| 139 origin_types->SetBoolean( | 140 origin_types->SetBoolean( |
| 140 extension_browsing_data_api_constants::kProtectedWebKey, | 141 extension_browsing_data_api_constants::kProtectedWebKey, |
| 141 prefs->GetBoolean(prefs::kDeleteHostedAppsData)); | 142 prefs->GetBoolean(prefs::kDeleteHostedAppsData)); |
| 142 origin_types->SetBoolean( | 143 origin_types->SetBoolean( |
| 143 extension_browsing_data_api_constants::kExtensionsKey, false); | 144 extension_browsing_data_api_constants::kExtensionsKey, false); |
| 144 | 145 |
| 145 // Fill deletion time period. | 146 // Fill deletion time period. |
| 146 int period_pref = prefs->GetInteger(prefs::kDeleteTimePeriod); | 147 int period_pref = prefs->GetInteger(browsing_data::prefs::kDeleteTimePeriod); |
| 147 BrowsingDataRemover::TimePeriod period = | 148 browsing_data::TimePeriod period = |
| 148 static_cast<BrowsingDataRemover::TimePeriod>(period_pref); | 149 static_cast<browsing_data::TimePeriod>(period_pref); |
| 149 double since = 0; | 150 double since = 0; |
| 150 if (period != BrowsingDataRemover::EVERYTHING) { | 151 if (period != browsing_data::EVERYTHING) { |
| 151 base::Time time = BrowsingDataRemover::CalculateBeginDeleteTime(period); | 152 base::Time time = browsing_data::CalculateBeginDeleteTime(period); |
| 152 since = time.ToJsTime(); | 153 since = time.ToJsTime(); |
| 153 } | 154 } |
| 154 | 155 |
| 155 std::unique_ptr<base::DictionaryValue> options(new base::DictionaryValue); | 156 std::unique_ptr<base::DictionaryValue> options(new base::DictionaryValue); |
| 156 options->Set(extension_browsing_data_api_constants::kOriginTypesKey, | 157 options->Set(extension_browsing_data_api_constants::kOriginTypesKey, |
| 157 origin_types.release()); | 158 origin_types.release()); |
| 158 options->SetDouble(extension_browsing_data_api_constants::kSinceKey, since); | 159 options->SetDouble(extension_browsing_data_api_constants::kSinceKey, since); |
| 159 | 160 |
| 160 // Fill dataToRemove and dataRemovalPermitted. | 161 // Fill dataToRemove and dataRemovalPermitted. |
| 161 std::unique_ptr<base::DictionaryValue> selected(new base::DictionaryValue); | 162 std::unique_ptr<base::DictionaryValue> selected(new base::DictionaryValue); |
| (...skipping 289 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 451 return BrowsingDataRemover::REMOVE_SERVICE_WORKERS; | 452 return BrowsingDataRemover::REMOVE_SERVICE_WORKERS; |
| 452 } | 453 } |
| 453 | 454 |
| 454 int BrowsingDataRemoveCacheStorageFunction::GetRemovalMask() { | 455 int BrowsingDataRemoveCacheStorageFunction::GetRemovalMask() { |
| 455 return BrowsingDataRemover::REMOVE_CACHE_STORAGE; | 456 return BrowsingDataRemover::REMOVE_CACHE_STORAGE; |
| 456 } | 457 } |
| 457 | 458 |
| 458 int BrowsingDataRemoveWebSQLFunction::GetRemovalMask() { | 459 int BrowsingDataRemoveWebSQLFunction::GetRemovalMask() { |
| 459 return BrowsingDataRemover::REMOVE_WEBSQL; | 460 return BrowsingDataRemover::REMOVE_WEBSQL; |
| 460 } | 461 } |
| OLD | NEW |