| Index: chrome/browser/extensions/api/web_view/chrome_web_view_internal_api.cc
|
| diff --git a/chrome/browser/extensions/api/web_view/chrome_web_view_internal_api.cc b/chrome/browser/extensions/api/web_view/chrome_web_view_internal_api.cc
|
| index a9d755efb04ae58fdca4c61c78f9ea3bbfdf3899..204397d651715f74a6cac3a29e1f5a1a1e61994c 100644
|
| --- a/chrome/browser/extensions/api/web_view/chrome_web_view_internal_api.cc
|
| +++ b/chrome/browser/extensions/api/web_view/chrome_web_view_internal_api.cc
|
| @@ -4,13 +4,10 @@
|
|
|
| #include "chrome/browser/extensions/api/web_view/chrome_web_view_internal_api.h"
|
|
|
| -#include "chrome/browser/extensions/api/browsing_data/browsing_data_api.h"
|
| #include "chrome/browser/extensions/api/context_menus/context_menus_api.h"
|
| #include "chrome/browser/extensions/api/context_menus/context_menus_api_helpers.h"
|
| #include "chrome/browser/profiles/profile.h"
|
| #include "chrome/common/extensions/api/chrome_web_view_internal.h"
|
| -#include "content/public/browser/storage_partition.h"
|
| -#include "content/public/browser/web_contents.h"
|
| #include "extensions/common/error_utils.h"
|
|
|
| namespace helpers = extensions::context_menus_api_helpers;
|
| @@ -18,25 +15,6 @@ namespace webview = extensions::api::chrome_web_view_internal;
|
|
|
| namespace extensions {
|
|
|
| -namespace {
|
| -int MaskForKey(const char* key) {
|
| - if (strcmp(key, extension_browsing_data_api_constants::kAppCacheKey) == 0)
|
| - return content::StoragePartition::REMOVE_DATA_MASK_APPCACHE;
|
| - if (strcmp(key, extension_browsing_data_api_constants::kCookiesKey) == 0)
|
| - return content::StoragePartition::REMOVE_DATA_MASK_COOKIES;
|
| - if (strcmp(key, extension_browsing_data_api_constants::kFileSystemsKey) == 0)
|
| - return content::StoragePartition::REMOVE_DATA_MASK_FILE_SYSTEMS;
|
| - if (strcmp(key, extension_browsing_data_api_constants::kIndexedDBKey) == 0)
|
| - return content::StoragePartition::REMOVE_DATA_MASK_INDEXEDDB;
|
| - if (strcmp(key, extension_browsing_data_api_constants::kLocalStorageKey) == 0)
|
| - return content::StoragePartition::REMOVE_DATA_MASK_LOCAL_STORAGE;
|
| - if (strcmp(key, extension_browsing_data_api_constants::kWebSQLKey) == 0)
|
| - return content::StoragePartition::REMOVE_DATA_MASK_WEBSQL;
|
| - return 0;
|
| -}
|
| -
|
| -} // namespace
|
| -
|
| // TODO(lazyboy): Add checks similar to
|
| // WebViewInternalExtensionFunction::RunAsyncSafe(WebViewGuest*).
|
| bool ChromeWebViewInternalContextMenusCreateFunction::RunAsync() {
|
| @@ -143,92 +121,6 @@ bool ChromeWebViewInternalContextMenusRemoveAllFunction::RunAsync() {
|
| return true;
|
| }
|
|
|
| -ChromeWebViewInternalClearDataFunction::ChromeWebViewInternalClearDataFunction()
|
| - : remove_mask_(0), bad_message_(false) {
|
| -}
|
| -
|
| -ChromeWebViewInternalClearDataFunction::
|
| - ~ChromeWebViewInternalClearDataFunction() {
|
| -}
|
| -
|
| -// Parses the |dataToRemove| argument to generate the remove mask. Sets
|
| -// |bad_message_| (like EXTENSION_FUNCTION_VALIDATE would if this were a bool
|
| -// method) if 'dataToRemove' is not present.
|
| -uint32 ChromeWebViewInternalClearDataFunction::GetRemovalMask() {
|
| - base::DictionaryValue* data_to_remove;
|
| - if (!args_->GetDictionary(2, &data_to_remove)) {
|
| - bad_message_ = true;
|
| - return 0;
|
| - }
|
| -
|
| - uint32 remove_mask = 0;
|
| - for (base::DictionaryValue::Iterator i(*data_to_remove); !i.IsAtEnd();
|
| - i.Advance()) {
|
| - bool selected = false;
|
| - if (!i.value().GetAsBoolean(&selected)) {
|
| - bad_message_ = true;
|
| - return 0;
|
| - }
|
| - if (selected)
|
| - remove_mask |= MaskForKey(i.key().c_str());
|
| - }
|
| -
|
| - return remove_mask;
|
| -}
|
| -
|
| -// TODO(lazyboy): Parameters in this extension function are similar (or a
|
| -// sub-set) to BrowsingDataRemoverFunction. How can we share this code?
|
| -// TODO(lf): Move ClearDataFunction to extensions
|
| -bool ChromeWebViewInternalClearDataFunction::RunAsyncSafe(WebViewGuest* guest) {
|
| - // Grab the initial |options| parameter, and parse out the arguments.
|
| - base::DictionaryValue* options;
|
| - EXTENSION_FUNCTION_VALIDATE(args_->GetDictionary(1, &options));
|
| - DCHECK(options);
|
| -
|
| - // If |ms_since_epoch| isn't set, default it to 0.
|
| - double ms_since_epoch;
|
| - if (!options->GetDouble(extension_browsing_data_api_constants::kSinceKey,
|
| - &ms_since_epoch)) {
|
| - ms_since_epoch = 0;
|
| - }
|
| -
|
| - // 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);
|
| -
|
| - remove_mask_ = GetRemovalMask();
|
| - if (bad_message_)
|
| - return false;
|
| -
|
| - AddRef(); // Balanced below or in WebViewInternalClearDataFunction::Done().
|
| -
|
| - bool scheduled = false;
|
| - if (remove_mask_) {
|
| - scheduled = guest->ClearData(
|
| - remove_since_,
|
| - remove_mask_,
|
| - base::Bind(&ChromeWebViewInternalClearDataFunction::ClearDataDone,
|
| - this));
|
| - }
|
| - if (!remove_mask_ || !scheduled) {
|
| - SendResponse(false);
|
| - Release(); // Balanced above.
|
| - return false;
|
| - }
|
| -
|
| - // Will finish asynchronously.
|
| - return true;
|
| -}
|
| -
|
| -void ChromeWebViewInternalClearDataFunction::ClearDataDone() {
|
| - Release(); // Balanced in RunAsync().
|
| - SendResponse(true);
|
| -}
|
| -
|
| ChromeWebViewInternalShowContextMenuFunction::
|
| ChromeWebViewInternalShowContextMenuFunction() {
|
| }
|
|
|