| OLD | NEW |
| 1 // Copyright (c) 2011 The Chromium Authors. All rights reserved. | 1 // Copyright (c) 2011 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 Clear API functions, which entail | 5 // Defines the Chrome Extensions Clear 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/extension_clear_api.h" | 9 #include "chrome/browser/extensions/extension_clear_api.h" |
| 10 | 10 |
| (...skipping 85 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 96 return false; | 96 return false; |
| 97 } | 97 } |
| 98 | 98 |
| 99 // Parse the |timeframe| argument to generate the TimePeriod. | 99 // Parse the |timeframe| argument to generate the TimePeriod. |
| 100 std::string timeframe; | 100 std::string timeframe; |
| 101 EXTENSION_FUNCTION_VALIDATE(args_->GetString(0, &timeframe)); | 101 EXTENSION_FUNCTION_VALIDATE(args_->GetString(0, &timeframe)); |
| 102 EXTENSION_FUNCTION_VALIDATE(ParseTimePeriod(timeframe, &period_)); | 102 EXTENSION_FUNCTION_VALIDATE(ParseTimePeriod(timeframe, &period_)); |
| 103 | 103 |
| 104 removal_mask_ = GetRemovalMask(); | 104 removal_mask_ = GetRemovalMask(); |
| 105 | 105 |
| 106 if (removal_mask_ & BrowsingDataRemover::REMOVE_LSO_DATA) { | 106 if (removal_mask_ & BrowsingDataRemover::REMOVE_PLUGIN_DATA) { |
| 107 // If we're being asked to remove LSO data, check whether it's actually | 107 // If we're being asked to remove plugin data, check whether it's actually |
| 108 // supported. | 108 // supported. |
| 109 Profile* profile = GetCurrentBrowser()->profile(); | 109 Profile* profile = GetCurrentBrowser()->profile(); |
| 110 BrowserThread::PostTask( | 110 BrowserThread::PostTask( |
| 111 BrowserThread::FILE, FROM_HERE, | 111 BrowserThread::FILE, FROM_HERE, |
| 112 base::Bind( | 112 base::Bind( |
| 113 &BrowsingDataExtensionFunction::CheckRemovingLSODataSupported, | 113 &BrowsingDataExtensionFunction::CheckRemovingPluginDataSupported, |
| 114 this, | 114 this, |
| 115 make_scoped_refptr(PluginPrefs::GetForProfile(profile)))); | 115 make_scoped_refptr(PluginPrefs::GetForProfile(profile)))); |
| 116 } else { | 116 } else { |
| 117 StartRemoving(); | 117 StartRemoving(); |
| 118 } | 118 } |
| 119 | 119 |
| 120 // Will finish asynchronously. | 120 // Will finish asynchronously. |
| 121 return true; | 121 return true; |
| 122 } | 122 } |
| 123 | 123 |
| 124 void BrowsingDataExtensionFunction::CheckRemovingLSODataSupported( | 124 void BrowsingDataExtensionFunction::CheckRemovingPluginDataSupported( |
| 125 scoped_refptr<PluginPrefs> plugin_prefs) { | 125 scoped_refptr<PluginPrefs> plugin_prefs) { |
| 126 if (!PluginDataRemoverHelper::IsSupported(plugin_prefs)) | 126 if (!PluginDataRemoverHelper::IsSupported(plugin_prefs)) |
| 127 removal_mask_ &= ~BrowsingDataRemover::REMOVE_LSO_DATA; | 127 removal_mask_ &= ~BrowsingDataRemover::REMOVE_PLUGIN_DATA; |
| 128 | 128 |
| 129 BrowserThread::PostTask( | 129 BrowserThread::PostTask( |
| 130 BrowserThread::UI, FROM_HERE, | 130 BrowserThread::UI, FROM_HERE, |
| 131 base::Bind(&BrowsingDataExtensionFunction::StartRemoving, this)); | 131 base::Bind(&BrowsingDataExtensionFunction::StartRemoving, this)); |
| 132 } | 132 } |
| 133 | 133 |
| 134 void BrowsingDataExtensionFunction::StartRemoving() { | 134 void BrowsingDataExtensionFunction::StartRemoving() { |
| 135 // If we're good to go, add a ref (Balanced in OnBrowsingDataRemoverDone) | 135 // If we're good to go, add a ref (Balanced in OnBrowsingDataRemoverDone) |
| 136 AddRef(); | 136 AddRef(); |
| 137 | 137 |
| (...skipping 32 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 170 return BrowsingDataRemover::REMOVE_FORM_DATA; | 170 return BrowsingDataRemover::REMOVE_FORM_DATA; |
| 171 } | 171 } |
| 172 | 172 |
| 173 int ClearHistoryFunction::GetRemovalMask() const { | 173 int ClearHistoryFunction::GetRemovalMask() const { |
| 174 return BrowsingDataRemover::REMOVE_HISTORY; | 174 return BrowsingDataRemover::REMOVE_HISTORY; |
| 175 } | 175 } |
| 176 | 176 |
| 177 int ClearPasswordsFunction::GetRemovalMask() const { | 177 int ClearPasswordsFunction::GetRemovalMask() const { |
| 178 return BrowsingDataRemover::REMOVE_CACHE; | 178 return BrowsingDataRemover::REMOVE_CACHE; |
| 179 } | 179 } |
| OLD | NEW |