Chromium Code Reviews
chromiumcodereview-hr@appspot.gserviceaccount.com (chromiumcodereview-hr) | Please choose your nickname with Settings | Help | Chromium Project | Gerrit Changes | Sign out
(1181)

Unified Diff: chrome/browser/extensions/extension_clear_api.h

Issue 7551008: Strawman proposal for chrome.experimental.clear.* (Closed) Base URL: svn://svn.chromium.org/chrome/trunk/src
Patch Set: Rebasing. Created 9 years, 4 months ago
Use n/p to move between diff chunks; N/P to move between comments. Draft comments are only viewable by you.
Jump to:
View side-by-side diff with in-line comments
Download patch
Index: chrome/browser/extensions/extension_clear_api.h
diff --git a/chrome/browser/extensions/extension_clear_api.h b/chrome/browser/extensions/extension_clear_api.h
new file mode 100644
index 0000000000000000000000000000000000000000..f17c613f4a7f66ed8063a8cf352b81556599cfba
--- /dev/null
+++ b/chrome/browser/extensions/extension_clear_api.h
@@ -0,0 +1,132 @@
+// Copyright (c) 2011 The Chromium Authors. All rights reserved.
+// Use of this source code is governed by a BSD-style license that can be
+// found in the LICENSE file.
+
+// Defines the Chrome Extensions Clear API functions, which entail
+// clearing browsing data, and clearing the browser's cache (which, let's be
+// honest, are the same thing), as specified in
+// chrome/common/extensions/api/extension_api.json.
+
+#ifndef CHROME_BROWSER_EXTENSIONS_EXTENSION_CLEAR_API_H_
+#define CHROME_BROWSER_EXTENSIONS_EXTENSION_CLEAR_API_H_
+#pragma once
+
+#include <string>
+
+#include "chrome/browser/browsing_data_remover.h"
+#include "chrome/browser/extensions/extension_function.h"
+
+namespace base {
+class DictionaryValue;
+}
+
+// This serves as a base class from which the browsing data API functions will
+// inherit. Each needs to be an observer of BrowsingDataRemover events, and each
+// will handle those events in the same way (by calling the passed-in callback
+// function).
+//
+// Each child class must implement removal_mask(), which returns the bitmask of
+// data types to remove.
+class BrowsingDataExtensionFunction : public AsyncExtensionFunction,
+ public BrowsingDataRemover::Observer {
+ public:
+ // BrowsingDataRemover::Observer interface method.
+ virtual void OnBrowsingDataRemoverDone() OVERRIDE;
+
+ // AsyncExtensionFunction interface method.
+ virtual bool RunImpl() OVERRIDE;
+
+ // Children should override this method to provide the proper removal mask
+ // based on the API call they represent.
+ virtual int removal_mask() const = 0;
Mihai Parparita -not on Chrome 2011/08/23 23:24:13 Since this isn't just a simple getter for a variab
Mike West 2011/08/24 09:10:33 Done.
+
+ protected:
+ // Converts the JavaScript API's string input ("last_week") into the
+ // appropriate BrowsingDataRemover::TimePeriod (in this case,
+ // BrowsingDataRemover::LAST_WEEK).
+ virtual bool ParseTimePeriod(const std::string& parse,
Mihai Parparita -not on Chrome 2011/08/23 23:24:13 Would any subclass need to call this? Seems like i
Mike West 2011/08/24 09:10:33 Done.
+ BrowsingDataRemover::TimePeriod* period) const;
+
+ // Convert the JavaScript API's object input ({ cookies: true }) into the
+ // appropriate removal mask for the BrowsingDataRemover object.
+ virtual int ParseRemovalMask(base::DictionaryValue* value) const;
Mihai Parparita -not on Chrome 2011/08/23 23:24:13 It seems like you would only need this for ClearBr
Mike West 2011/08/24 09:10:33 Conceptually, it seemed like something that belong
+};
+
+class ClearBrowsingDataFunction : public BrowsingDataExtensionFunction {
+ public:
+ ClearBrowsingDataFunction() {}
+ virtual ~ClearBrowsingDataFunction() {}
+
+ // BrowsingDataExtensionFunction interface method.
+ virtual int removal_mask() const OVERRIDE;
+
+ DECLARE_EXTENSION_FUNCTION_NAME("experimental.clear.browsingData")
+};
+
+class ClearCacheFunction : public BrowsingDataExtensionFunction {
+ public:
+ ClearCacheFunction() {}
+ virtual ~ClearCacheFunction() {}
+
+ // BrowsingDataTypeExtensionFunction interface method.
+ virtual int removal_mask() const OVERRIDE;
+
+ DECLARE_EXTENSION_FUNCTION_NAME("experimental.clear.cache")
+};
+
+class ClearCookiesFunction : public BrowsingDataExtensionFunction {
+ public:
+ ClearCookiesFunction() {}
+ virtual ~ClearCookiesFunction() {}
+
+ // BrowsingDataTypeExtensionFunction interface method.
+ virtual int removal_mask() const OVERRIDE;
+
+ DECLARE_EXTENSION_FUNCTION_NAME("experimental.clear.cookies")
+};
+
+class ClearDownloadsFunction : public BrowsingDataExtensionFunction {
+ public:
+ ClearDownloadsFunction() {}
+ virtual ~ClearDownloadsFunction() {}
+
+ // BrowsingDataTypeExtensionFunction interface method.
+ virtual int removal_mask() const OVERRIDE;
+
+ DECLARE_EXTENSION_FUNCTION_NAME("experimental.clear.downloads")
+};
+
+class ClearFormDataFunction : public BrowsingDataExtensionFunction {
+ public:
+ ClearFormDataFunction() {}
+ virtual ~ClearFormDataFunction() {}
+
+ // BrowsingDataTypeExtensionFunction interface method.
+ virtual int removal_mask() const OVERRIDE;
+
+ DECLARE_EXTENSION_FUNCTION_NAME("experimental.clear.formData")
+};
+
+class ClearHistoryFunction : public BrowsingDataExtensionFunction {
+ public:
+ ClearHistoryFunction() {}
+ virtual ~ClearHistoryFunction() {}
+
+ // BrowsingDataTypeExtensionFunction interface method.
+ virtual int removal_mask() const OVERRIDE;
+
+ DECLARE_EXTENSION_FUNCTION_NAME("experimental.clear.history")
+};
+
+class ClearPasswordsFunction : public BrowsingDataExtensionFunction {
+ public:
+ ClearPasswordsFunction() {}
+ virtual ~ClearPasswordsFunction() {}
+
+ // BrowsingDataTypeExtensionFunction interface method.
+ virtual int removal_mask() const OVERRIDE;
+
+ DECLARE_EXTENSION_FUNCTION_NAME("experimental.clear.passwords")
+};
+
+#endif // CHROME_BROWSER_EXTENSIONS_EXTENSION_CLEAR_API_H_

Powered by Google App Engine
This is Rietveld 408576698