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; |
| 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 bool ParseTimePeriod(const std::string& parse, |
| 48 BrowsingDataRemover::TimePeriod* 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("experimental.clear.browsingData") |
| 64 }; |
| 65 |
| 66 class ClearCacheFunction : public BrowsingDataExtensionFunction { |
| 67 public: |
| 68 ClearCacheFunction() {} |
| 69 virtual ~ClearCacheFunction() {} |
| 70 |
| 71 // BrowsingDataTypeExtensionFunction interface method. |
| 72 virtual int removal_mask() const OVERRIDE; |
| 73 |
| 74 DECLARE_EXTENSION_FUNCTION_NAME("experimental.clear.cache") |
| 75 }; |
| 76 |
| 77 class ClearCookiesFunction : public BrowsingDataExtensionFunction { |
| 78 public: |
| 79 ClearCookiesFunction() {} |
| 80 virtual ~ClearCookiesFunction() {} |
| 81 |
| 82 // BrowsingDataTypeExtensionFunction interface method. |
| 83 virtual int removal_mask() const OVERRIDE; |
| 84 |
| 85 DECLARE_EXTENSION_FUNCTION_NAME("experimental.clear.cookies") |
| 86 }; |
| 87 |
| 88 class ClearDownloadsFunction : public BrowsingDataExtensionFunction { |
| 89 public: |
| 90 ClearDownloadsFunction() {} |
| 91 virtual ~ClearDownloadsFunction() {} |
| 92 |
| 93 // BrowsingDataTypeExtensionFunction interface method. |
| 94 virtual int removal_mask() const OVERRIDE; |
| 95 |
| 96 DECLARE_EXTENSION_FUNCTION_NAME("experimental.clear.downloads") |
| 97 }; |
| 98 |
| 99 class ClearFormDataFunction : public BrowsingDataExtensionFunction { |
| 100 public: |
| 101 ClearFormDataFunction() {} |
| 102 virtual ~ClearFormDataFunction() {} |
| 103 |
| 104 // BrowsingDataTypeExtensionFunction interface method. |
| 105 virtual int removal_mask() const OVERRIDE; |
| 106 |
| 107 DECLARE_EXTENSION_FUNCTION_NAME("experimental.clear.formData") |
| 108 }; |
| 109 |
| 110 class ClearHistoryFunction : public BrowsingDataExtensionFunction { |
| 111 public: |
| 112 ClearHistoryFunction() {} |
| 113 virtual ~ClearHistoryFunction() {} |
| 114 |
| 115 // BrowsingDataTypeExtensionFunction interface method. |
| 116 virtual int removal_mask() const OVERRIDE; |
| 117 |
| 118 DECLARE_EXTENSION_FUNCTION_NAME("experimental.clear.history") |
| 119 }; |
| 120 |
| 121 class ClearPasswordsFunction : public BrowsingDataExtensionFunction { |
| 122 public: |
| 123 ClearPasswordsFunction() {} |
| 124 virtual ~ClearPasswordsFunction() {} |
| 125 |
| 126 // BrowsingDataTypeExtensionFunction interface method. |
| 127 virtual int removal_mask() const OVERRIDE; |
| 128 |
| 129 DECLARE_EXTENSION_FUNCTION_NAME("experimental.clear.passwords") |
| 130 }; |
| 131 |
| 132 #endif // CHROME_BROWSER_EXTENSIONS_EXTENSION_CLEAR_API_H_ |
OLD | NEW |