| 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 #ifndef CHROME_BROWSER_EXTENSIONS_API_BROWSING_DATA_BROWSING_DATA_API_H_ | 9 #ifndef CHROME_BROWSER_EXTENSIONS_API_BROWSING_DATA_BROWSING_DATA_API_H_ |
| 10 #define CHROME_BROWSER_EXTENSIONS_API_BROWSING_DATA_BROWSING_DATA_API_H_ | 10 #define CHROME_BROWSER_EXTENSIONS_API_BROWSING_DATA_BROWSING_DATA_API_H_ |
| 11 | 11 |
| 12 #include <string> | 12 #include <string> |
| 13 | 13 |
| 14 #include "base/scoped_observer.h" | 14 #include "base/scoped_observer.h" |
| 15 #include "chrome/browser/browsing_data/browsing_data_remover.h" | |
| 16 #include "chrome/browser/extensions/chrome_extension_function.h" | 15 #include "chrome/browser/extensions/chrome_extension_function.h" |
| 16 #include "content/public/browser/browsing_data_remover.h" |
| 17 | 17 |
| 18 class PluginPrefs; | 18 class PluginPrefs; |
| 19 class PrefService; | 19 class PrefService; |
| 20 | 20 |
| 21 namespace extension_browsing_data_api_constants { | 21 namespace extension_browsing_data_api_constants { |
| 22 | 22 |
| 23 // Parameter name keys. | 23 // Parameter name keys. |
| 24 extern const char kDataRemovalPermittedKey[]; | 24 extern const char kDataRemovalPermittedKey[]; |
| 25 extern const char kDataToRemoveKey[]; | 25 extern const char kDataToRemoveKey[]; |
| 26 extern const char kOptionsKey[]; | 26 extern const char kOptionsKey[]; |
| (...skipping 50 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 77 PrefService* prefs_ = nullptr; | 77 PrefService* prefs_ = nullptr; |
| 78 }; | 78 }; |
| 79 | 79 |
| 80 // This serves as a base class from which the browsing data API removal | 80 // This serves as a base class from which the browsing data API removal |
| 81 // functions will inherit. Each needs to be an observer of BrowsingDataRemover | 81 // functions will inherit. Each needs to be an observer of BrowsingDataRemover |
| 82 // events, and each will handle those events in the same way (by calling the | 82 // events, and each will handle those events in the same way (by calling the |
| 83 // passed-in callback function). | 83 // passed-in callback function). |
| 84 // | 84 // |
| 85 // Each child class must implement GetRemovalMask(), which returns the bitmask | 85 // Each child class must implement GetRemovalMask(), which returns the bitmask |
| 86 // of data types to remove. | 86 // of data types to remove. |
| 87 class BrowsingDataRemoverFunction : public ChromeAsyncExtensionFunction, | 87 class BrowsingDataRemoverFunction |
| 88 public BrowsingDataRemover::Observer { | 88 : public ChromeAsyncExtensionFunction, |
| 89 public content::BrowsingDataRemover::Observer { |
| 89 public: | 90 public: |
| 90 BrowsingDataRemoverFunction(); | 91 BrowsingDataRemoverFunction(); |
| 91 | 92 |
| 92 // BrowsingDataRemover::Observer interface method. | 93 // BrowsingDataRemover::Observer interface method. |
| 93 void OnBrowsingDataRemoverDone() override; | 94 void OnBrowsingDataRemoverDone() override; |
| 94 | 95 |
| 95 // ExtensionFunction: | 96 // ExtensionFunction: |
| 96 bool RunAsync() override; | 97 bool RunAsync() override; |
| 97 | 98 |
| 98 protected: | 99 protected: |
| (...skipping 16 matching lines...) Expand all Loading... |
| 115 // Returns true if parsing was successful. | 116 // Returns true if parsing was successful. |
| 116 bool ParseOriginTypeMask(const base::DictionaryValue& options, | 117 bool ParseOriginTypeMask(const base::DictionaryValue& options, |
| 117 int* origin_type_mask); | 118 int* origin_type_mask); |
| 118 | 119 |
| 119 // Called when we're ready to start removing data. | 120 // Called when we're ready to start removing data. |
| 120 void StartRemoving(); | 121 void StartRemoving(); |
| 121 | 122 |
| 122 base::Time remove_since_; | 123 base::Time remove_since_; |
| 123 int removal_mask_; | 124 int removal_mask_; |
| 124 int origin_type_mask_; | 125 int origin_type_mask_; |
| 125 ScopedObserver<BrowsingDataRemover, BrowsingDataRemover::Observer> observer_; | 126 ScopedObserver<content::BrowsingDataRemover, |
| 127 content::BrowsingDataRemover::Observer> |
| 128 observer_; |
| 126 }; | 129 }; |
| 127 | 130 |
| 128 class BrowsingDataRemoveAppcacheFunction : public BrowsingDataRemoverFunction { | 131 class BrowsingDataRemoveAppcacheFunction : public BrowsingDataRemoverFunction { |
| 129 public: | 132 public: |
| 130 DECLARE_EXTENSION_FUNCTION("browsingData.removeAppcache", | 133 DECLARE_EXTENSION_FUNCTION("browsingData.removeAppcache", |
| 131 BROWSINGDATA_REMOVEAPPCACHE) | 134 BROWSINGDATA_REMOVEAPPCACHE) |
| 132 | 135 |
| 133 protected: | 136 protected: |
| 134 ~BrowsingDataRemoveAppcacheFunction() override {} | 137 ~BrowsingDataRemoveAppcacheFunction() override {} |
| 135 | 138 |
| (...skipping 167 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 303 BROWSINGDATA_REMOVEWEBSQL) | 306 BROWSINGDATA_REMOVEWEBSQL) |
| 304 | 307 |
| 305 protected: | 308 protected: |
| 306 ~BrowsingDataRemoveWebSQLFunction() override {} | 309 ~BrowsingDataRemoveWebSQLFunction() override {} |
| 307 | 310 |
| 308 // BrowsingDataRemoverFunction: | 311 // BrowsingDataRemoverFunction: |
| 309 bool GetRemovalMask(int* removal_mask) override; | 312 bool GetRemovalMask(int* removal_mask) override; |
| 310 }; | 313 }; |
| 311 | 314 |
| 312 #endif // CHROME_BROWSER_EXTENSIONS_API_BROWSING_DATA_BROWSING_DATA_API_H_ | 315 #endif // CHROME_BROWSER_EXTENSIONS_API_BROWSING_DATA_BROWSING_DATA_API_H_ |
| OLD | NEW |