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 101 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
112 DCHECK(BrowserThread::CurrentlyOn(BrowserThread::UI)); | 112 DCHECK(BrowserThread::CurrentlyOn(BrowserThread::UI)); |
113 this->SendResponse(true); | 113 this->SendResponse(true); |
114 | 114 |
115 Release(); // Balanced in RunImpl. | 115 Release(); // Balanced in RunImpl. |
116 } | 116 } |
117 | 117 |
118 bool BrowsingDataExtensionFunction::RunImpl() { | 118 bool BrowsingDataExtensionFunction::RunImpl() { |
119 // If we don't have a profile, something's pretty wrong. | 119 // If we don't have a profile, something's pretty wrong. |
120 DCHECK(profile()); | 120 DCHECK(profile()); |
121 | 121 |
122 if (BrowsingDataRemover::is_removing()) { | 122 if (BrowsingDataRemover::removing()) { |
123 error_ = extension_browsing_data_api_constants::kOneAtATimeError; | 123 error_ = extension_browsing_data_api_constants::kOneAtATimeError; |
124 return false; | 124 return false; |
125 } | 125 } |
126 | 126 |
127 // Grab the initial |options| parameter, and parse out the arguments. | 127 // Grab the initial |options| parameter, and parse out the arguments. |
128 DictionaryValue* options; | 128 DictionaryValue* options; |
129 EXTENSION_FUNCTION_VALIDATE(args_->GetDictionary(0, &options)); | 129 EXTENSION_FUNCTION_VALIDATE(args_->GetDictionary(0, &options)); |
130 DCHECK(options); | 130 DCHECK(options); |
131 | 131 |
132 origin_set_mask_ = ParseOriginSetMask(*options); | 132 origin_set_mask_ = ParseOriginSetMask(*options); |
(...skipping 42 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
175 } | 175 } |
176 | 176 |
177 void BrowsingDataExtensionFunction::StartRemoving() { | 177 void BrowsingDataExtensionFunction::StartRemoving() { |
178 // If we're good to go, add a ref (Balanced in OnBrowsingDataRemoverDone) | 178 // If we're good to go, add a ref (Balanced in OnBrowsingDataRemoverDone) |
179 AddRef(); | 179 AddRef(); |
180 | 180 |
181 // Create a BrowsingDataRemover, set the current object as an observer (so | 181 // Create a BrowsingDataRemover, set the current object as an observer (so |
182 // that we're notified after removal) and call remove() with the arguments | 182 // that we're notified after removal) and call remove() with the arguments |
183 // we've generated above. We can use a raw pointer here, as the browsing data | 183 // we've generated above. We can use a raw pointer here, as the browsing data |
184 // remover is responsible for deleting itself once data removal is complete. | 184 // remover is responsible for deleting itself once data removal is complete. |
185 BrowsingDataRemover* remover = new BrowsingDataRemover(profile(), | 185 BrowsingDataRemover* remover = BrowsingDataRemover::CreateForRange(profile(), |
186 remove_since_, base::Time::Now()); | 186 remove_since_, base::Time::Max()); |
187 remover->AddObserver(this); | 187 remover->AddObserver(this); |
188 remover->Remove(removal_mask_, origin_set_mask_); | 188 remover->Remove(removal_mask_, origin_set_mask_); |
189 } | 189 } |
190 | 190 |
191 int BrowsingDataExtensionFunction::ParseOriginSetMask( | 191 int BrowsingDataExtensionFunction::ParseOriginSetMask( |
192 const base::DictionaryValue& options) { | 192 const base::DictionaryValue& options) { |
193 // Parse the |options| dictionary to generate the origin set mask. Default to | 193 // Parse the |options| dictionary to generate the origin set mask. Default to |
194 // UNPROTECTED_WEB if the developer doesn't specify anything. | 194 // UNPROTECTED_WEB if the developer doesn't specify anything. |
195 int mask = BrowsingDataHelper::UNPROTECTED_WEB; | 195 int mask = BrowsingDataHelper::UNPROTECTED_WEB; |
196 | 196 |
(...skipping 84 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
281 return BrowsingDataRemover::REMOVE_PLUGIN_DATA; | 281 return BrowsingDataRemover::REMOVE_PLUGIN_DATA; |
282 } | 282 } |
283 | 283 |
284 int RemovePasswordsFunction::GetRemovalMask() const { | 284 int RemovePasswordsFunction::GetRemovalMask() const { |
285 return BrowsingDataRemover::REMOVE_PASSWORDS; | 285 return BrowsingDataRemover::REMOVE_PASSWORDS; |
286 } | 286 } |
287 | 287 |
288 int RemoveWebSQLFunction::GetRemovalMask() const { | 288 int RemoveWebSQLFunction::GetRemovalMask() const { |
289 return BrowsingDataRemover::REMOVE_WEBSQL; | 289 return BrowsingDataRemover::REMOVE_WEBSQL; |
290 } | 290 } |
OLD | NEW |