Chromium Code Reviews| OLD | NEW |
|---|---|
| (Empty) | |
| 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 | |
| 3 // found in the LICENSE file. | |
| 4 | |
| 5 // Defines the Chrome Extensions Clear API functions, which entail | |
| 6 // clearing browsing data, and clearing the browser's cache (which, let's be | |
| 7 // honest, are the same thing), as specified in | |
| 8 // chrome/common/extensions/api/extension_api.json. | |
| 9 | |
| 10 #ifndef CHROME_BROWSER_EXTENSIONS_EXTENSION_CLEAR_API_H_ | |
| 11 #define CHROME_BROWSER_EXTENSIONS_EXTENSION_CLEAR_API_H_ | |
| 12 #pragma once | |
| 13 | |
| 14 #include <string> | |
| 15 | |
| 16 #include "chrome/browser/browsing_data_remover.h" | |
| 17 #include "chrome/browser/extensions/extension_function.h" | |
| 18 | |
| 19 namespace base { | |
| 20 class DictionaryValue; | |
|
Bernhard Bauer
2011/08/16 09:49:36
Nit: no indent.
Mike West
2011/08/16 11:05:56
Done.
| |
| 21 } | |
| 22 | |
| 23 // This serves as a base class from which the browsing data API functions will | |
| 24 // inherit. Each needs to be an observer of BrowsingDataRemover events, and each | |
| 25 // will handle those events in the same way (by calling the passed-in callback | |
| 26 // function). | |
| 27 // | |
| 28 // Each child class must implement removal_mask(), which returns the bitmask of | |
| 29 // data types to remove. | |
| 30 class BrowsingDataExtensionFunction : public AsyncExtensionFunction, | |
| 31 public BrowsingDataRemover::Observer { | |
| 32 public: | |
| 33 // BrowsingDataRemover::Observer interface method. | |
| 34 virtual void OnBrowsingDataRemoverDone() OVERRIDE; | |
| 35 | |
| 36 // AsyncExtensionFunction interface method. | |
| 37 virtual bool RunImpl() OVERRIDE; | |
| 38 | |
| 39 // Children should override this method to provide the proper removal mask | |
| 40 // based on the API call they represent. | |
| 41 virtual int removal_mask() const = 0; | |
| 42 | |
| 43 protected: | |
| 44 // Converts the JavaScript API's string input ("last_week") into the | |
| 45 // appropriate BrowsingDataRemover::TimePeriod (in this case, | |
| 46 // BrowsingDataRemover::LAST_WEEK). | |
| 47 virtual BrowsingDataRemover::TimePeriod ParseTimePeriod( | |
| 48 const std::string& period) const; | |
| 49 | |
| 50 // Convert the JavaScript API's object input ({ cookies: true }) into the | |
| 51 // appropriate removal mask for the BrowsingDataRemover object. | |
| 52 virtual int ParseRemovalMask(base::DictionaryValue* value) const; | |
| 53 }; | |
| 54 | |
| 55 class ClearBrowsingDataFunction : public BrowsingDataExtensionFunction { | |
| 56 public: | |
| 57 ClearBrowsingDataFunction() {} | |
| 58 virtual ~ClearBrowsingDataFunction() {} | |
| 59 | |
| 60 // BrowsingDataExtensionFunction interface method. | |
| 61 virtual int removal_mask() const OVERRIDE; | |
| 62 | |
| 63 DECLARE_EXTENSION_FUNCTION_NAME( | |
|
Bernhard Bauer
2011/08/16 09:49:36
Nit: does this fit on one line?
Mike West
2011/08/16 11:05:56
Done.
| |
| 64 "experimental.clear.browsingData") | |
| 65 }; | |
| 66 | |
| 67 class ClearCacheFunction : public BrowsingDataExtensionFunction { | |
| 68 public: | |
| 69 ClearCacheFunction() {} | |
| 70 virtual ~ClearCacheFunction() {} | |
| 71 | |
| 72 // BrowsingDataTypeExtensionFunction interface method. | |
| 73 virtual int removal_mask() const OVERRIDE; | |
| 74 | |
| 75 DECLARE_EXTENSION_FUNCTION_NAME( | |
| 76 "experimental.clear.cache") | |
| 77 }; | |
| 78 | |
| 79 class ClearCookiesFunction : public BrowsingDataExtensionFunction { | |
| 80 public: | |
| 81 ClearCookiesFunction() {} | |
| 82 virtual ~ClearCookiesFunction() {} | |
| 83 | |
| 84 // BrowsingDataTypeExtensionFunction interface method. | |
| 85 virtual int removal_mask() const OVERRIDE; | |
| 86 | |
| 87 DECLARE_EXTENSION_FUNCTION_NAME( | |
| 88 "experimental.clear.cookies") | |
| 89 }; | |
| 90 | |
| 91 class ClearDownloadsFunction : public BrowsingDataExtensionFunction { | |
| 92 public: | |
| 93 ClearDownloadsFunction() {} | |
| 94 virtual ~ClearDownloadsFunction() {} | |
| 95 | |
| 96 // BrowsingDataTypeExtensionFunction interface method. | |
| 97 virtual int removal_mask() const OVERRIDE; | |
| 98 | |
| 99 DECLARE_EXTENSION_FUNCTION_NAME( | |
| 100 "experimental.clear.downloads") | |
| 101 }; | |
| 102 | |
| 103 class ClearFormDataFunction : public BrowsingDataExtensionFunction { | |
| 104 public: | |
| 105 ClearFormDataFunction() {} | |
| 106 virtual ~ClearFormDataFunction() {} | |
| 107 | |
| 108 // BrowsingDataTypeExtensionFunction interface method. | |
| 109 virtual int removal_mask() const OVERRIDE; | |
| 110 | |
| 111 DECLARE_EXTENSION_FUNCTION_NAME( | |
| 112 "experimental.clear.formData") | |
| 113 }; | |
| 114 | |
| 115 class ClearHistoryFunction : public BrowsingDataExtensionFunction { | |
| 116 public: | |
| 117 ClearHistoryFunction() {} | |
| 118 virtual ~ClearHistoryFunction() {} | |
| 119 | |
| 120 // BrowsingDataTypeExtensionFunction interface method. | |
| 121 virtual int removal_mask() const OVERRIDE; | |
| 122 | |
| 123 DECLARE_EXTENSION_FUNCTION_NAME( | |
| 124 "experimental.clear.history") | |
| 125 }; | |
| 126 | |
| 127 class ClearPasswordsFunction : public BrowsingDataExtensionFunction { | |
| 128 public: | |
| 129 ClearPasswordsFunction() {} | |
| 130 virtual ~ClearPasswordsFunction() {} | |
| 131 | |
| 132 // BrowsingDataTypeExtensionFunction interface method. | |
| 133 virtual int removal_mask() const OVERRIDE; | |
| 134 | |
| 135 DECLARE_EXTENSION_FUNCTION_NAME( | |
| 136 "experimental.clear.passwords") | |
| 137 }; | |
| 138 | |
| 139 #endif // CHROME_BROWSER_EXTENSIONS_EXTENSION_CLEAR_API_H_ | |
| OLD | NEW |