diff options
author | lazyboy@chromium.org <lazyboy@chromium.org@0039d316-1c4b-4281-b951-d872f2087c98> | 2014-06-25 17:39:11 +0000 |
---|---|---|
committer | lazyboy@chromium.org <lazyboy@chromium.org@0039d316-1c4b-4281-b951-d872f2087c98> | 2014-06-25 17:39:11 +0000 |
commit | 1a895fbc4c5a8b5b763593092d93a2bfed4b7417 (patch) | |
tree | 60b0bce887796cf9d8bad1c6cef3031636055211 /chrome/browser/extensions | |
parent | 38b07d57b9069e3fd44b15bb5883432202ddf78a (diff) | |
download | chromium_src-1a895fbc4c5a8b5b763593092d93a2bfed4b7417.zip chromium_src-1a895fbc4c5a8b5b763593092d93a2bfed4b7417.tar.gz chromium_src-1a895fbc4c5a8b5b763593092d93a2bfed4b7417.tar.bz2 |
Rename webview API related files to web_view_internal.
webview.json -> web_view_internal.json
NOTRY=True
BUG=388380
Test=Internal cleanup, no visible change.
Review URL: https://codereview.chromium.org/347143004
git-svn-id: svn://svn.chromium.org/chrome/trunk/src@279748 0039d316-1c4b-4281-b951-d872f2087c98
Diffstat (limited to 'chrome/browser/extensions')
-rw-r--r-- | chrome/browser/extensions/api/declarative/declarative_api.cc | 16 | ||||
-rw-r--r-- | chrome/browser/extensions/api/web_request/web_request_api.cc | 19 | ||||
-rw-r--r-- | chrome/browser/extensions/api/web_view/OWNERS (renamed from chrome/browser/extensions/api/webview/OWNERS) | 0 | ||||
-rw-r--r-- | chrome/browser/extensions/api/web_view/web_view_internal_api.cc (renamed from chrome/browser/extensions/api/webview/webview_api.cc) | 180 | ||||
-rw-r--r-- | chrome/browser/extensions/api/web_view/web_view_internal_api.h | 443 | ||||
-rw-r--r-- | chrome/browser/extensions/api/webview/webview_api.h | 418 | ||||
-rw-r--r-- | chrome/browser/extensions/menu_manager.cc | 11 |
7 files changed, 565 insertions, 522 deletions
diff --git a/chrome/browser/extensions/api/declarative/declarative_api.cc b/chrome/browser/extensions/api/declarative/declarative_api.cc index f53ead1..9967de4 100644 --- a/chrome/browser/extensions/api/declarative/declarative_api.cc +++ b/chrome/browser/extensions/api/declarative/declarative_api.cc @@ -9,6 +9,7 @@ #include "base/task_runner_util.h" #include "base/values.h" #include "chrome/browser/extensions/api/declarative/rules_registry_service.h" +#include "chrome/browser/guest_view/web_view/web_view_constants.h" #include "chrome/browser/guest_view/web_view/web_view_guest.h" #include "chrome/browser/profiles/profile.h" #include "chrome/common/extensions/api/events.h" @@ -31,20 +32,23 @@ namespace extensions { namespace { const char kWebRequest[] = "declarativeWebRequest."; -const char kWebView[] = "webview."; const char kWebViewExpectedError[] = "Webview event with Webview ID expected."; bool IsWebViewEvent(const std::string& event_name) { // Sample event names: - // webview.onRequest. - // webview.OnMessage. - return event_name.compare(0, strlen(kWebView), kWebView) == 0; + // webViewInternal.onRequest. + // webViewInternal.onMessage. + return event_name.compare(0, + strlen(webview::kWebViewEventPrefix), + webview::kWebViewEventPrefix) == 0; } std::string GetWebRequestEventName(const std::string& event_name) { std::string web_request_event_name(event_name); - if (IsWebViewEvent(web_request_event_name)) - web_request_event_name.replace(0, strlen(kWebView), kWebRequest); + if (IsWebViewEvent(web_request_event_name)) { + web_request_event_name.replace( + 0, strlen(webview::kWebViewEventPrefix), kWebRequest); + } return web_request_event_name; } diff --git a/chrome/browser/extensions/api/web_request/web_request_api.cc b/chrome/browser/extensions/api/web_request/web_request_api.cc index 5560282..4a192bb 100644 --- a/chrome/browser/extensions/api/web_request/web_request_api.cc +++ b/chrome/browser/extensions/api/web_request/web_request_api.cc @@ -92,8 +92,7 @@ namespace activitylog = activity_log_web_request_constants; namespace { -const char kWebRequest[] = "webRequest"; -const char kWebView[] = "webview"; +const char kWebRequestEventPrefix[] = "webRequest."; // List of all the webRequest events. const char* const kWebRequestEvents[] = { @@ -140,8 +139,11 @@ const char* GetRequestStageAsString( bool IsWebRequestEvent(const std::string& event_name) { std::string web_request_event_name(event_name); - if (web_request_event_name.find(kWebView) != std::string::npos) - web_request_event_name.replace(0, sizeof(kWebView) - 1, kWebRequest); + if (StartsWithASCII( + web_request_event_name, webview::kWebViewEventPrefix, true)) { + web_request_event_name.replace( + 0, strlen(webview::kWebViewEventPrefix), kWebRequestEventPrefix); + } return std::find(kWebRequestEvents, ARRAYEND(kWebRequestEvents), web_request_event_name) != ARRAYEND(kWebRequestEvents); } @@ -454,7 +456,8 @@ WebRequestAPI::WebRequestAPI(content::BrowserContext* context) event_router->RegisterObserver(this, event_name); // Also observe the corresponding webview event. - event_name.replace(0, sizeof(kWebRequest) - 1, kWebView); + event_name.replace( + 0, sizeof(kWebRequestEventPrefix) - 1, webview::kWebViewEventPrefix); event_router->RegisterObserver(this, event_name); } } @@ -1466,8 +1469,10 @@ void ExtensionWebRequestEventRouter::GetMatchingListenersImpl( ExtensionRendererState::WebViewInfo web_view_info; bool is_web_view_guest = ExtensionRendererState::GetInstance()-> GetWebViewInfo(render_process_host_id, routing_id, &web_view_info); - if (is_web_view_guest) - web_request_event_name.replace(0, sizeof(kWebRequest) - 1, kWebView); + if (is_web_view_guest) { + web_request_event_name.replace( + 0, sizeof(kWebRequestEventPrefix) - 1, webview::kWebViewEventPrefix); + } std::set<EventListener>& listeners = listeners_[profile][web_request_event_name]; diff --git a/chrome/browser/extensions/api/webview/OWNERS b/chrome/browser/extensions/api/web_view/OWNERS index 057dbdc..057dbdc 100644 --- a/chrome/browser/extensions/api/webview/OWNERS +++ b/chrome/browser/extensions/api/web_view/OWNERS diff --git a/chrome/browser/extensions/api/webview/webview_api.cc b/chrome/browser/extensions/api/web_view/web_view_internal_api.cc index 1f1f626..598c9ff 100644 --- a/chrome/browser/extensions/api/webview/webview_api.cc +++ b/chrome/browser/extensions/api/web_view/web_view_internal_api.cc @@ -1,8 +1,8 @@ -// Copyright (c) 2013 The Chromium Authors. All rights reserved. +// Copyright 2014 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/api/webview/webview_api.h" +#include "chrome/browser/extensions/api/web_view/web_view_internal_api.h" #include "base/strings/utf_string_conversions.h" #include "chrome/browser/extensions/api/browsing_data/browsing_data_api.h" @@ -23,7 +23,7 @@ using content::WebContents; using extensions::api::tabs::InjectDetails; using extensions::api::webview::SetPermission::Params; namespace helpers = extensions::context_menus_api_helpers; -namespace webview = extensions::api::webview; +namespace webview = extensions::api::web_view_internal; namespace extensions { @@ -46,7 +46,7 @@ int MaskForKey(const char* key) { } // namespace -bool WebviewExtensionFunction::RunAsync() { +bool WebViewInternalExtensionFunction::RunAsync() { int instance_id = 0; EXTENSION_FUNCTION_VALIDATE(args_->GetInteger(0, &instance_id)); WebViewGuest* guest = WebViewGuest::From( @@ -58,8 +58,8 @@ bool WebviewExtensionFunction::RunAsync() { } // TODO(lazyboy): Add checks similar to -// WebviewExtensionFunction::RunAsyncSafe(WebViewGuest*). -bool WebviewContextMenusCreateFunction::RunAsync() { +// WebViewInternalExtensionFunction::RunAsyncSafe(WebViewGuest*). +bool WebViewInternalContextMenusCreateFunction::RunAsync() { scoped_ptr<webview::ContextMenusCreate::Params> params( webview::ContextMenusCreate::Params::Create(*args_)); EXTENSION_FUNCTION_VALIDATE(params.get()); @@ -71,7 +71,7 @@ bool WebviewContextMenusCreateFunction::RunAsync() { if (params->create_properties.id.get()) { id.string_uid = *params->create_properties.id; } else { - // The Generated Id is added by webview_custom_bindings.js. + // The Generated Id is added by web_view_internal_custom_bindings.js. base::DictionaryValue* properties = NULL; EXTENSION_FUNCTION_VALIDATE(args_->GetDictionary(1, &properties)); EXTENSION_FUNCTION_VALIDATE( @@ -89,7 +89,7 @@ bool WebviewContextMenusCreateFunction::RunAsync() { return success; } -bool WebviewNavigateFunction::RunAsyncSafe(WebViewGuest* guest) { +bool WebViewInternalNavigateFunction::RunAsyncSafe(WebViewGuest* guest) { scoped_ptr<webview::Navigate::Params> params( webview::Navigate::Params::Create(*args_)); EXTENSION_FUNCTION_VALIDATE(params.get()); @@ -98,7 +98,7 @@ bool WebviewNavigateFunction::RunAsyncSafe(WebViewGuest* guest) { return true; } -bool WebviewContextMenusUpdateFunction::RunAsync() { +bool WebViewInternalContextMenusUpdateFunction::RunAsync() { scoped_ptr<webview::ContextMenusUpdate::Params> params( webview::ContextMenusUpdate::Params::Create(*args_)); EXTENSION_FUNCTION_VALIDATE(params.get()); @@ -121,7 +121,7 @@ bool WebviewContextMenusUpdateFunction::RunAsync() { return success; } -bool WebviewContextMenusRemoveFunction::RunAsync() { +bool WebViewInternalContextMenusRemoveFunction::RunAsync() { scoped_ptr<webview::ContextMenusRemove::Params> params( webview::ContextMenusRemove::Params::Create(*args_)); EXTENSION_FUNCTION_VALIDATE(params.get()); @@ -157,7 +157,7 @@ bool WebviewContextMenusRemoveFunction::RunAsync() { return success; } -bool WebviewContextMenusRemoveAllFunction::RunAsync() { +bool WebViewInternalContextMenusRemoveAllFunction::RunAsync() { scoped_ptr<webview::ContextMenusRemoveAll::Params> params( webview::ContextMenusRemoveAll::Params::Create(*args_)); EXTENSION_FUNCTION_VALIDATE(params.get()); @@ -172,15 +172,17 @@ bool WebviewContextMenusRemoveAllFunction::RunAsync() { return true; } -WebviewClearDataFunction::WebviewClearDataFunction() - : remove_mask_(0), bad_message_(false) {} +WebViewInternalClearDataFunction::WebViewInternalClearDataFunction() + : remove_mask_(0), bad_message_(false) { +} -WebviewClearDataFunction::~WebviewClearDataFunction() {} +WebViewInternalClearDataFunction::~WebViewInternalClearDataFunction() { +} // 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 WebviewClearDataFunction::GetRemovalMask() { +uint32 WebViewInternalClearDataFunction::GetRemovalMask() { base::DictionaryValue* data_to_remove; if (!args_->GetDictionary(2, &data_to_remove)) { bad_message_ = true; @@ -188,8 +190,7 @@ uint32 WebviewClearDataFunction::GetRemovalMask() { } uint32 remove_mask = 0; - for (base::DictionaryValue::Iterator i(*data_to_remove); - !i.IsAtEnd(); + for (base::DictionaryValue::Iterator i(*data_to_remove); !i.IsAtEnd(); i.Advance()) { bool selected = false; if (!i.value().GetAsBoolean(&selected)) { @@ -205,7 +206,7 @@ uint32 WebviewClearDataFunction::GetRemovalMask() { // TODO(lazyboy): Parameters in this extension function are similar (or a // sub-set) to BrowsingDataRemoverFunction. How can we share this code? -bool WebviewClearDataFunction::RunAsyncSafe(WebViewGuest* guest) { +bool WebViewInternalClearDataFunction::RunAsyncSafe(WebViewGuest* guest) { // Grab the initial |options| parameter, and parse out the arguments. base::DictionaryValue* options; EXTENSION_FUNCTION_VALIDATE(args_->GetDictionary(1, &options)); @@ -222,23 +223,22 @@ bool WebviewClearDataFunction::RunAsyncSafe(WebViewGuest* guest) { // 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_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 WebviewClearDataFunction::Done(). + AddRef(); // Balanced below or in WebViewInternalClearDataFunction::Done(). bool scheduled = false; if (remove_mask_) { scheduled = guest->ClearData( remove_since_, remove_mask_, - base::Bind(&WebviewClearDataFunction::ClearDataDone, - this)); + base::Bind(&WebViewInternalClearDataFunction::ClearDataDone, this)); } if (!remove_mask_ || !scheduled) { SendResponse(false); @@ -250,18 +250,19 @@ bool WebviewClearDataFunction::RunAsyncSafe(WebViewGuest* guest) { return true; } -void WebviewClearDataFunction::ClearDataDone() { +void WebViewInternalClearDataFunction::ClearDataDone() { Release(); // Balanced in RunAsync(). SendResponse(true); } -WebviewExecuteCodeFunction::WebviewExecuteCodeFunction() - : guest_instance_id_(0), guest_src_(GURL::EmptyGURL()) {} +WebViewInternalExecuteCodeFunction::WebViewInternalExecuteCodeFunction() + : guest_instance_id_(0), guest_src_(GURL::EmptyGURL()) { +} -WebviewExecuteCodeFunction::~WebviewExecuteCodeFunction() { +WebViewInternalExecuteCodeFunction::~WebViewInternalExecuteCodeFunction() { } -bool WebviewExecuteCodeFunction::Init() { +bool WebViewInternalExecuteCodeFunction::Init() { if (details_.get()) return true; @@ -290,15 +291,16 @@ bool WebviewExecuteCodeFunction::Init() { return true; } -bool WebviewExecuteCodeFunction::ShouldInsertCSS() const { +bool WebViewInternalExecuteCodeFunction::ShouldInsertCSS() const { return false; } -bool WebviewExecuteCodeFunction::CanExecuteScriptOnPage() { +bool WebViewInternalExecuteCodeFunction::CanExecuteScriptOnPage() { return true; } -extensions::ScriptExecutor* WebviewExecuteCodeFunction::GetScriptExecutor() { +extensions::ScriptExecutor* +WebViewInternalExecuteCodeFunction::GetScriptExecutor() { WebViewGuest* guest = WebViewGuest::From( render_view_host()->GetProcess()->GetID(), guest_instance_id_); if (!guest) @@ -307,70 +309,72 @@ extensions::ScriptExecutor* WebviewExecuteCodeFunction::GetScriptExecutor() { return guest->script_executor(); } -bool WebviewExecuteCodeFunction::IsWebView() const { +bool WebViewInternalExecuteCodeFunction::IsWebView() const { return true; } -const GURL& WebviewExecuteCodeFunction::GetWebViewSrc() const { +const GURL& WebViewInternalExecuteCodeFunction::GetWebViewSrc() const { return guest_src_; } -WebviewExecuteScriptFunction::WebviewExecuteScriptFunction() { +WebViewInternalExecuteScriptFunction::WebViewInternalExecuteScriptFunction() { } -void WebviewExecuteScriptFunction::OnExecuteCodeFinished( +void WebViewInternalExecuteScriptFunction::OnExecuteCodeFinished( const std::string& error, int32 on_page_id, const GURL& on_url, const base::ListValue& result) { if (error.empty()) SetResult(result.DeepCopy()); - WebviewExecuteCodeFunction::OnExecuteCodeFinished(error, on_page_id, on_url, - result); + WebViewInternalExecuteCodeFunction::OnExecuteCodeFinished( + error, on_page_id, on_url, result); } -WebviewInsertCSSFunction::WebviewInsertCSSFunction() { +WebViewInternalInsertCSSFunction::WebViewInternalInsertCSSFunction() { } -bool WebviewInsertCSSFunction::ShouldInsertCSS() const { +bool WebViewInternalInsertCSSFunction::ShouldInsertCSS() const { return true; } -WebviewCaptureVisibleRegionFunction::WebviewCaptureVisibleRegionFunction() { +WebViewInternalCaptureVisibleRegionFunction:: + WebViewInternalCaptureVisibleRegionFunction() { } -WebviewCaptureVisibleRegionFunction::~WebviewCaptureVisibleRegionFunction() { +WebViewInternalCaptureVisibleRegionFunction:: + ~WebViewInternalCaptureVisibleRegionFunction() { } -bool WebviewCaptureVisibleRegionFunction::IsScreenshotEnabled() { +bool WebViewInternalCaptureVisibleRegionFunction::IsScreenshotEnabled() { return true; } -WebContents* WebviewCaptureVisibleRegionFunction::GetWebContentsForID( +WebContents* WebViewInternalCaptureVisibleRegionFunction::GetWebContentsForID( int instance_id) { WebViewGuest* guest = WebViewGuest::From( render_view_host()->GetProcess()->GetID(), instance_id); return guest ? guest->guest_web_contents() : NULL; } -void WebviewCaptureVisibleRegionFunction::OnCaptureFailure( +void WebViewInternalCaptureVisibleRegionFunction::OnCaptureFailure( FailureReason reason) { SendResponse(false); } -WebviewSetNameFunction::WebviewSetNameFunction() { +WebViewInternalSetNameFunction::WebViewInternalSetNameFunction() { } -WebviewSetNameFunction::~WebviewSetNameFunction() { +WebViewInternalSetNameFunction::~WebViewInternalSetNameFunction() { } -WebviewSetZoomFunction::WebviewSetZoomFunction() { +WebViewInternalSetZoomFunction::WebViewInternalSetZoomFunction() { } -WebviewSetZoomFunction::~WebviewSetZoomFunction() { +WebViewInternalSetZoomFunction::~WebViewInternalSetZoomFunction() { } -bool WebviewSetNameFunction::RunAsyncSafe(WebViewGuest* guest) { +bool WebViewInternalSetNameFunction::RunAsyncSafe(WebViewGuest* guest) { scoped_ptr<webview::SetName::Params> params( webview::SetName::Params::Create(*args_)); EXTENSION_FUNCTION_VALIDATE(params.get()); @@ -379,7 +383,7 @@ bool WebviewSetNameFunction::RunAsyncSafe(WebViewGuest* guest) { return true; } -bool WebviewSetZoomFunction::RunAsyncSafe(WebViewGuest* guest) { +bool WebViewInternalSetZoomFunction::RunAsyncSafe(WebViewGuest* guest) { scoped_ptr<webview::SetZoom::Params> params( webview::SetZoom::Params::Create(*args_)); EXTENSION_FUNCTION_VALIDATE(params.get()); @@ -389,13 +393,13 @@ bool WebviewSetZoomFunction::RunAsyncSafe(WebViewGuest* guest) { return true; } -WebviewGetZoomFunction::WebviewGetZoomFunction() { +WebViewInternalGetZoomFunction::WebViewInternalGetZoomFunction() { } -WebviewGetZoomFunction::~WebviewGetZoomFunction() { +WebViewInternalGetZoomFunction::~WebViewInternalGetZoomFunction() { } -bool WebviewGetZoomFunction::RunAsyncSafe(WebViewGuest* guest) { +bool WebViewInternalGetZoomFunction::RunAsyncSafe(WebViewGuest* guest) { scoped_ptr<webview::GetZoom::Params> params( webview::GetZoom::Params::Create(*args_)); EXTENSION_FUNCTION_VALIDATE(params.get()); @@ -406,22 +410,21 @@ bool WebviewGetZoomFunction::RunAsyncSafe(WebViewGuest* guest) { return true; } -WebviewFindFunction::WebviewFindFunction() { +WebViewInternalFindFunction::WebViewInternalFindFunction() { } -WebviewFindFunction::~WebviewFindFunction() { +WebViewInternalFindFunction::~WebViewInternalFindFunction() { } -bool WebviewFindFunction::RunAsyncSafe(WebViewGuest* guest) { +bool WebViewInternalFindFunction::RunAsyncSafe(WebViewGuest* guest) { scoped_ptr<webview::Find::Params> params( webview::Find::Params::Create(*args_)); EXTENSION_FUNCTION_VALIDATE(params.get()); // Convert the std::string search_text to string16. base::string16 search_text; - base::UTF8ToUTF16(params->search_text.c_str(), - params->search_text.length(), - &search_text); + base::UTF8ToUTF16( + params->search_text.c_str(), params->search_text.length(), &search_text); // Set the find options to their default values. blink::WebFindOptions options; @@ -436,13 +439,13 @@ bool WebviewFindFunction::RunAsyncSafe(WebViewGuest* guest) { return true; } -WebviewStopFindingFunction::WebviewStopFindingFunction() { +WebViewInternalStopFindingFunction::WebViewInternalStopFindingFunction() { } -WebviewStopFindingFunction::~WebviewStopFindingFunction() { +WebViewInternalStopFindingFunction::~WebViewInternalStopFindingFunction() { } -bool WebviewStopFindingFunction::RunAsyncSafe(WebViewGuest* guest) { +bool WebViewInternalStopFindingFunction::RunAsyncSafe(WebViewGuest* guest) { scoped_ptr<webview::StopFinding::Params> params( webview::StopFinding::Params::Create(*args_)); EXTENSION_FUNCTION_VALIDATE(params.get()); @@ -467,13 +470,13 @@ bool WebviewStopFindingFunction::RunAsyncSafe(WebViewGuest* guest) { return true; } -WebviewGoFunction::WebviewGoFunction() { +WebViewInternalGoFunction::WebViewInternalGoFunction() { } -WebviewGoFunction::~WebviewGoFunction() { +WebViewInternalGoFunction::~WebViewInternalGoFunction() { } -bool WebviewGoFunction::RunAsyncSafe(WebViewGuest* guest) { +bool WebViewInternalGoFunction::RunAsyncSafe(WebViewGuest* guest) { scoped_ptr<webview::Go::Params> params(webview::Go::Params::Create(*args_)); EXTENSION_FUNCTION_VALIDATE(params.get()); @@ -481,24 +484,24 @@ bool WebviewGoFunction::RunAsyncSafe(WebViewGuest* guest) { return true; } -WebviewReloadFunction::WebviewReloadFunction() { +WebViewInternalReloadFunction::WebViewInternalReloadFunction() { } -WebviewReloadFunction::~WebviewReloadFunction() { +WebViewInternalReloadFunction::~WebViewInternalReloadFunction() { } -bool WebviewReloadFunction::RunAsyncSafe(WebViewGuest* guest) { +bool WebViewInternalReloadFunction::RunAsyncSafe(WebViewGuest* guest) { guest->Reload(); return true; } -WebviewSetPermissionFunction::WebviewSetPermissionFunction() { +WebViewInternalSetPermissionFunction::WebViewInternalSetPermissionFunction() { } -WebviewSetPermissionFunction::~WebviewSetPermissionFunction() { +WebViewInternalSetPermissionFunction::~WebViewInternalSetPermissionFunction() { } -bool WebviewSetPermissionFunction::RunAsyncSafe(WebViewGuest* guest) { +bool WebViewInternalSetPermissionFunction::RunAsyncSafe(WebViewGuest* guest) { scoped_ptr<webview::SetPermission::Params> params( webview::SetPermission::Params::Create(*args_)); EXTENSION_FUNCTION_VALIDATE(params.get()); @@ -532,13 +535,15 @@ bool WebviewSetPermissionFunction::RunAsyncSafe(WebViewGuest* guest) { return true; } -WebviewShowContextMenuFunction::WebviewShowContextMenuFunction() { +WebViewInternalShowContextMenuFunction:: + WebViewInternalShowContextMenuFunction() { } -WebviewShowContextMenuFunction::~WebviewShowContextMenuFunction() { +WebViewInternalShowContextMenuFunction:: + ~WebViewInternalShowContextMenuFunction() { } -bool WebviewShowContextMenuFunction::RunAsyncSafe(WebViewGuest* guest) { +bool WebViewInternalShowContextMenuFunction::RunAsyncSafe(WebViewGuest* guest) { scoped_ptr<webview::ShowContextMenu::Params> params( webview::ShowContextMenu::Params::Create(*args_)); EXTENSION_FUNCTION_VALIDATE(params.get()); @@ -551,39 +556,42 @@ bool WebviewShowContextMenuFunction::RunAsyncSafe(WebViewGuest* guest) { return true; } -WebviewOverrideUserAgentFunction::WebviewOverrideUserAgentFunction() { +WebViewInternalOverrideUserAgentFunction:: + WebViewInternalOverrideUserAgentFunction() { } -WebviewOverrideUserAgentFunction::~WebviewOverrideUserAgentFunction() { +WebViewInternalOverrideUserAgentFunction:: + ~WebViewInternalOverrideUserAgentFunction() { } -bool WebviewOverrideUserAgentFunction::RunAsyncSafe(WebViewGuest* guest) { - scoped_ptr<extensions::api::webview::OverrideUserAgent::Params> params( - extensions::api::webview::OverrideUserAgent::Params::Create(*args_)); +bool WebViewInternalOverrideUserAgentFunction::RunAsyncSafe( + WebViewGuest* guest) { + scoped_ptr<webview::OverrideUserAgent::Params> params( + webview::OverrideUserAgent::Params::Create(*args_)); EXTENSION_FUNCTION_VALIDATE(params.get()); guest->SetUserAgentOverride(params->user_agent_override); return true; } -WebviewStopFunction::WebviewStopFunction() { +WebViewInternalStopFunction::WebViewInternalStopFunction() { } -WebviewStopFunction::~WebviewStopFunction() { +WebViewInternalStopFunction::~WebViewInternalStopFunction() { } -bool WebviewStopFunction::RunAsyncSafe(WebViewGuest* guest) { +bool WebViewInternalStopFunction::RunAsyncSafe(WebViewGuest* guest) { guest->Stop(); return true; } -WebviewTerminateFunction::WebviewTerminateFunction() { +WebViewInternalTerminateFunction::WebViewInternalTerminateFunction() { } -WebviewTerminateFunction::~WebviewTerminateFunction() { +WebViewInternalTerminateFunction::~WebViewInternalTerminateFunction() { } -bool WebviewTerminateFunction::RunAsyncSafe(WebViewGuest* guest) { +bool WebViewInternalTerminateFunction::RunAsyncSafe(WebViewGuest* guest) { guest->Terminate(); return true; } diff --git a/chrome/browser/extensions/api/web_view/web_view_internal_api.h b/chrome/browser/extensions/api/web_view/web_view_internal_api.h new file mode 100644 index 0000000..3ccf27d --- /dev/null +++ b/chrome/browser/extensions/api/web_view/web_view_internal_api.h @@ -0,0 +1,443 @@ +// Copyright 2014 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. + +#ifndef CHROME_BROWSER_EXTENSIONS_API_WEBVIEW_WEB_VIEW_INTERNRAL_API_H_ +#define CHROME_BROWSER_EXTENSIONS_API_WEBVIEW_WEB_VIEW_INTERNRAL_API_H_ + +#include "chrome/browser/extensions/api/capture_web_contents_function.h" +#include "chrome/browser/extensions/api/execute_code_function.h" +#include "chrome/browser/guest_view/web_view/web_view_find_helper.h" +#include "chrome/browser/guest_view/web_view/web_view_guest.h" + +// WARNING: WebViewInternal could be loaded in an unblessed context, thus any +// new APIs must extend WebViewInternalExtensionFunction or +// WebViewInternalExecuteCodeFunction which do a process ID check to prevent +// abuse by normal renderer processes. +// TODO(guohui): refactor WebViewInternalExecuteCodeFunction to also extend +// WebViewInternalExtensionFunction. +namespace extensions { + +// An abstract base class for async webview APIs. It does a process ID check +// in RunAsync, and then calls RunAsyncSafe which must be overriden by all +// subclasses. +class WebViewInternalExtensionFunction : public AsyncExtensionFunction { + public: + WebViewInternalExtensionFunction() {} + + protected: + virtual ~WebViewInternalExtensionFunction() {} + + // ExtensionFunction implementation. + virtual bool RunAsync() OVERRIDE FINAL; + + private: + virtual bool RunAsyncSafe(WebViewGuest* guest) = 0; +}; + +class WebViewInternalContextMenusCreateFunction + : public AsyncExtensionFunction { + public: + DECLARE_EXTENSION_FUNCTION("webViewInternal.contextMenusCreate", + WEBVIEWINTERNAL_CONTEXTMENUSCREATE); + WebViewInternalContextMenusCreateFunction() {} + + protected: + virtual ~WebViewInternalContextMenusCreateFunction() {} + + // ExtensionFunction implementation. + virtual bool RunAsync() OVERRIDE; + + private: + DISALLOW_COPY_AND_ASSIGN(WebViewInternalContextMenusCreateFunction); +}; + +class WebViewInternalContextMenusUpdateFunction + : public AsyncExtensionFunction { + public: + DECLARE_EXTENSION_FUNCTION("webViewInternal.contextMenusUpdate", + WEBVIEWINTERNAL_CONTEXTMENUSUPDATE); + WebViewInternalContextMenusUpdateFunction() {} + + protected: + virtual ~WebViewInternalContextMenusUpdateFunction() {} + + // ExtensionFunction implementation. + virtual bool RunAsync() OVERRIDE; + + private: + DISALLOW_COPY_AND_ASSIGN(WebViewInternalContextMenusUpdateFunction); +}; + +class WebViewInternalContextMenusRemoveFunction + : public AsyncExtensionFunction { + public: + DECLARE_EXTENSION_FUNCTION("webViewInternal.contextMenusRemove", + WEBVIEWINTERNAL_CONTEXTMENUSREMOVE); + WebViewInternalContextMenusRemoveFunction() {} + + protected: + virtual ~WebViewInternalContextMenusRemoveFunction() {} + + // ExtensionFunction implementation. + virtual bool RunAsync() OVERRIDE; + + private: + DISALLOW_COPY_AND_ASSIGN(WebViewInternalContextMenusRemoveFunction); +}; + +class WebViewInternalContextMenusRemoveAllFunction + : public AsyncExtensionFunction { + public: + DECLARE_EXTENSION_FUNCTION("webViewInternal.contextMenusRemoveAll", + WEBVIEWINTERNAL_CONTEXTMENUSREMOVEALL); + WebViewInternalContextMenusRemoveAllFunction() {} + + protected: + virtual ~WebViewInternalContextMenusRemoveAllFunction() {} + + // ExtensionFunction implementation. + virtual bool RunAsync() OVERRIDE; + + private: + DISALLOW_COPY_AND_ASSIGN(WebViewInternalContextMenusRemoveAllFunction); +}; + +class WebViewInternalNavigateFunction + : public WebViewInternalExtensionFunction { + public: + DECLARE_EXTENSION_FUNCTION("webViewInternal.navigate", + WEBVIEWINTERNAL_NAVIGATE); + WebViewInternalNavigateFunction() {} + + protected: + virtual ~WebViewInternalNavigateFunction() {} + + private: + // WebViewInternalExtensionFunction implementation. + virtual bool RunAsyncSafe(WebViewGuest* guest) OVERRIDE; + + DISALLOW_COPY_AND_ASSIGN(WebViewInternalNavigateFunction); +}; + +class WebViewInternalClearDataFunction + : public WebViewInternalExtensionFunction { + public: + DECLARE_EXTENSION_FUNCTION("webViewInternal.clearData", + WEBVIEWINTERNAL_CLEARDATA); + + WebViewInternalClearDataFunction(); + + protected: + virtual ~WebViewInternalClearDataFunction(); + + private: + // WebViewInternalExtensionFunction implementation. + virtual bool RunAsyncSafe(WebViewGuest* guest) OVERRIDE; + + uint32 GetRemovalMask(); + void ClearDataDone(); + + // Removal start time. + base::Time remove_since_; + // Removal mask, corresponds to StoragePartition::RemoveDataMask enum. + uint32 remove_mask_; + // Tracks any data related or parse errors. + bool bad_message_; + + DISALLOW_COPY_AND_ASSIGN(WebViewInternalClearDataFunction); +}; + +class WebViewInternalExecuteCodeFunction + : public extensions::ExecuteCodeFunction { + public: + WebViewInternalExecuteCodeFunction(); + + protected: + virtual ~WebViewInternalExecuteCodeFunction(); + + // Initialize |details_| if it hasn't already been. + virtual bool Init() OVERRIDE; + virtual bool ShouldInsertCSS() const OVERRIDE; + virtual bool CanExecuteScriptOnPage() OVERRIDE; + // Guarded by a process ID check. + virtual extensions::ScriptExecutor* GetScriptExecutor() OVERRIDE FINAL; + virtual bool IsWebView() const OVERRIDE; + virtual const GURL& GetWebViewSrc() const OVERRIDE; + + private: + // Contains extension resource built from path of file which is + // specified in JSON arguments. + extensions::ExtensionResource resource_; + + int guest_instance_id_; + + GURL guest_src_; + + DISALLOW_COPY_AND_ASSIGN(WebViewInternalExecuteCodeFunction); +}; + +class WebViewInternalExecuteScriptFunction + : public WebViewInternalExecuteCodeFunction { + public: + WebViewInternalExecuteScriptFunction(); + + protected: + virtual ~WebViewInternalExecuteScriptFunction() {} + + virtual void OnExecuteCodeFinished(const std::string& error, + int32 on_page_id, + const GURL& on_url, + const base::ListValue& result) OVERRIDE; + + DECLARE_EXTENSION_FUNCTION("webViewInternal.executeScript", + WEBVIEWINTERNAL_EXECUTESCRIPT) + + private: + DISALLOW_COPY_AND_ASSIGN(WebViewInternalExecuteScriptFunction); +}; + +class WebViewInternalInsertCSSFunction + : public WebViewInternalExecuteCodeFunction { + public: + WebViewInternalInsertCSSFunction(); + + protected: + virtual ~WebViewInternalInsertCSSFunction() {} + + virtual bool ShouldInsertCSS() const OVERRIDE; + + DECLARE_EXTENSION_FUNCTION("webViewInternal.insertCSS", + WEBVIEWINTERNAL_INSERTCSS) + + private: + DISALLOW_COPY_AND_ASSIGN(WebViewInternalInsertCSSFunction); +}; + +class WebViewInternalCaptureVisibleRegionFunction + : public extensions::CaptureWebContentsFunction { + DECLARE_EXTENSION_FUNCTION("webViewInternal.captureVisibleRegion", + WEBVIEWINTERNAL_CAPTUREVISIBLEREGION); + + WebViewInternalCaptureVisibleRegionFunction(); + + protected: + virtual ~WebViewInternalCaptureVisibleRegionFunction(); + + private: + // extensions::CaptureWebContentsFunction implementation. + virtual bool IsScreenshotEnabled() OVERRIDE; + virtual content::WebContents* GetWebContentsForID(int id) OVERRIDE; + virtual void OnCaptureFailure(FailureReason reason) OVERRIDE; + + DISALLOW_COPY_AND_ASSIGN(WebViewInternalCaptureVisibleRegionFunction); +}; + +class WebViewInternalSetNameFunction : public WebViewInternalExtensionFunction { + public: + DECLARE_EXTENSION_FUNCTION("webViewInternal.setName", + WEBVIEWINTERNAL_SETNAME); + + WebViewInternalSetNameFunction(); + + protected: + virtual ~WebViewInternalSetNameFunction(); + + private: + virtual bool RunAsyncSafe(WebViewGuest* guest) OVERRIDE; + + DISALLOW_COPY_AND_ASSIGN(WebViewInternalSetNameFunction); +}; + +class WebViewInternalSetZoomFunction : public WebViewInternalExtensionFunction { + public: + DECLARE_EXTENSION_FUNCTION("webViewInternal.setZoom", + WEBVIEWINTERNAL_SETZOOM); + + WebViewInternalSetZoomFunction(); + + protected: + virtual ~WebViewInternalSetZoomFunction(); + + private: + virtual bool RunAsyncSafe(WebViewGuest* guest) OVERRIDE; + + DISALLOW_COPY_AND_ASSIGN(WebViewInternalSetZoomFunction); +}; + +class WebViewInternalGetZoomFunction : public WebViewInternalExtensionFunction { + public: + DECLARE_EXTENSION_FUNCTION("webViewInternal.getZoom", + WEBVIEWINTERNAL_GETZOOM); + + WebViewInternalGetZoomFunction(); + + protected: + virtual ~WebViewInternalGetZoomFunction(); + + private: + virtual bool RunAsyncSafe(WebViewGuest* guest) OVERRIDE; + + DISALLOW_COPY_AND_ASSIGN(WebViewInternalGetZoomFunction); +}; + +class WebViewInternalFindFunction : public WebViewInternalExtensionFunction { + public: + DECLARE_EXTENSION_FUNCTION("webViewInternal.find", WEBVIEWINTERNAL_FIND); + + WebViewInternalFindFunction(); + + // Exposes SendResponse() for use by WebViewInternalFindHelper. + using WebViewInternalExtensionFunction::SendResponse; + + protected: + virtual ~WebViewInternalFindFunction(); + + private: + // WebViewInternalExtensionFunction implementation. + virtual bool RunAsyncSafe(WebViewGuest* guest) OVERRIDE; + + DISALLOW_COPY_AND_ASSIGN(WebViewInternalFindFunction); +}; + +class WebViewInternalStopFindingFunction + : public WebViewInternalExtensionFunction { + public: + DECLARE_EXTENSION_FUNCTION("webViewInternal.stopFinding", + WEBVIEWINTERNAL_STOPFINDING); + + WebViewInternalStopFindingFunction(); + + protected: + virtual ~WebViewInternalStopFindingFunction(); + + private: + // WebViewInternalExtensionFunction implementation. + virtual bool RunAsyncSafe(WebViewGuest* guest) OVERRIDE; + + DISALLOW_COPY_AND_ASSIGN(WebViewInternalStopFindingFunction); +}; + +class WebViewInternalGoFunction : public WebViewInternalExtensionFunction { + public: + DECLARE_EXTENSION_FUNCTION("webViewInternal.go", WEBVIEWINTERNAL_GO); + + WebViewInternalGoFunction(); + + protected: + virtual ~WebViewInternalGoFunction(); + + private: + // WebViewInternalExtensionFunction implementation. + virtual bool RunAsyncSafe(WebViewGuest* guest) OVERRIDE; + + DISALLOW_COPY_AND_ASSIGN(WebViewInternalGoFunction); +}; + +class WebViewInternalReloadFunction : public WebViewInternalExtensionFunction { + public: + DECLARE_EXTENSION_FUNCTION("webViewInternal.reload", WEBVIEWINTERNAL_RELOAD); + + WebViewInternalReloadFunction(); + + protected: + virtual ~WebViewInternalReloadFunction(); + + private: + // WebViewInternalExtensionFunction implementation. + virtual bool RunAsyncSafe(WebViewGuest* guest) OVERRIDE; + + DISALLOW_COPY_AND_ASSIGN(WebViewInternalReloadFunction); +}; + +class WebViewInternalSetPermissionFunction + : public WebViewInternalExtensionFunction { + public: + DECLARE_EXTENSION_FUNCTION("webViewInternal.setPermission", + WEBVIEWINTERNAL_SETPERMISSION); + + WebViewInternalSetPermissionFunction(); + + protected: + virtual ~WebViewInternalSetPermissionFunction(); + + private: + // WebViewInternalExtensionFunction implementation. + virtual bool RunAsyncSafe(WebViewGuest* guest) OVERRIDE; + + DISALLOW_COPY_AND_ASSIGN(WebViewInternalSetPermissionFunction); +}; + +class WebViewInternalShowContextMenuFunction + : public WebViewInternalExtensionFunction { + public: + DECLARE_EXTENSION_FUNCTION("webViewInternal.showContextMenu", + WEBVIEWINTERNAL_SHOWCONTEXTMENU); + + WebViewInternalShowContextMenuFunction(); + + protected: + virtual ~WebViewInternalShowContextMenuFunction(); + + private: + // WebViewInternalExtensionFunction implementation. + virtual bool RunAsyncSafe(WebViewGuest* guest) OVERRIDE; + + DISALLOW_COPY_AND_ASSIGN(WebViewInternalShowContextMenuFunction); +}; + +class WebViewInternalOverrideUserAgentFunction + : public WebViewInternalExtensionFunction { + public: + DECLARE_EXTENSION_FUNCTION("webViewInternal.overrideUserAgent", + WEBVIEWINTERNAL_OVERRIDEUSERAGENT); + + WebViewInternalOverrideUserAgentFunction(); + + protected: + virtual ~WebViewInternalOverrideUserAgentFunction(); + + private: + // WebViewInternalExtensionFunction implementation. + virtual bool RunAsyncSafe(WebViewGuest* guest) OVERRIDE; + + DISALLOW_COPY_AND_ASSIGN(WebViewInternalOverrideUserAgentFunction); +}; + +class WebViewInternalStopFunction : public WebViewInternalExtensionFunction { + public: + DECLARE_EXTENSION_FUNCTION("webViewInternal.stop", WEBVIEWINTERNAL_STOP); + + WebViewInternalStopFunction(); + + protected: + virtual ~WebViewInternalStopFunction(); + + private: + // WebViewInternalExtensionFunction implementation. + virtual bool RunAsyncSafe(WebViewGuest* guest) OVERRIDE; + + DISALLOW_COPY_AND_ASSIGN(WebViewInternalStopFunction); +}; + +class WebViewInternalTerminateFunction + : public WebViewInternalExtensionFunction { + public: + DECLARE_EXTENSION_FUNCTION("webViewInternal.terminate", + WEBVIEWINTERNAL_TERMINATE); + + WebViewInternalTerminateFunction(); + + protected: + virtual ~WebViewInternalTerminateFunction(); + + private: + // WebViewInternalExtensionFunction implementation. + virtual bool RunAsyncSafe(WebViewGuest* guest) OVERRIDE; + + DISALLOW_COPY_AND_ASSIGN(WebViewInternalTerminateFunction); +}; + +} // namespace extensions + +#endif // CHROME_BROWSER_EXTENSIONS_API_WEBVIEW_WEB_VIEW_INTERNRAL_API_H_ diff --git a/chrome/browser/extensions/api/webview/webview_api.h b/chrome/browser/extensions/api/webview/webview_api.h deleted file mode 100644 index dfd6d72..0000000 --- a/chrome/browser/extensions/api/webview/webview_api.h +++ /dev/null @@ -1,418 +0,0 @@ -// Copyright (c) 2013 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. - -#ifndef CHROME_BROWSER_EXTENSIONS_API_WEBVIEW_WEBVIEW_API_H_ -#define CHROME_BROWSER_EXTENSIONS_API_WEBVIEW_WEBVIEW_API_H_ - -#include "chrome/browser/extensions/api/capture_web_contents_function.h" -#include "chrome/browser/extensions/api/execute_code_function.h" -#include "chrome/browser/guest_view/web_view/web_view_find_helper.h" -#include "chrome/browser/guest_view/web_view/web_view_guest.h" - -// WARNING: Webview could be loaded in an unblessed context, thus any new -// APIs must extend WebviewExtensionFunction/WebviewExecuteCodeFunction which -// do a process ID check to prevent abuse by normal renderer processes. -// TODO(guohui): refactor WebviewExecuteCodeFunction to also extend -// WebviewExtensionFunction. -namespace extensions { - -// An abstract base class for async webview APIs. It does a process ID check -// in RunAsync, and then calls RunAsyncSafe which must be overriden by all -// subclasses. -class WebviewExtensionFunction : public AsyncExtensionFunction { - public: - WebviewExtensionFunction() {} - - protected: - virtual ~WebviewExtensionFunction() {} - - // ExtensionFunction implementation. - virtual bool RunAsync() OVERRIDE FINAL; - - private: - virtual bool RunAsyncSafe(WebViewGuest* guest) = 0; -}; - -class WebviewContextMenusCreateFunction : public AsyncExtensionFunction { - public: - DECLARE_EXTENSION_FUNCTION("webview.contextMenusCreate", - WEBVIEW_CONTEXTMENUSCREATE); - WebviewContextMenusCreateFunction() {} - - protected: - virtual ~WebviewContextMenusCreateFunction() {} - - // ExtensionFunction implementation. - virtual bool RunAsync() OVERRIDE; - - private: - DISALLOW_COPY_AND_ASSIGN(WebviewContextMenusCreateFunction); -}; - -class WebviewContextMenusUpdateFunction : public AsyncExtensionFunction { - public: - DECLARE_EXTENSION_FUNCTION("webview.contextMenusUpdate", - WEBVIEW_CONTEXTMENUSUPDATE); - WebviewContextMenusUpdateFunction() {} - - protected: - virtual ~WebviewContextMenusUpdateFunction() {} - - // ExtensionFunction implementation. - virtual bool RunAsync() OVERRIDE; - - private: - DISALLOW_COPY_AND_ASSIGN(WebviewContextMenusUpdateFunction); -}; - -class WebviewContextMenusRemoveFunction : public AsyncExtensionFunction { - public: - DECLARE_EXTENSION_FUNCTION("webview.contextMenusRemove", - WEBVIEW_CONTEXTMENUSREMOVE); - WebviewContextMenusRemoveFunction() {} - - protected: - virtual ~WebviewContextMenusRemoveFunction() {} - - // ExtensionFunction implementation. - virtual bool RunAsync() OVERRIDE; - - private: - DISALLOW_COPY_AND_ASSIGN(WebviewContextMenusRemoveFunction); -}; - -class WebviewContextMenusRemoveAllFunction : public AsyncExtensionFunction { - public: - DECLARE_EXTENSION_FUNCTION("webview.contextMenusRemoveAll", - WEBVIEW_CONTEXTMENUSREMOVEALL); - WebviewContextMenusRemoveAllFunction() {} - - protected: - virtual ~WebviewContextMenusRemoveAllFunction() {} - - // ExtensionFunction implementation. - virtual bool RunAsync() OVERRIDE; - - private: - DISALLOW_COPY_AND_ASSIGN(WebviewContextMenusRemoveAllFunction); -}; - -class WebviewNavigateFunction : public WebviewExtensionFunction { - public: - DECLARE_EXTENSION_FUNCTION("webview.navigate", WEBVIEW_NAVIGATE); - WebviewNavigateFunction() {} - - protected: - virtual ~WebviewNavigateFunction() {} - - private: - // WebviewExtensionFunction implementation. - virtual bool RunAsyncSafe(WebViewGuest* guest) OVERRIDE; - - DISALLOW_COPY_AND_ASSIGN(WebviewNavigateFunction); -}; - -class WebviewClearDataFunction : public WebviewExtensionFunction { - public: - DECLARE_EXTENSION_FUNCTION("webview.clearData", WEBVIEW_CLEARDATA); - - WebviewClearDataFunction(); - - protected: - virtual ~WebviewClearDataFunction(); - - private: - // WebviewExtensionFunction implementation. - virtual bool RunAsyncSafe(WebViewGuest* guest) OVERRIDE; - - uint32 GetRemovalMask(); - void ClearDataDone(); - - // Removal start time. - base::Time remove_since_; - // Removal mask, corresponds to StoragePartition::RemoveDataMask enum. - uint32 remove_mask_; - // Tracks any data related or parse errors. - bool bad_message_; - - DISALLOW_COPY_AND_ASSIGN(WebviewClearDataFunction); -}; - -class WebviewExecuteCodeFunction : public extensions::ExecuteCodeFunction { - public: - WebviewExecuteCodeFunction(); - - protected: - virtual ~WebviewExecuteCodeFunction(); - - // Initialize |details_| if it hasn't already been. - virtual bool Init() OVERRIDE; - virtual bool ShouldInsertCSS() const OVERRIDE; - virtual bool CanExecuteScriptOnPage() OVERRIDE; - // Guarded by a process ID check. - virtual extensions::ScriptExecutor* GetScriptExecutor() OVERRIDE FINAL; - virtual bool IsWebView() const OVERRIDE; - virtual const GURL& GetWebViewSrc() const OVERRIDE; - - private: - // Contains extension resource built from path of file which is - // specified in JSON arguments. - extensions::ExtensionResource resource_; - - int guest_instance_id_; - - GURL guest_src_; - - DISALLOW_COPY_AND_ASSIGN(WebviewExecuteCodeFunction); -}; - -class WebviewExecuteScriptFunction : public WebviewExecuteCodeFunction { - public: - WebviewExecuteScriptFunction(); - - protected: - virtual ~WebviewExecuteScriptFunction() {} - - virtual void OnExecuteCodeFinished(const std::string& error, - int32 on_page_id, - const GURL& on_url, - const base::ListValue& result) OVERRIDE; - - DECLARE_EXTENSION_FUNCTION("webview.executeScript", WEBVIEW_EXECUTESCRIPT) - - private: - DISALLOW_COPY_AND_ASSIGN(WebviewExecuteScriptFunction); -}; - -class WebviewInsertCSSFunction : public WebviewExecuteCodeFunction { - public: - WebviewInsertCSSFunction(); - - protected: - virtual ~WebviewInsertCSSFunction() {} - - virtual bool ShouldInsertCSS() const OVERRIDE; - - DECLARE_EXTENSION_FUNCTION("webview.insertCSS", WEBVIEW_INSERTCSS) - - private: - DISALLOW_COPY_AND_ASSIGN(WebviewInsertCSSFunction); -}; - -class WebviewCaptureVisibleRegionFunction - : public extensions::CaptureWebContentsFunction { - DECLARE_EXTENSION_FUNCTION("webview.captureVisibleRegion", - WEBVIEW_CAPTUREVISIBLEREGION); - - WebviewCaptureVisibleRegionFunction(); - - protected: - virtual ~WebviewCaptureVisibleRegionFunction(); - - private: - // extensions::CaptureWebContentsFunction implementation. - virtual bool IsScreenshotEnabled() OVERRIDE; - virtual content::WebContents* GetWebContentsForID(int id) OVERRIDE; - virtual void OnCaptureFailure(FailureReason reason) OVERRIDE; - - DISALLOW_COPY_AND_ASSIGN(WebviewCaptureVisibleRegionFunction); -}; - -class WebviewSetNameFunction : public WebviewExtensionFunction { - public: - DECLARE_EXTENSION_FUNCTION("webview.setName", WEBVIEW_SETNAME); - - WebviewSetNameFunction(); - - protected: - virtual ~WebviewSetNameFunction(); - - private: - virtual bool RunAsyncSafe(WebViewGuest* guest) OVERRIDE; - - DISALLOW_COPY_AND_ASSIGN(WebviewSetNameFunction); -}; - -class WebviewSetZoomFunction : public WebviewExtensionFunction { - public: - DECLARE_EXTENSION_FUNCTION("webview.setZoom", WEBVIEW_SETZOOM); - - WebviewSetZoomFunction(); - - protected: - virtual ~WebviewSetZoomFunction(); - - private: - virtual bool RunAsyncSafe(WebViewGuest* guest) OVERRIDE; - - DISALLOW_COPY_AND_ASSIGN(WebviewSetZoomFunction); -}; - -class WebviewGetZoomFunction : public WebviewExtensionFunction { - public: - DECLARE_EXTENSION_FUNCTION("webview.getZoom", WEBVIEW_GETZOOM); - - WebviewGetZoomFunction(); - - protected: - virtual ~WebviewGetZoomFunction(); - - private: - virtual bool RunAsyncSafe(WebViewGuest* guest) OVERRIDE; - - DISALLOW_COPY_AND_ASSIGN(WebviewGetZoomFunction); -}; - -class WebviewFindFunction : public WebviewExtensionFunction { - public: - DECLARE_EXTENSION_FUNCTION("webview.find", WEBVIEW_FIND); - - WebviewFindFunction(); - - // Exposes SendResponse() for use by WebviewFindHelper. - using WebviewExtensionFunction::SendResponse; - - protected: - virtual ~WebviewFindFunction(); - - private: - // WebviewExtensionFunction implementation. - virtual bool RunAsyncSafe(WebViewGuest* guest) OVERRIDE; - - DISALLOW_COPY_AND_ASSIGN(WebviewFindFunction); -}; - -class WebviewStopFindingFunction : public WebviewExtensionFunction { - public: - DECLARE_EXTENSION_FUNCTION("webview.stopFinding", WEBVIEW_STOPFINDING); - - WebviewStopFindingFunction(); - - protected: - virtual ~WebviewStopFindingFunction(); - - private: - // WebviewExtensionFunction implementation. - virtual bool RunAsyncSafe(WebViewGuest* guest) OVERRIDE; - - DISALLOW_COPY_AND_ASSIGN(WebviewStopFindingFunction); -}; - -class WebviewGoFunction : public WebviewExtensionFunction { - public: - DECLARE_EXTENSION_FUNCTION("webview.go", WEBVIEW_GO); - - WebviewGoFunction(); - - protected: - virtual ~WebviewGoFunction(); - - private: - // WebviewExtensionFunction implementation. - virtual bool RunAsyncSafe(WebViewGuest* guest) OVERRIDE; - - DISALLOW_COPY_AND_ASSIGN(WebviewGoFunction); -}; - -class WebviewReloadFunction : public WebviewExtensionFunction { - public: - DECLARE_EXTENSION_FUNCTION("webview.reload", WEBVIEW_RELOAD); - - WebviewReloadFunction(); - - protected: - virtual ~WebviewReloadFunction(); - - private: - // WebviewExtensionFunction implementation. - virtual bool RunAsyncSafe(WebViewGuest* guest) OVERRIDE; - - DISALLOW_COPY_AND_ASSIGN(WebviewReloadFunction); -}; - -class WebviewSetPermissionFunction : public WebviewExtensionFunction { - public: - DECLARE_EXTENSION_FUNCTION("webview.setPermission", WEBVIEW_SETPERMISSION); - - WebviewSetPermissionFunction(); - - protected: - virtual ~WebviewSetPermissionFunction(); - - private: - // WebviewExtensionFunction implementation. - virtual bool RunAsyncSafe(WebViewGuest* guest) OVERRIDE; - - DISALLOW_COPY_AND_ASSIGN(WebviewSetPermissionFunction); -}; - -class WebviewShowContextMenuFunction : public WebviewExtensionFunction { - public: - DECLARE_EXTENSION_FUNCTION("webview.showContextMenu", - WEBVIEW_SHOWCONTEXTMENU); - - WebviewShowContextMenuFunction(); - - protected: - virtual ~WebviewShowContextMenuFunction(); - - private: - // WebviewExtensionFunction implementation. - virtual bool RunAsyncSafe(WebViewGuest* guest) OVERRIDE; - - DISALLOW_COPY_AND_ASSIGN(WebviewShowContextMenuFunction); -}; - -class WebviewOverrideUserAgentFunction: public WebviewExtensionFunction { - public: - DECLARE_EXTENSION_FUNCTION("webview.overrideUserAgent", - WEBVIEW_OVERRIDEUSERAGENT); - - WebviewOverrideUserAgentFunction(); - - protected: - virtual ~WebviewOverrideUserAgentFunction(); - - private: - // WebviewExtensionFunction implementation. - virtual bool RunAsyncSafe(WebViewGuest* guest) OVERRIDE; - - DISALLOW_COPY_AND_ASSIGN(WebviewOverrideUserAgentFunction); -}; - -class WebviewStopFunction : public WebviewExtensionFunction { - public: - DECLARE_EXTENSION_FUNCTION("webview.stop", WEBVIEW_STOP); - - WebviewStopFunction(); - - protected: - virtual ~WebviewStopFunction(); - - private: - // WebviewExtensionFunction implementation. - virtual bool RunAsyncSafe(WebViewGuest* guest) OVERRIDE; - - DISALLOW_COPY_AND_ASSIGN(WebviewStopFunction); -}; - -class WebviewTerminateFunction : public WebviewExtensionFunction { - public: - DECLARE_EXTENSION_FUNCTION("webview.terminate", WEBVIEW_TERMINATE); - - WebviewTerminateFunction(); - - protected: - virtual ~WebviewTerminateFunction(); - - private: - // WebviewExtensionFunction implementation. - virtual bool RunAsyncSafe(WebViewGuest* guest) OVERRIDE; - - DISALLOW_COPY_AND_ASSIGN(WebviewTerminateFunction); -}; - -} // namespace extensions - -#endif // CHROME_BROWSER_EXTENSIONS_API_WEBVIEW_WEBVIEW_API_H_ diff --git a/chrome/browser/extensions/menu_manager.cc b/chrome/browser/extensions/menu_manager.cc index 0a06139..e40b467 100644 --- a/chrome/browser/extensions/menu_manager.cc +++ b/chrome/browser/extensions/menu_manager.cc @@ -20,7 +20,7 @@ #include "chrome/browser/guest_view/web_view/web_view_guest.h" #include "chrome/browser/profiles/profile.h" #include "chrome/common/extensions/api/context_menus.h" -#include "chrome/common/extensions/api/webview.h" +#include "chrome/common/extensions/api/web_view_internal.h" #include "content/public/browser/notification_details.h" #include "content/public/browser/notification_service.h" #include "content/public/browser/notification_source.h" @@ -41,7 +41,7 @@ using extensions::ExtensionSystem; namespace extensions { namespace context_menus = api::context_menus; -namespace webview = api::webview; +namespace web_view = api::web_view_internal; namespace { @@ -300,7 +300,8 @@ bool MenuItem::PopulateURLPatterns( // static const char MenuManager::kOnContextMenus[] = "contextMenus"; -const char MenuManager::kOnWebviewContextMenus[] = "webview.contextMenus"; +const char MenuManager::kOnWebviewContextMenus[] = + "webViewInternal.contextMenus"; MenuManager::MenuManager(Profile* profile, StateStore* store) : extension_registry_observer_(this), profile_(profile), store_(store) { @@ -654,7 +655,7 @@ void MenuManager::ExecuteCommand(Profile* profile, WebViewGuest* webview_guest = WebViewGuest::FromWebContents(web_contents); if (webview_guest) { - // This is used in webview_custom_bindings.js. + // This is used in web_view_internalcustom_bindings.js. // The property is not exposed to developer API. properties->SetInteger("webviewInstanceId", webview_guest->view_instance_id()); @@ -709,7 +710,7 @@ void MenuManager::ExecuteCommand(Profile* profile, { // Dispatch to .contextMenus.onClicked handler. scoped_ptr<Event> event( - new Event(webview_guest ? webview::OnClicked::kEventName + new Event(webview_guest ? web_view::OnClicked::kEventName : context_menus::OnClicked::kEventName, args.Pass())); event->restrict_to_browser_context = profile; |