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 |
(...skipping 135 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
146 browsing_data::TimePeriod period = | 146 browsing_data::TimePeriod period = |
147 static_cast<browsing_data::TimePeriod>(period_pref); | 147 static_cast<browsing_data::TimePeriod>(period_pref); |
148 double since = 0; | 148 double since = 0; |
149 if (period != browsing_data::TimePeriod::ALL_TIME) { | 149 if (period != browsing_data::TimePeriod::ALL_TIME) { |
150 base::Time time = browsing_data::CalculateBeginDeleteTime(period); | 150 base::Time time = browsing_data::CalculateBeginDeleteTime(period); |
151 since = time.ToJsTime(); | 151 since = time.ToJsTime(); |
152 } | 152 } |
153 | 153 |
154 std::unique_ptr<base::DictionaryValue> options(new base::DictionaryValue); | 154 std::unique_ptr<base::DictionaryValue> options(new base::DictionaryValue); |
155 options->Set(extension_browsing_data_api_constants::kOriginTypesKey, | 155 options->Set(extension_browsing_data_api_constants::kOriginTypesKey, |
156 origin_types.release()); | 156 std::move(origin_types)); |
157 options->SetDouble(extension_browsing_data_api_constants::kSinceKey, since); | 157 options->SetDouble(extension_browsing_data_api_constants::kSinceKey, since); |
158 | 158 |
159 // Fill dataToRemove and dataRemovalPermitted. | 159 // Fill dataToRemove and dataRemovalPermitted. |
160 std::unique_ptr<base::DictionaryValue> selected(new base::DictionaryValue); | 160 std::unique_ptr<base::DictionaryValue> selected(new base::DictionaryValue); |
161 std::unique_ptr<base::DictionaryValue> permitted(new base::DictionaryValue); | 161 std::unique_ptr<base::DictionaryValue> permitted(new base::DictionaryValue); |
162 | 162 |
163 bool delete_site_data = | 163 bool delete_site_data = |
164 prefs_->GetBoolean(browsing_data::prefs::kDeleteCookies) || | 164 prefs_->GetBoolean(browsing_data::prefs::kDeleteCookies) || |
165 prefs_->GetBoolean(browsing_data::prefs::kDeleteHostedAppsData); | 165 prefs_->GetBoolean(browsing_data::prefs::kDeleteHostedAppsData); |
166 | 166 |
(...skipping 41 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
208 prefs_->GetBoolean(browsing_data::prefs::kDeleteCache)); | 208 prefs_->GetBoolean(browsing_data::prefs::kDeleteCache)); |
209 SetDetails(selected.get(), permitted.get(), | 209 SetDetails(selected.get(), permitted.get(), |
210 extension_browsing_data_api_constants::kFormDataKey, | 210 extension_browsing_data_api_constants::kFormDataKey, |
211 prefs_->GetBoolean(browsing_data::prefs::kDeleteFormData)); | 211 prefs_->GetBoolean(browsing_data::prefs::kDeleteFormData)); |
212 SetDetails(selected.get(), permitted.get(), | 212 SetDetails(selected.get(), permitted.get(), |
213 extension_browsing_data_api_constants::kPasswordsKey, | 213 extension_browsing_data_api_constants::kPasswordsKey, |
214 prefs_->GetBoolean(browsing_data::prefs::kDeletePasswords)); | 214 prefs_->GetBoolean(browsing_data::prefs::kDeletePasswords)); |
215 | 215 |
216 std::unique_ptr<base::DictionaryValue> result(new base::DictionaryValue); | 216 std::unique_ptr<base::DictionaryValue> result(new base::DictionaryValue); |
217 result->Set(extension_browsing_data_api_constants::kOptionsKey, | 217 result->Set(extension_browsing_data_api_constants::kOptionsKey, |
218 options.release()); | 218 std::move(options)); |
219 result->Set(extension_browsing_data_api_constants::kDataToRemoveKey, | 219 result->Set(extension_browsing_data_api_constants::kDataToRemoveKey, |
220 selected.release()); | 220 std::move(selected)); |
221 result->Set(extension_browsing_data_api_constants::kDataRemovalPermittedKey, | 221 result->Set(extension_browsing_data_api_constants::kDataRemovalPermittedKey, |
222 permitted.release()); | 222 std::move(permitted)); |
223 return RespondNow(OneArgument(std::move(result))); | 223 return RespondNow(OneArgument(std::move(result))); |
224 } | 224 } |
225 | 225 |
226 void BrowsingDataSettingsFunction::SetDetails( | 226 void BrowsingDataSettingsFunction::SetDetails( |
227 base::DictionaryValue* selected_dict, | 227 base::DictionaryValue* selected_dict, |
228 base::DictionaryValue* permitted_dict, | 228 base::DictionaryValue* permitted_dict, |
229 const char* data_type, | 229 const char* data_type, |
230 bool is_selected) { | 230 bool is_selected) { |
231 bool is_permitted = IsRemovalPermitted(MaskForKey(data_type), prefs_); | 231 bool is_permitted = IsRemovalPermitted(MaskForKey(data_type), prefs_); |
232 selected_dict->SetBoolean(data_type, is_selected && is_permitted); | 232 selected_dict->SetBoolean(data_type, is_selected && is_permitted); |
(...skipping 233 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
466 | 466 |
467 bool BrowsingDataRemoveCacheStorageFunction::GetRemovalMask(int* removal_mask) { | 467 bool BrowsingDataRemoveCacheStorageFunction::GetRemovalMask(int* removal_mask) { |
468 *removal_mask = BrowsingDataRemover::DATA_TYPE_CACHE_STORAGE; | 468 *removal_mask = BrowsingDataRemover::DATA_TYPE_CACHE_STORAGE; |
469 return true; | 469 return true; |
470 } | 470 } |
471 | 471 |
472 bool BrowsingDataRemoveWebSQLFunction::GetRemovalMask(int* removal_mask) { | 472 bool BrowsingDataRemoveWebSQLFunction::GetRemovalMask(int* removal_mask) { |
473 *removal_mask = BrowsingDataRemover::DATA_TYPE_WEB_SQL; | 473 *removal_mask = BrowsingDataRemover::DATA_TYPE_WEB_SQL; |
474 return true; | 474 return true; |
475 } | 475 } |
OLD | NEW |