Commit 6b55790a authored by mkwst@chromium.org's avatar mkwst@chromium.org

Reland of r114615: "chrome.clear: Increasing granularity of public API"

http://codereview.chromium.org/7717023 added more granular options to
BrowsingDataRemover. This CL exposes those options to the chrome.clear
extension API. Among other things, this means that chrome.clear.cookies()
will _only_ clear cookies, not cookies and site data.

At the moment, clearing any quota managed data type will clear them all.
That is being addressed in http://codereview.chromium.org/7839029/
but is independent from changing the public interface.

BUG=94334
TEST=browser_tests


Review URL: http://codereview.chromium.org/8952014

git-svn-id: svn://svn.chromium.org/chrome/trunk/src@114630 0039d316-1c4b-4281-b951-d872f2087c98
parent 0fe65a47
......@@ -128,7 +128,7 @@ class BrowsingDataRemover : public content::NotificationObserver,
private:
// The clear API needs to be able to toggle removing_ in order to test that
// only one BrowsingDataRemover instance can be called at a time.
FRIEND_TEST_ALL_PREFIXES(ExtensionApiTest, ClearOneAtATime);
FRIEND_TEST_ALL_PREFIXES(ExtensionClearTest, OneAtATime);
enum CacheState {
STATE_NONE,
......
......@@ -12,7 +12,6 @@
#include "base/values.h"
#include "chrome/browser/browsing_data_remover.h"
#include "chrome/browser/extensions/extension_clear_api_constants.h"
#include "chrome/browser/plugin_data_remover_helper.h"
#include "chrome/browser/plugin_prefs.h"
#include "chrome/browser/profiles/profile.h"
......@@ -23,28 +22,31 @@
using content::BrowserThread;
namespace keys = extension_clear_api_constants;
namespace extension_clear_api_constants {
namespace {
// Keys.
const char kAppCacheKey[] = "appcache";
const char kCacheKey[] = "cache";
const char kCookiesKey[] = "cookies";
const char kDownloadsKey[] = "downloads";
const char kFileSystemsKey[] = "fileSystems";
const char kFormDataKey[] = "formData";
const char kHistoryKey[] = "history";
const char kIndexedDBKey[] = "indexedDB";
const char kPluginDataKey[] = "pluginData";
const char kLocalStorageKey[] = "localStorage";
const char kPasswordsKey[] = "passwords";
const char kWebSQLKey[] = "webSQL";
// Converts the JavaScript API's string input ("last_week") into the
// appropriate BrowsingDataRemover::TimePeriod (in this case,
// BrowsingDataRemover::LAST_WEEK).
bool ParseTimePeriod(const std::string& parse,
BrowsingDataRemover::TimePeriod* period) {
if (parse == keys::kHourEnum)
*period = BrowsingDataRemover::LAST_HOUR;
else if (parse == keys::kDayEnum)
*period = BrowsingDataRemover::LAST_DAY;
else if (parse == keys::kWeekEnum)
*period = BrowsingDataRemover::LAST_WEEK;
else if (parse == keys::kMonthEnum)
*period = BrowsingDataRemover::FOUR_WEEKS;
else if (parse == keys::kEverythingEnum)
*period = BrowsingDataRemover::EVERYTHING;
else
return false;
// Errors!
const char kOneAtATimeError[] = "Only one 'clear' API call can run at a time.";
} // namespace extension_clear_api_constants
namespace {
// Converts the JavaScript API's numeric input (miliseconds since epoch) into an
// appropriate base::Time that we can pass into the BrowsingDataRemove.
bool ParseTimeFromValue(const double& ms_since_epoch, base::Time* time) {
return true;
}
......@@ -62,21 +64,30 @@ bool DataRemovalRequested(base::DictionaryValue* dict, std::string key) {
// appropriate removal mask for the BrowsingDataRemover object.
int ParseRemovalMask(base::DictionaryValue* value) {
int GetRemovalMask = 0;
if (DataRemovalRequested(value, keys::kCacheKey))
if (DataRemovalRequested(value, extension_clear_api_constants::kAppCacheKey))
GetRemovalMask |= BrowsingDataRemover::REMOVE_APPCACHE;
if (DataRemovalRequested(value, extension_clear_api_constants::kCacheKey))
GetRemovalMask |= BrowsingDataRemover::REMOVE_CACHE;
if (DataRemovalRequested(value, keys::kDownloadsKey))
if (DataRemovalRequested(value, extension_clear_api_constants::kCookiesKey))
GetRemovalMask |= BrowsingDataRemover::REMOVE_COOKIES;
if (DataRemovalRequested(value, extension_clear_api_constants::kDownloadsKey))
GetRemovalMask |= BrowsingDataRemover::REMOVE_DOWNLOADS;
if (DataRemovalRequested(value, keys::kFormDataKey))
if (DataRemovalRequested(value, extension_clear_api_constants::kPasswordsKey))
GetRemovalMask |= BrowsingDataRemover::REMOVE_FILE_SYSTEMS;
if (DataRemovalRequested(value, extension_clear_api_constants::kFormDataKey))
GetRemovalMask |= BrowsingDataRemover::REMOVE_FORM_DATA;
if (DataRemovalRequested(value, keys::kHistoryKey))
if (DataRemovalRequested(value, extension_clear_api_constants::kHistoryKey))
GetRemovalMask |= BrowsingDataRemover::REMOVE_HISTORY;
if (DataRemovalRequested(value, keys::kPasswordsKey))
if (DataRemovalRequested(value, extension_clear_api_constants::kPasswordsKey))
GetRemovalMask |= BrowsingDataRemover::REMOVE_INDEXEDDB;
if (DataRemovalRequested(value, extension_clear_api_constants::kPasswordsKey))
GetRemovalMask |= BrowsingDataRemover::REMOVE_LOCAL_STORAGE;
if (DataRemovalRequested(value, extension_clear_api_constants::kPasswordsKey))
GetRemovalMask |= BrowsingDataRemover::REMOVE_PLUGIN_DATA;
if (DataRemovalRequested(value, extension_clear_api_constants::kPasswordsKey))
GetRemovalMask |= BrowsingDataRemover::REMOVE_PASSWORDS;
// When we talk users about "cookies", we mean not just cookies, but pretty
// much everything associated with an origin.
if (DataRemovalRequested(value, keys::kCookiesKey))
GetRemovalMask |= BrowsingDataRemover::REMOVE_SITE_DATA;
if (DataRemovalRequested(value, extension_clear_api_constants::kPasswordsKey))
GetRemovalMask |= BrowsingDataRemover::REMOVE_WEBSQL;
return GetRemovalMask;
}
......@@ -92,14 +103,19 @@ void BrowsingDataExtensionFunction::OnBrowsingDataRemoverDone() {
bool BrowsingDataExtensionFunction::RunImpl() {
if (BrowsingDataRemover::is_removing()) {
error_ = keys::kOneAtATimeError;
error_ = extension_clear_api_constants::kOneAtATimeError;
return false;
}
// Parse the |timeframe| argument to generate the TimePeriod.
std::string timeframe;
EXTENSION_FUNCTION_VALIDATE(args_->GetString(0, &timeframe));
EXTENSION_FUNCTION_VALIDATE(ParseTimePeriod(timeframe, &period_));
double ms_since_epoch;
EXTENSION_FUNCTION_VALIDATE(args_->GetDouble(0, &ms_since_epoch));
// base::Time takes a double that represents seconds since epoch. JavaScript
// gives developers milliseconds, so do a quick conversion before populating
// the object. Also, Time::FromDoubleT converts double time 0 to empty Time
// object. So we need to do special handling here.
remove_since_ = (ms_since_epoch == 0) ?
base::Time::UnixEpoch() :
base::Time::FromDoubleT(ms_since_epoch / 1000.0);
removal_mask_ = GetRemovalMask();
......@@ -140,7 +156,7 @@ void BrowsingDataExtensionFunction::StartRemoving() {
// we've generated above. We can use a raw pointer here, as the browsing data
// remover is responsible for deleting itself once data removal is complete.
BrowsingDataRemover* remover = new BrowsingDataRemover(
GetCurrentBrowser()->profile(), period_, base::Time::Now());
GetCurrentBrowser()->profile(), remove_since_, base::Time::Now());
remover->AddObserver(this);
remover->Remove(removal_mask_);
}
......@@ -154,18 +170,26 @@ int ClearBrowsingDataFunction::GetRemovalMask() const {
return 0;
}
int ClearAppCacheFunction::GetRemovalMask() const {
return BrowsingDataRemover::REMOVE_APPCACHE;
}
int ClearCacheFunction::GetRemovalMask() const {
return BrowsingDataRemover::REMOVE_CACHE;
}
int ClearCookiesFunction::GetRemovalMask() const {
return BrowsingDataRemover::REMOVE_SITE_DATA;
return BrowsingDataRemover::REMOVE_COOKIES;
}
int ClearDownloadsFunction::GetRemovalMask() const {
return BrowsingDataRemover::REMOVE_DOWNLOADS;
}
int ClearFileSystemsFunction::GetRemovalMask() const {
return BrowsingDataRemover::REMOVE_FILE_SYSTEMS;
}
int ClearFormDataFunction::GetRemovalMask() const {
return BrowsingDataRemover::REMOVE_FORM_DATA;
}
......@@ -174,6 +198,22 @@ int ClearHistoryFunction::GetRemovalMask() const {
return BrowsingDataRemover::REMOVE_HISTORY;
}
int ClearIndexedDBFunction::GetRemovalMask() const {
return BrowsingDataRemover::REMOVE_INDEXEDDB;
}
int ClearLocalStorageFunction::GetRemovalMask() const {
return BrowsingDataRemover::REMOVE_LOCAL_STORAGE;
}
int ClearPluginDataFunction::GetRemovalMask() const {
return BrowsingDataRemover::REMOVE_PLUGIN_DATA;
}
int ClearPasswordsFunction::GetRemovalMask() const {
return BrowsingDataRemover::REMOVE_CACHE;
return BrowsingDataRemover::REMOVE_PASSWORDS;
}
int ClearWebSQLFunction::GetRemovalMask() const {
return BrowsingDataRemover::REMOVE_WEBSQL;
}
......@@ -17,6 +17,27 @@
class PluginPrefs;
namespace extension_clear_api_constants {
// Keys.
extern const char kAppCacheKey[];
extern const char kCacheKey[];
extern const char kCookiesKey[];
extern const char kDownloadsKey[];
extern const char kFileSystemsKey[];
extern const char kFormDataKey[];
extern const char kHistoryKey[];
extern const char kIndexedDBKey[];
extern const char kPluginDataKey[];
extern const char kLocalStorageKey[];
extern const char kPasswordsKey[];
extern const char kWebSQLKey[];
// Errors!
extern const char kOneAtATimeError[];
} // namespace extension_clear_api_constants
// 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
......@@ -47,10 +68,22 @@ class BrowsingDataExtensionFunction : public AsyncExtensionFunction,
// Called when we're ready to start removing data.
void StartRemoving();
BrowsingDataRemover::TimePeriod period_;
base::Time remove_since_;
int removal_mask_;
};
class ClearAppCacheFunction : public BrowsingDataExtensionFunction {
public:
ClearAppCacheFunction() {}
virtual ~ClearAppCacheFunction() {}
protected:
// BrowsingDataTypeExtensionFunction interface method.
virtual int GetRemovalMask() const OVERRIDE;
DECLARE_EXTENSION_FUNCTION_NAME("experimental.clear.appcache")
};
class ClearBrowsingDataFunction : public BrowsingDataExtensionFunction {
public:
ClearBrowsingDataFunction() {}
......@@ -99,6 +132,18 @@ class ClearDownloadsFunction : public BrowsingDataExtensionFunction {
DECLARE_EXTENSION_FUNCTION_NAME("experimental.clear.downloads")
};
class ClearFileSystemsFunction : public BrowsingDataExtensionFunction {
public:
ClearFileSystemsFunction() {}
virtual ~ClearFileSystemsFunction() {}
protected:
// BrowsingDataTypeExtensionFunction interface method.
virtual int GetRemovalMask() const OVERRIDE;
DECLARE_EXTENSION_FUNCTION_NAME("experimental.clear.fileSystems")
};
class ClearFormDataFunction : public BrowsingDataExtensionFunction {
public:
ClearFormDataFunction() {}
......@@ -123,6 +168,42 @@ class ClearHistoryFunction : public BrowsingDataExtensionFunction {
DECLARE_EXTENSION_FUNCTION_NAME("experimental.clear.history")
};
class ClearIndexedDBFunction : public BrowsingDataExtensionFunction {
public:
ClearIndexedDBFunction() {}
virtual ~ClearIndexedDBFunction() {}
protected:
// BrowsingDataTypeExtensionFunction interface method.
virtual int GetRemovalMask() const OVERRIDE;
DECLARE_EXTENSION_FUNCTION_NAME("experimental.clear.indexedDB")
};
class ClearLocalStorageFunction : public BrowsingDataExtensionFunction {
public:
ClearLocalStorageFunction() {}
virtual ~ClearLocalStorageFunction() {}
protected:
// BrowsingDataTypeExtensionFunction interface method.
virtual int GetRemovalMask() const OVERRIDE;
DECLARE_EXTENSION_FUNCTION_NAME("experimental.clear.localStorage")
};
class ClearPluginDataFunction : public BrowsingDataExtensionFunction {
public:
ClearPluginDataFunction() {}
virtual ~ClearPluginDataFunction() {}
protected:
// BrowsingDataTypeExtensionFunction interface method.
virtual int GetRemovalMask() const OVERRIDE;
DECLARE_EXTENSION_FUNCTION_NAME("experimental.clear.pluginData")
};
class ClearPasswordsFunction : public BrowsingDataExtensionFunction {
public:
ClearPasswordsFunction() {}
......@@ -135,4 +216,15 @@ class ClearPasswordsFunction : public BrowsingDataExtensionFunction {
DECLARE_EXTENSION_FUNCTION_NAME("experimental.clear.passwords")
};
class ClearWebSQLFunction : public BrowsingDataExtensionFunction {
public:
ClearWebSQLFunction() {}
virtual ~ClearWebSQLFunction() {}
protected:
// BrowsingDataTypeExtensionFunction interface method.
virtual int GetRemovalMask() const OVERRIDE;
DECLARE_EXTENSION_FUNCTION_NAME("experimental.clear.webSQL")
};
#endif // CHROME_BROWSER_EXTENSIONS_EXTENSION_CLEAR_API_H_
// 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.
#include "chrome/browser/extensions/extension_clear_api_constants.h"
namespace extension_clear_api_constants {
// Keys.
const char kCacheKey[] = "cache";
const char kCookiesKey[] = "cookies";
const char kDownloadsKey[] = "downloads";
const char kFormDataKey[] = "formData";
const char kHistoryKey[] = "history";
const char kPasswordsKey[] = "passwords";
// Timeframe "enum" values.
const char kHourEnum[] = "last_hour";
const char kDayEnum[] = "last_day";
const char kWeekEnum[] = "last_week";
const char kMonthEnum[] = "last_month";
const char kEverythingEnum[] = "everything";
// Errors!
const char kOneAtATimeError[] = "Only one 'clear' API call can run at a time.";
} // namespace extension_clear_api_constants
// 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.
// Constants used for the Cookies API.
#ifndef CHROME_BROWSER_EXTENSIONS_EXTENSION_CLEAR_API_CONSTANTS_H_
#define CHROME_BROWSER_EXTENSIONS_EXTENSION_CLEAR_API_CONSTANTS_H_
#pragma once
namespace extension_clear_api_constants {
// Keys.
extern const char kCacheKey[];
extern const char kCookiesKey[];
extern const char kDownloadsKey[];
extern const char kFormDataKey[];
extern const char kHistoryKey[];
extern const char kPasswordsKey[];
// Timeframe "enum" values.
extern const char kHourEnum[];
extern const char kDayEnum[];
extern const char kWeekEnum[];
extern const char kMonthEnum[];
extern const char kEverythingEnum[];
// Errors!
extern const char kOneAtATimeError[];
} // namespace extension_clear_api_constants
#endif // CHROME_BROWSER_EXTENSIONS_EXTENSION_CLEAR_API_CONSTANTS_H_
// 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.
#include "base/command_line.h"
#include "chrome/browser/browsing_data_remover.h"
#include "chrome/browser/extensions/extension_apitest.h"
#include "chrome/common/chrome_switches.h"
IN_PROC_BROWSER_TEST_F(ExtensionApiTest, Clear) {
CommandLine::ForCurrentProcess()->AppendSwitch(
switches::kEnableExperimentalExtensionApis);
ASSERT_TRUE(RunExtensionTest("clear/api")) << message_;
}
IN_PROC_BROWSER_TEST_F(ExtensionApiTest, ClearOneAtATime) {
CommandLine::ForCurrentProcess()->AppendSwitch(
switches::kEnableExperimentalExtensionApis);
BrowsingDataRemover::set_removing(true);
ASSERT_TRUE(RunExtensionTest("clear/one_at_a_time")) << message_;
BrowsingDataRemover::set_removing(false);
}
// 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.
#include "chrome/browser/extensions/extension_clear_api.h"
#include <string>
#include "base/memory/ref_counted.h"
#include "base/memory/scoped_ptr.h"
#include "base/string_util.h"
#include "base/stringprintf.h"
#include "base/values.h"
#include "chrome/browser/browsing_data_remover.h"
#include "chrome/browser/extensions/extension_function_test_utils.h"
#include "chrome/browser/profiles/profile.h"
#include "chrome/browser/ui/browser.h"
#include "chrome/common/chrome_notification_types.h"
#include "chrome/test/base/in_process_browser_test.h"
#include "content/public/browser/notification_service.h"
using namespace extension_function_test_utils;
namespace {
const char kClearEverythingArguments[] = "[1000, {"
"\"appcache\": true, \"cache\": true, \"cookies\": true, "
"\"downloads\": true, \"fileSystems\": true, \"formData\": true, "
"\"history\": true, \"indexedDB\": true, \"localStorage\": true, "
"\"pluginData\": true, \"passwords\": true, \"webSQL\": true"
"}]";
class ExtensionClearTest : public InProcessBrowserTest,
public content::NotificationObserver {
public:
base::Time GetBeginTime() {
return called_with_details_->removal_begin;
}
int GetRemovalMask() {
return called_with_details_->removal_mask;
}
protected:
virtual void SetUpOnMainThread() {
called_with_details_.reset(new BrowsingDataRemover::NotificationDetails());
registrar_.Add(this, chrome::NOTIFICATION_BROWSING_DATA_REMOVED,
content::Source<Profile>(browser()->profile()));
}
// content::NotificationObserver implementation.
virtual void Observe(int type,
const content::NotificationSource& source,
const content::NotificationDetails& details) OVERRIDE {
DCHECK_EQ(type, chrome::NOTIFICATION_BROWSING_DATA_REMOVED);
// We're not taking ownership of the details object, but storing a copy of
// it locally.
called_with_details_.reset(new BrowsingDataRemover::NotificationDetails(
*content::Details<BrowsingDataRemover::NotificationDetails>(
details).ptr()));
registrar_.RemoveAll();
}
private:
scoped_ptr<BrowsingDataRemover::NotificationDetails> called_with_details_;
content::NotificationRegistrar registrar_;
};
} // namespace
IN_PROC_BROWSER_TEST_F(ExtensionClearTest, OneAtATime) {
BrowsingDataRemover::set_removing(true);
EXPECT_TRUE(MatchPattern(
RunFunctionAndReturnError(
new ClearBrowsingDataFunction(),
kClearEverythingArguments,
browser()),
extension_clear_api_constants::kOneAtATimeError));
BrowsingDataRemover::set_removing(false);
EXPECT_EQ(base::Time(), GetBeginTime());
EXPECT_EQ(-1, GetRemovalMask());
}
IN_PROC_BROWSER_TEST_F(ExtensionClearTest, ClearBrowsingDataEverything) {
EXPECT_EQ(NULL, RunFunctionAndReturnResult(new ClearBrowsingDataFunction(),
kClearEverythingArguments, browser()));
EXPECT_EQ(base::Time::FromDoubleT(1.0), GetBeginTime());
EXPECT_EQ((BrowsingDataRemover::REMOVE_SITE_DATA |
BrowsingDataRemover::REMOVE_CACHE |
BrowsingDataRemover::REMOVE_DOWNLOADS |
BrowsingDataRemover::REMOVE_FORM_DATA |
BrowsingDataRemover::REMOVE_HISTORY |
BrowsingDataRemover::REMOVE_PASSWORDS) &
// We can't remove plugin data inside a test profile.
~BrowsingDataRemover::REMOVE_PLUGIN_DATA, GetRemovalMask());
}
......@@ -185,12 +185,18 @@ void FactoryRegistry::ResetFunctions() {
// Browsing Data.
RegisterFunction<ClearBrowsingDataFunction>();
RegisterFunction<ClearAppCacheFunction>();
RegisterFunction<ClearCacheFunction>();
RegisterFunction<ClearCookiesFunction>();
RegisterFunction<ClearDownloadsFunction>();
RegisterFunction<ClearFileSystemsFunction>();
RegisterFunction<ClearFormDataFunction>();
RegisterFunction<ClearHistoryFunction>();
RegisterFunction<ClearIndexedDBFunction>();
RegisterFunction<ClearLocalStorageFunction>();
RegisterFunction<ClearPluginDataFunction>();
RegisterFunction<ClearPasswordsFunction>();
RegisterFunction<ClearWebSQLFunction>();
// Bookmarks.
RegisterFunction<GetBookmarksFunction>();
......
......@@ -138,8 +138,8 @@ base::Value* RunFunctionAndReturnResult(UIThreadExtensionFunction* function,
RunFunction(function, args, browser, flags);
EXPECT_TRUE(function->GetError().empty()) << "Unexpected error: "
<< function->GetError();
EXPECT_TRUE(function->GetResultValue()) << "No result value found";
return function->GetResultValue()->DeepCopy();
return (function->GetResultValue() == NULL) ? NULL :
function->GetResultValue()->DeepCopy();
}
// This helps us be able to wait until an AsyncExtensionFunction calls
......
......@@ -991,8 +991,6 @@
'browser/extensions/extension_chrome_auth_private_api.h',
'browser/extensions/extension_clear_api.cc',
'browser/extensions/extension_clear_api.h',
'browser/extensions/extension_clear_api_constants.cc',
'browser/extensions/extension_clear_api_constants.h',
'browser/extensions/extension_content_settings_api.cc',
'browser/extensions/extension_content_settings_api.h',
'browser/extensions/extension_content_settings_api_constants.cc',
......
......@@ -2519,7 +2519,7 @@
'browser/extensions/extension_browsertest.h',
'browser/extensions/extension_browsertests_misc.cc',
'browser/extensions/extension_chrome_auth_private_apitest.cc',
'browser/extensions/extension_clear_apitest.cc',
'browser/extensions/extension_clear_test.cc',
'browser/extensions/extension_content_settings_apitest.cc',
'browser/extensions/extension_context_menu_apitest.cc',
'browser/extensions/extension_context_menu_browsertest.cc',
......
......@@ -8784,10 +8784,9 @@
"namespace": "experimental.clear",
"types": [
{
"id": "TimePeriod",
"type": "string",
"enum": ["last_hour", "last_day", "last_week", "last_month", "everything"],
"description": "The timeframe inside of which to delete browsing data. Passing 'last_day', for example, will delete all browsing data that was touched between 24 hours ago and right now, inclusive."
"id": "RemovalRange",
"type": "number",
"description": "Remove data accumulated on or after this date, represented in milliseconds since the epoch ('Date().GetTime()')"
}
],
"functions": [
......@@ -8797,14 +8796,19 @@
"type": "function",
"parameters": [
{
"$ref": "TimePeriod",
"name": "period"
"$ref": "RemovalRange",
"name": "since"
},
{
"name": "dataToRemove",
"type": "object",
"description": "An object whose properties specify which browsing data types ought to be cleared. You may set as many or as few as you like in a single call, each is optional (defaulting to <code>false</code>).",
"properties": {
"appcache": {
"type": "boolean",
"optional": true,
"description": "Should websites' appcaches be cleared?"
},
"cache": {
"type": "boolean",
"optional": true,
......@@ -8820,6 +8824,11 @@
"optional": true,
"description": "Should the browser's download list be cleared?"
},
"fileSystems": {
"type": "boolean",
"optional": true,
"description": "Should websites' file systems be cleared?"
},
"formData": {
"type": "boolean",
"optional": true,
......@@ -8830,10 +8839,30 @@
"optional": true,
"description": "Should the browser's history be cleared?"
},
"indexedDB": {
"type": "boolean",
"optional": true,
"description": "Should websites' IndexedDB data be cleared?"
},
"localStorage": {
"type": "boolean",
"optional": true,
"description": "Should websites' local storage data be cleared?"
},
"pluginData": {
"type": "boolean",
"optional": true,
"description": "Should plugins' data be cleared?"
},
"passwords": {
"type": "boolean",
"optional": true,
"description": "Should the stored passwords be cleared?"
},
"webSQL": {
"type": "boolean",
"optional": true,
"description": "Should websites' WebSQL data be cleared?"
}
}
},
......@@ -8846,19 +8875,37 @@
}
]
},
{
"name": "appcache",
"description": "Clears websites' appcache data.",
"type": "function",
"parameters": [
{
"$ref": "RemovalRange",
"name": "since"
},
{
"name": "callback",
"type": "function",
"description": "Called when websites' appcache data has been cleared.",
"optional": true,
"parameters": []
}
]
},
{
"name": "cache",
"description": "Clears the browser's cache.",
"type": "function",
"parameters": [
{
"$ref": "TimePeriod",
"name": "period"
"$ref": "RemovalRange",
"name": "since"
},
{
"name": "callback",
"type": "function",
"description": "Called when the browser's cache has cleared.",
"description": "Called when the browser's cache has been cleared.",
"optional": true,
"parameters": []
}
......@@ -8866,17 +8913,17 @@
},
{
"name": "cookies",
"description": "Clears the browser's cookies and site data.",
"description": "Clears the browser's cookies.",
"type": "function",
"parameters": [
{
"$ref": "TimePeriod",
"name": "period"
"$ref": "RemovalRange",
"name": "since"
},
{
"name": "callback",
"type": "function",
"description": "Called when the browser's cookies and site data have been cleared.",
"description": "Called when the browser's cookies have been cleared.",
"optional": true,
"parameters": []
}
......@@ -8888,8 +8935,8 @@
"type": "function",
"parameters": [
{
"$ref": "TimePeriod",
"name": "period"
"$ref": "RemovalRange",
"name": "since"
},
{
"name": "callback",
......@@ -8900,14 +8947,32 @@
}
]
},
{
"name": "fileSystems",
"description": "Clears websites' file system data.",
"type": "function",
"parameters": [
{
"$ref": "RemovalRange",
"name": "since"
},
{
"name": "callback",
"type": "function",
"description": "Called when websites' file systems have been cleared.",
"optional": true,
"parameters": []
}
]
},
{
"name": "formData",
"description": "Clears the browser's stored form data (autofill).",
"type": "function",
"parameters": [
{
"$ref": "TimePeriod",
"name": "period"
"$ref": "RemovalRange",
"name": "since"
},
{
"name": "callback",
......@@ -8924,8 +8989,8 @@
"type": "function",
"parameters": [
{
"$ref": "TimePeriod",
"name": "period"
"$ref": "RemovalRange",
"name": "since"
},
{
"name": "callback",
......@@ -8936,14 +9001,68 @@
}
]
},
{
"name": "indexedDB",
"description": "Clears websites' IndexedDB data.",
"type": "function",
"parameters": [
{
"$ref": "RemovalRange",
"name": "since"
},
{
"name": "callback",
"type": "function",
"description": "Called when websites' IndexedDB data has been cleared.",
"optional": true,
"parameters": []
}
]
},
{
"name": "localStorage",
"description": "Clears websites' local storage data.",
"type": "function",
"parameters": [
{
"$ref": "RemovalRange",
"name": "since"
},
{
"name": "callback",
"type": "function",
"description": "Called when websites' local storage has been cleared.",
"optional": true,
"parameters": []
}
]
},
{
"name": "lsoData",
"description": "Clears plugins' Local Storage Object data.",
"type": "function",
"parameters": [
{
"$ref": "RemovalRange",
"name": "since"
},
{
"name": "callback",
"type": "function",
"description": "Called when plugins' Local Storage Data has been cleared.",
"optional": true,
"parameters": []
}
]
},
{
"name": "passwords",
"description": "Clears the browser's stored passwords.",
"type": "function",
"parameters": [
{
"$ref": "TimePeriod",
"name": "period"
"$ref": "RemovalRange",
"name": "since"
},
{
"name": "callback",
......@@ -8953,6 +9072,24 @@
"parameters": []
}
]
},
{
"name": "webSQL",
"description": "Clears websites' WebSQL data.",
"type": "function",
"parameters": [
{
"$ref": "RemovalRange",
"name": "since"
},
{
"name": "callback",
"type": "function",
"description": "Called when websites' WebSQL databases have been cleared.",
"optional": true,
"parameters": []
}
]
}
]
},
......
......@@ -40,13 +40,19 @@
"chrome.experimental.app.notify": "experimental.app.html#method-notify",
"chrome.experimental.app.resetLaunchIcon": "experimental.app.html#method-resetLaunchIcon",
"chrome.experimental.app.setLaunchIcon": "experimental.app.html#method-setLaunchIcon",
"chrome.experimental.clear.appcache": "experimental.clear.html#method-appcache",
"chrome.experimental.clear.browsingData": "experimental.clear.html#method-browsingData",
"chrome.experimental.clear.cache": "experimental.clear.html#method-cache",
"chrome.experimental.clear.cookies": "experimental.clear.html#method-cookies",
"chrome.experimental.clear.downloads": "experimental.clear.html#method-downloads",
"chrome.experimental.clear.fileSystems": "experimental.clear.html#method-fileSystems",
"chrome.experimental.clear.formData": "experimental.clear.html#method-formData",
"chrome.experimental.clear.history": "experimental.clear.html#method-history",
"chrome.experimental.clear.indexedDB": "experimental.clear.html#method-indexedDB",
"chrome.experimental.clear.localStorage": "experimental.clear.html#method-localStorage",
"chrome.experimental.clear.lsoData": "experimental.clear.html#method-lsoData",
"chrome.experimental.clear.passwords": "experimental.clear.html#method-passwords",
"chrome.experimental.clear.webSQL": "experimental.clear.html#method-webSQL",
"chrome.experimental.debugger.attach": "experimental.debugger.html#method-attach",
"chrome.experimental.debugger.detach": "experimental.debugger.html#method-detach",
"chrome.experimental.debugger.onDetach": "experimental.debugger.html#event-onDetach",
......
<!--
* 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.
-->
<script src="background.js"></script>
// 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.
var allTypes = {
cache: true,
cookies: true,
downloads: true,
formData: true,
history: true,
passwords: true
};
chrome.test.runTests([
function testClearEverything() {
chrome.experimental.clear.browsingData("everything", allTypes,
chrome.test.callbackPass());
},
function testClearCache() {
chrome.experimental.clear.cache(
"everything", chrome.test.callbackPass());
},
function testClearCookies() {
chrome.experimental.clear.cookies(
"everything", chrome.test.callbackPass());
},
function testClearHistory() {
chrome.experimental.clear.history(
"everything", chrome.test.callbackPass());
},
function testClearPasswords() {
chrome.experimental.clear.passwords(
"everything", chrome.test.callbackPass());
},
function testClearDownloads() {
chrome.experimental.clear.downloads(
"everything", chrome.test.callbackPass());
},
function testClearFormData() {
chrome.experimental.clear.formData(
"everything", chrome.test.callbackPass());
}
]);
{
"name": "chrome.clear API Test",
"version": "0.1",
"manifest_version": 2,
"description": "end-to-end browser test for chrome.experimental.clear API",
"background_page": "background.html",
"permissions": [
"experimental",
"clear"
]
}
<!--
* 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.
-->
<script src="background.js"></script>
// 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.
var allTypes = {
cache: true,
cookies: true,
downloads: true,
formData: true,
history: true,
passwords: true
};
chrome.test.runTests([
function testEverything() {
chrome.experimental.clear.browsingData("everything", allTypes,
chrome.test.callbackFail(
'Only one \'clear\' API call can run at a time.'));
},
function testClearCache() {
chrome.experimental.clear.cache("everything",
chrome.test.callbackFail(
'Only one \'clear\' API call can run at a time.'));
},
function testClearCookies() {
chrome.experimental.clear.cookies("everything",
chrome.test.callbackFail(
'Only one \'clear\' API call can run at a time.'));
},
function testClearHistory() {
chrome.experimental.clear.history("everything",
chrome.test.callbackFail(
'Only one \'clear\' API call can run at a time.'));
},
function testClearPasswords() {
chrome.experimental.clear.passwords("everything",
chrome.test.callbackFail(
'Only one \'clear\' API call can run at a time.'));
},
function testClearDownloads() {
chrome.experimental.clear.downloads("everything",
chrome.test.callbackFail(
'Only one \'clear\' API call can run at a time.'));
},
function testClearFormData() {
chrome.experimental.clear.formData("everything",
chrome.test.callbackFail(
'Only one \'clear\' API call can run at a time.'));
}
]);
{
"name": "chrome.clear API Test: One at a time.",
"version": "0.1",
"manifest_version": 2,
"description": "Checks that chrome.experimental.clear APIs can only be called if one's not already running.",
"background_page": "background.html",
"permissions": [
"experimental",
"clear"
]
}
Markdown is supported
0%
or
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment