diff options
author | fsamuel@chromium.org <fsamuel@chromium.org@0039d316-1c4b-4281-b951-d872f2087c98> | 2014-05-22 18:17:46 +0000 |
---|---|---|
committer | fsamuel@chromium.org <fsamuel@chromium.org@0039d316-1c4b-4281-b951-d872f2087c98> | 2014-05-22 18:17:46 +0000 |
commit | 504073e1d18c781c36bfcb8268bc3925fc53b488 (patch) | |
tree | 7d56c1154be215329b635ad48a5755aa79078b84 | |
parent | 669bb38acafd7d962dec8ed2ede725b1bf823e84 (diff) | |
download | chromium_src-504073e1d18c781c36bfcb8268bc3925fc53b488.zip chromium_src-504073e1d18c781c36bfcb8268bc3925fc53b488.tar.gz chromium_src-504073e1d18c781c36bfcb8268bc3925fc53b488.tar.bz2 |
<webview>: Move name attribute to chrome
This CL introduces a new way to monitor changes to frame names from the content embedder, and setting the main frame name from the content embedder.
The name attribute is now managed by web_view.js, and not BrowserPlugin.
BUG=364141, 330264
TBR=kenrb@chromium.org (removing IPC messages).
Review URL: https://codereview.chromium.org/291483010
git-svn-id: svn://svn.chromium.org/chrome/trunk/src@272241 0039d316-1c4b-4281-b951-d872f2087c98
26 files changed, 199 insertions, 145 deletions
diff --git a/chrome/browser/extensions/api/webview/webview_api.cc b/chrome/browser/extensions/api/webview/webview_api.cc index 93898f0..cfa2e34 100644 --- a/chrome/browser/extensions/api/webview/webview_api.cc +++ b/chrome/browser/extensions/api/webview/webview_api.cc @@ -349,12 +349,27 @@ void WebviewCaptureVisibleRegionFunction::OnCaptureFailure( SendResponse(false); } +WebviewSetNameFunction::WebviewSetNameFunction() { +} + +WebviewSetNameFunction::~WebviewSetNameFunction() { +} + WebviewSetZoomFunction::WebviewSetZoomFunction() { } WebviewSetZoomFunction::~WebviewSetZoomFunction() { } +bool WebviewSetNameFunction::RunAsyncSafe(WebViewGuest* guest) { + scoped_ptr<webview::SetName::Params> params( + webview::SetName::Params::Create(*args_)); + EXTENSION_FUNCTION_VALIDATE(params.get()); + guest->SetName(params->frame_name); + SendResponse(true); + return true; +} + bool WebviewSetZoomFunction::RunAsyncSafe(WebViewGuest* guest) { scoped_ptr<webview::SetZoom::Params> params( webview::SetZoom::Params::Create(*args_)); diff --git a/chrome/browser/extensions/api/webview/webview_api.h b/chrome/browser/extensions/api/webview/webview_api.h index 2e23bfd..e0b9efe 100644 --- a/chrome/browser/extensions/api/webview/webview_api.h +++ b/chrome/browser/extensions/api/webview/webview_api.h @@ -204,6 +204,21 @@ class WebviewCaptureVisibleRegionFunction 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); diff --git a/chrome/browser/guest_view/web_view/web_view_constants.cc b/chrome/browser/guest_view/web_view/web_view_constants.cc index 5c1e5f1..68be6a3 100644 --- a/chrome/browser/guest_view/web_view/web_view_constants.cc +++ b/chrome/browser/guest_view/web_view/web_view_constants.cc @@ -14,6 +14,7 @@ const char kEventContextMenu[] = "webview.contextmenu"; const char kEventDialog[] = "webview.onDialog"; const char kEventExit[] = "webview.onExit"; const char kEventFindReply[] = "webview.onFindReply"; +const char kEventFrameNameChanged[] = "webview.onFrameNameChanged"; const char kEventLoadAbort[] = "webview.onLoadAbort"; const char kEventLoadCommit[] = "webview.onLoadCommit"; const char kEventLoadProgress[] = "webview.onLoadProgress"; diff --git a/chrome/browser/guest_view/web_view/web_view_constants.h b/chrome/browser/guest_view/web_view/web_view_constants.h index d421702..f704258 100644 --- a/chrome/browser/guest_view/web_view/web_view_constants.h +++ b/chrome/browser/guest_view/web_view/web_view_constants.h @@ -17,6 +17,7 @@ extern const char kEventContextMenu[]; extern const char kEventDialog[]; extern const char kEventExit[]; extern const char kEventFindReply[]; +extern const char kEventFrameNameChanged[]; extern const char kEventLoadAbort[]; extern const char kEventLoadCommit[]; extern const char kEventLoadProgress[]; diff --git a/chrome/browser/guest_view/web_view/web_view_guest.cc b/chrome/browser/guest_view/web_view/web_view_guest.cc index 465495e..9f9ea46 100644 --- a/chrome/browser/guest_view/web_view/web_view_guest.cc +++ b/chrome/browser/guest_view/web_view/web_view_guest.cc @@ -23,6 +23,7 @@ #include "chrome/browser/renderer_context_menu/context_menu_delegate.h" #include "chrome/browser/renderer_context_menu/render_view_context_menu.h" #include "chrome/common/chrome_version_info.h" +#include "chrome/common/render_messages.h" #include "content/public/browser/browser_thread.h" #include "content/public/browser/child_process_security_policy.h" #include "content/public/browser/geolocation_permission_context.h" @@ -45,6 +46,7 @@ #include "content/public/common/stop_find_action.h" #include "content/public/common/url_constants.h" #include "extensions/common/constants.h" +#include "ipc/ipc_message_macros.h" #include "net/base/net_errors.h" #include "third_party/WebKit/public/web/WebFindOptions.h" #include "ui/base/models/simple_menu_model.h" @@ -67,6 +69,7 @@ #endif using base::UserMetricsAction; +using content::RenderFrameHost; using content::WebContents; namespace { @@ -310,6 +313,15 @@ scoped_ptr<base::ListValue> WebViewGuest::MenuModelToValue( void WebViewGuest::Attach(WebContents* embedder_web_contents, const base::DictionaryValue& args) { + std::string name; + args.GetString(webview::kName, &name); + // If the guest window's name is empty, then the WebView tag's name is + // assigned. Otherwise, the guest window's name takes precedence over the + // WebView tag's name. + if (name_.empty()) + name_ = name; + ReportFrameNameChange(name_); + std::string user_agent_override; if (args.GetString(webview::kParameterUserAgentOverride, &user_agent_override)) { @@ -467,6 +479,17 @@ void WebViewGuest::LoadAbort(bool is_top_level, new GuestViewBase::Event(webview::kEventLoadAbort, args.Pass())); } +void WebViewGuest::OnUpdateFrameName(bool is_top_level, + const std::string& name) { + if (!is_top_level) + return; + + if (name_ == name) + return; + + ReportFrameNameChange(name); +} + WebViewGuest* WebViewGuest::CreateNewGuestWindow( const content::OpenURLParams& params) { @@ -839,6 +862,16 @@ void WebViewGuest::DidStopLoading(content::RenderViewHost* render_view_host) { DispatchEvent(new GuestViewBase::Event(webview::kEventLoadStop, args.Pass())); } +bool WebViewGuest::OnMessageReceived(const IPC::Message& message, + RenderFrameHost* render_frame_host) { + bool handled = true; + IPC_BEGIN_MESSAGE_MAP(WebViewGuest, message) + IPC_MESSAGE_HANDLER(ChromeViewHostMsg_UpdateFrameName, OnUpdateFrameName) + IPC_MESSAGE_UNHANDLED(handled = false) + IPC_END_MESSAGE_MAP() + return handled; +} + void WebViewGuest::WebContentsDestroyed() { // Clean up custom context menu items for this guest. extensions::MenuManager* menu_manager = extensions::MenuManager::Get( @@ -865,6 +898,18 @@ void WebViewGuest::UserAgentOverrideSet(const std::string& user_agent) { guest_web_contents()->GetController().Reload(false); } +void WebViewGuest::RenderViewReady() { + Send(new ChromeViewMsg_SetName(guest_web_contents()->GetRoutingID(), name_)); +} + +void WebViewGuest::ReportFrameNameChange(const std::string& name) { + name_ = name; + scoped_ptr<base::DictionaryValue> args(new base::DictionaryValue()); + args->SetString(webview::kName, name); + DispatchEvent( + new GuestViewBase::Event(webview::kEventFrameNameChanged, args.Pass())); +} + void WebViewGuest::LoadHandlerCalled() { scoped_ptr<base::DictionaryValue> args(new base::DictionaryValue()); DispatchEvent( @@ -1205,6 +1250,14 @@ void WebViewGuest::ShowContextMenu(int request_id, menu_delegate->ShowMenu(pending_menu_.Pass()); } +void WebViewGuest::SetName(const std::string& name) { + if (name_ == name) + return; + name_ = name; + + Send(new ChromeViewMsg_SetName(routing_id(), name_)); +} + void WebViewGuest::Destroy() { if (!attached() && GetOpener()) GetOpener()->pending_new_windows_.erase(this); @@ -1263,6 +1316,7 @@ void WebViewGuest::WebContentsCreated(WebContents* source_contents, CHECK(guest); guest->SetOpener(this); std::string guest_name = base::UTF16ToUTF8(frame_name); + guest->name_ = guest_name; pending_new_windows_.insert( std::make_pair(guest, NewWindowInfo(target_url, guest_name))); } diff --git a/chrome/browser/guest_view/web_view/web_view_guest.h b/chrome/browser/guest_view/web_view/web_view_guest.h index ee86f63..f7b6d2b 100644 --- a/chrome/browser/guest_view/web_view/web_view_guest.h +++ b/chrome/browser/guest_view/web_view/web_view_guest.h @@ -63,6 +63,9 @@ class WebViewGuest : public GuestView<WebViewGuest>, // |items| == NULL means no filtering will be applied. void ShowContextMenu(int request_id, const MenuItemVector* items); + // Sets the frame name of the guest. + void SetName(const std::string& name); + // GuestViewBase implementation. virtual void Attach(content::WebContents* embedder_web_contents, const base::DictionaryValue& args) OVERRIDE; @@ -291,8 +294,15 @@ class WebViewGuest : public GuestView<WebViewGuest>, content::RenderViewHost* render_view_host) OVERRIDE; virtual void DidStopLoading( content::RenderViewHost* render_view_host) OVERRIDE; + virtual bool OnMessageReceived( + const IPC::Message& message, + content::RenderFrameHost* render_frame_host) OVERRIDE; virtual void WebContentsDestroyed() OVERRIDE; virtual void UserAgentOverrideSet(const std::string& user_agent) OVERRIDE; + virtual void RenderViewReady() OVERRIDE; + + // Informs the embedder of a frame name change. + void ReportFrameNameChange(const std::string& name); // Called after the load handler is called in the guest's main frame. void LoadHandlerCalled(); @@ -343,6 +353,7 @@ class WebViewGuest : public GuestView<WebViewGuest>, const GURL& url, const std::string& error_type); + void OnUpdateFrameName(bool is_top_level, const std::string& name); // Creates a new guest window owned by this WebViewGuest. WebViewGuest* CreateNewGuestWindow(const content::OpenURLParams& params); @@ -382,6 +393,9 @@ class WebViewGuest : public GuestView<WebViewGuest>, // Stores the current zoom factor. double current_zoom_factor_; + // Stores the window name of the main frame of the guest. + std::string name_; + // Handles find requests and replies for the webview find API. WebviewFindHelper find_helper_; diff --git a/chrome/common/extensions/api/webview.json b/chrome/common/extensions/api/webview.json index 70085e0..8b995b2 100644 --- a/chrome/common/extensions/api/webview.json +++ b/chrome/common/extensions/api/webview.json @@ -611,6 +611,20 @@ ] }, { + "name": "setName", + "type": "function", + "parameters": [ + { + "type": "integer", + "name": "instanceId" + }, + { + "type": "string", + "name": "frameName" + } + ] + }, + { "name": "setPermission", "type": "function", "parameters": [ diff --git a/chrome/common/render_messages.h b/chrome/common/render_messages.h index ee6939d..92fffdb 100644 --- a/chrome/common/render_messages.h +++ b/chrome/common/render_messages.h @@ -234,6 +234,10 @@ IPC_MESSAGE_CONTROL3(ChromeViewMsg_SetCacheCapacities, IPC_MESSAGE_CONTROL1(ChromeViewMsg_ClearCache, bool /* on_navigation */) +// Set the top-level frame to the provided name. +IPC_MESSAGE_ROUTED1(ChromeViewMsg_SetName, + std::string /* frame_name */) + // For WebUI testing, this message requests JavaScript to be executed at a time // which is late enough to not be thrown out, and early enough to be before // onload events are fired. @@ -466,6 +470,11 @@ IPC_SYNC_MESSAGE_CONTROL1_3( std::vector<base::string16> /* additional_param_names */, std::vector<base::string16> /* additional_param_values */) +// Informs the browser of updated frame names. +IPC_MESSAGE_ROUTED2(ChromeViewHostMsg_UpdateFrameName, + bool /* is_top_level */, + std::string /* name */) + #if defined(ENABLE_PLUGIN_INSTALLATION) // Tells the browser to search for a plug-in that can handle the given MIME // type. The result will be sent asynchronously to the routing ID diff --git a/chrome/renderer/chrome_render_frame_observer.cc b/chrome/renderer/chrome_render_frame_observer.cc index 9db49fb..438a33c 100644 --- a/chrome/renderer/chrome_render_frame_observer.cc +++ b/chrome/renderer/chrome_render_frame_observer.cc @@ -4,6 +4,7 @@ #include "chrome/renderer/chrome_render_frame_observer.h" +#include "base/strings/utf_string_conversions.h" #include "chrome/common/prerender_messages.h" #include "chrome/common/print_messages.h" #include "chrome/common/render_messages.h" @@ -14,6 +15,7 @@ #include "skia/ext/platform_canvas.h" #include "third_party/WebKit/public/platform/WebImage.h" #include "third_party/WebKit/public/web/WebElement.h" +#include "third_party/WebKit/public/web/WebFrame.h" #include "third_party/WebKit/public/web/WebNode.h" using blink::WebElement; @@ -56,7 +58,8 @@ SkBitmap Downscale(blink::WebImage image, static_cast<int>(scaled_size.height())); } -} +} // namespace + ChromeRenderFrameObserver::ChromeRenderFrameObserver( content::RenderFrame* render_frame) : content::RenderFrameObserver(render_frame) { @@ -86,6 +89,14 @@ bool ChromeRenderFrameObserver::OnMessageReceived(const IPC::Message& message) { return handled; } +void ChromeRenderFrameObserver::DidChangeName( + const base::string16& name) { + Send(new ChromeViewHostMsg_UpdateFrameName( + routing_id(), + !render_frame()->GetWebFrame()->parent(), + base::UTF16ToUTF8(name))); +} + void ChromeRenderFrameObserver::OnSetIsPrerendering(bool is_prerendering) { if (is_prerendering) { // If the PrerenderHelper for this frame already exists, don't create it. It diff --git a/chrome/renderer/chrome_render_frame_observer.h b/chrome/renderer/chrome_render_frame_observer.h index 9981b3c..d9a836d 100644 --- a/chrome/renderer/chrome_render_frame_observer.h +++ b/chrome/renderer/chrome_render_frame_observer.h @@ -21,6 +21,7 @@ class ChromeRenderFrameObserver : public content::RenderFrameObserver { private: // RenderFrameObserver implementation. virtual bool OnMessageReceived(const IPC::Message& message) OVERRIDE; + virtual void DidChangeName(const base::string16& name) OVERRIDE; // IPC handlers void OnSetIsPrerendering(bool is_prerendering); diff --git a/chrome/renderer/chrome_render_view_observer.cc b/chrome/renderer/chrome_render_view_observer.cc index da28a91..d292b3e 100644 --- a/chrome/renderer/chrome_render_view_observer.cc +++ b/chrome/renderer/chrome_render_view_observer.cc @@ -235,6 +235,7 @@ bool ChromeRenderViewObserver::OnMessageReceived(const IPC::Message& message) { IPC_MESSAGE_HANDLER(ChromeViewMsg_WebUIJavaScript, OnWebUIJavaScript) IPC_MESSAGE_HANDLER(ChromeViewMsg_SetClientSidePhishingDetection, OnSetClientSidePhishingDetection) + IPC_MESSAGE_HANDLER(ChromeViewMsg_SetName, OnSetName) IPC_MESSAGE_HANDLER(ChromeViewMsg_SetVisuallyDeemphasized, OnSetVisuallyDeemphasized) IPC_MESSAGE_HANDLER(ChromeViewMsg_GetFPS, OnGetFPS) @@ -358,6 +359,13 @@ void ChromeRenderViewObserver::OnSetClientSidePhishingDetection( #endif } +void ChromeRenderViewObserver::OnSetName(const std::string& name) { + if (!render_view()->GetWebView()) + return; + + render_view()->GetWebView()->mainFrame()->setName(WebString::fromUTF8(name)); +} + void ChromeRenderViewObserver::OnSetVisuallyDeemphasized(bool deemphasized) { bool already_deemphasized = !!dimmed_color_overlay_.get(); if (already_deemphasized == deemphasized) diff --git a/chrome/renderer/chrome_render_view_observer.h b/chrome/renderer/chrome_render_view_observer.h index 4dbdbb8..b18e9cd 100644 --- a/chrome/renderer/chrome_render_view_observer.h +++ b/chrome/renderer/chrome_render_view_observer.h @@ -60,6 +60,7 @@ class ChromeRenderViewObserver : public content::RenderViewObserver { void OnWebUIJavaScript(const base::string16& javascript); void OnSetClientSidePhishingDetection(bool enable_phishing_detection); + void OnSetName(const std::string& name); void OnSetVisuallyDeemphasized(bool deemphasized); void OnGetFPS(); #if defined(OS_ANDROID) diff --git a/chrome/renderer/resources/extensions/web_view.js b/chrome/renderer/resources/extensions/web_view.js index 3a8627c..f00fb9b 100644 --- a/chrome/renderer/resources/extensions/web_view.js +++ b/chrome/renderer/resources/extensions/web_view.js @@ -26,7 +26,6 @@ var WEB_VIEW_ATTRIBUTE_MINWIDTH = 'minwidth'; var WEB_VIEW_ATTRIBUTES = [ 'allowtransparency', 'autosize', - 'name', 'partition', WEB_VIEW_ATTRIBUTE_MINHEIGHT, WEB_VIEW_ATTRIBUTE_MINWIDTH, @@ -53,6 +52,9 @@ var CreateEvent = function(name) { // behavior can be canceled. If the default action associated with the event // is prevented, then its dispatch function will return false in its event // handler. The event must have a custom handler for this to be meaningful. + +var FrameNameChangedEvent = CreateEvent('webview.onFrameNameChanged'); + var WEB_VIEW_EVENTS = { 'close': { evt: CreateEvent('webview.onClose'), @@ -387,6 +389,16 @@ WebViewInternal.prototype.setupWebviewNodeProperties = function() { enumerable: true }); + Object.defineProperty(this.webviewNode, 'name', { + get: function() { + return self.name; + }, + set: function(value) { + self.webviewNode.setAttribute('name', value); + }, + enumerable: true + }); + // We cannot use {writable: true} property descriptor because we want a // dynamic getter value. Object.defineProperty(this.webviewNode, 'contentWindow', { @@ -446,7 +458,22 @@ WebViewInternal.prototype.handleWebviewAttributeMutation = // a BrowserPlugin property will update the corresponding BrowserPlugin // attribute, if necessary. See BrowserPlugin::UpdateDOMAttribute for more // details. - if (name == 'src') { + if (name == 'name') { + // We treat null attribute (attribute removed) and the empty string as + // one case. + oldValue = oldValue || ''; + newValue = newValue || ''; + + if (oldValue === newValue) { + return; + } + this.name = newValue; + if (!this.instanceId) { + return; + } + WebView.setName(this.instanceId, newValue); + return; + } else if (name == 'src') { // We treat null attribute (attribute removed) and the empty string as // one case. oldValue = oldValue || ''; @@ -595,6 +622,21 @@ WebViewInternal.prototype.setupWebviewNodeEvents = function() { /** * @private */ +WebViewInternal.prototype.setupNameAttribute = function() { + var self = this; + FrameNameChangedEvent.addListener(function(event) { + self.name = event.name || ''; + if (self.name === '') { + self.webviewNode.removeAttribute('name'); + } else { + self.webviewNode.setAttribute('name', self.name); + } + }, {instanceId: self.instanceId}); +}; + +/** + * @private + */ WebViewInternal.prototype.setupEvent = function(eventName, eventInfo) { var self = this; var webviewNode = this.webviewNode; @@ -1024,17 +1066,20 @@ WebViewInternal.prototype.attachWindowAndSetUpEvents = function(instanceId) { this.instanceId = instanceId; var params = { 'api': 'webview', - 'instanceId': this.viewInstanceId + 'instanceId': this.viewInstanceId, + 'name': this.name }; if (this.userAgentOverride) { params['userAgentOverride'] = this.userAgentOverride; } - this.browserPluginNode['-internal-attach'](this.instanceId, params); - + this.setupNameAttribute(); var events = this.getEvents(); for (var eventName in events) { this.setupEvent(eventName, events[eventName]); } + + this.browserPluginNode['-internal-attach'](this.instanceId, params); + return true; }; diff --git a/content/browser/browser_plugin/browser_plugin_guest.cc b/content/browser/browser_plugin/browser_plugin_guest.cc index d9b8659..15ec3ba 100644 --- a/content/browser/browser_plugin/browser_plugin_guest.cc +++ b/content/browser/browser_plugin/browser_plugin_guest.cc @@ -187,7 +187,6 @@ bool BrowserPluginGuest::OnMessageReceivedFromEmbedder( IPC_MESSAGE_HANDLER(BrowserPluginHostMsg_SetEditCommandsForNextKeyEvent, OnSetEditCommandsForNextKeyEvent) IPC_MESSAGE_HANDLER(BrowserPluginHostMsg_SetFocus, OnSetFocus) - IPC_MESSAGE_HANDLER(BrowserPluginHostMsg_SetName, OnSetName) IPC_MESSAGE_HANDLER(BrowserPluginHostMsg_SetContentsOpaque, OnSetContentsOpaque) IPC_MESSAGE_HANDLER(BrowserPluginHostMsg_SetVisibility, OnSetVisibility) @@ -206,8 +205,6 @@ void BrowserPluginGuest::Initialize( guest_opaque_ = params.opaque; guest_window_rect_ = params.resize_guest_params.view_rect; - if (!params.name.empty()) - name_ = params.name; auto_size_enabled_ = params.auto_size_params.enable; max_auto_size_ = params.auto_size_params.max_size; min_auto_size_ = params.auto_size_params.min_size; @@ -281,7 +278,6 @@ void BrowserPluginGuest::Initialize( ack_params.storage_partition_id = site_url.query(); ack_params.persist_storage = site_url.path().find("persist") != std::string::npos; - ack_params.name = name_; SendMessageToEmbedder( new BrowserPluginMsg_Attach_ACK(instance_id_, ack_params)); @@ -486,12 +482,6 @@ void BrowserPluginGuest::WebContentsCreated(WebContents* source_contents, const base::string16& frame_name, const GURL& target_url, WebContents* new_contents) { - WebContentsImpl* new_contents_impl = - static_cast<WebContentsImpl*>(new_contents); - BrowserPluginGuest* guest = new_contents_impl->GetBrowserPluginGuest(); - std::string guest_name = base::UTF16ToUTF8(frame_name); - guest->name_ = guest_name; - if (!delegate_) return; @@ -624,7 +614,6 @@ void BrowserPluginGuest::RenderViewReady() { else rvh->DisableAutoResize(full_size_); - Send(new ViewMsg_SetName(routing_id(), name_)); OnSetContentsOpaque(instance_id_, guest_opaque_); RenderWidgetHostImpl::From(rvh)->set_hung_renderer_delay_ms( @@ -671,7 +660,6 @@ bool BrowserPluginGuest::ShouldForwardToBrowserPluginGuest( case BrowserPluginHostMsg_SetAutoSize::ID: case BrowserPluginHostMsg_SetEditCommandsForNextKeyEvent::ID: case BrowserPluginHostMsg_SetFocus::ID: - case BrowserPluginHostMsg_SetName::ID: case BrowserPluginHostMsg_SetContentsOpaque::ID: case BrowserPluginHostMsg_SetVisibility::ID: case BrowserPluginHostMsg_UnlockMouse_ACK::ID: @@ -706,7 +694,6 @@ bool BrowserPluginGuest::OnMessageReceived(const IPC::Message& message) { OnImeCompositionRangeChanged) #endif IPC_MESSAGE_HANDLER(ViewHostMsg_UnlockMouse, OnUnlockMouse) - IPC_MESSAGE_HANDLER(ViewHostMsg_UpdateFrameName, OnUpdateFrameName) IPC_MESSAGE_HANDLER(ViewHostMsg_UpdateRect, OnUpdateRect) IPC_MESSAGE_UNHANDLED(handled = false) IPC_END_MESSAGE_MAP() @@ -736,12 +723,6 @@ void BrowserPluginGuest::Attach( new_view->CreateViewForWidget(web_contents()->GetRenderViewHost()); } - // The guest's frame name takes precedence over the BrowserPlugin's name. - // The guest's frame name is assigned in - // BrowserPluginGuest::WebContentsCreated. - if (!name_.empty()) - params.name.clear(); - Initialize(params, embedder_web_contents); SendQueuedMessages(); @@ -975,13 +956,6 @@ void BrowserPluginGuest::OnSetFocus(int instance_id, bool focused) { } } -void BrowserPluginGuest::OnSetName(int instance_id, const std::string& name) { - if (name == name_) - return; - name_ = name; - Send(new ViewMsg_SetName(routing_id(), name)); -} - void BrowserPluginGuest::OnSetSize( int instance_id, const BrowserPluginHostMsg_AutoSize_Params& auto_size_params, @@ -1107,16 +1081,6 @@ void BrowserPluginGuest::OnTakeFocus(bool reverse) { new BrowserPluginMsg_AdvanceFocus(instance_id(), reverse)); } -void BrowserPluginGuest::OnUpdateFrameName(int frame_id, - bool is_top_level, - const std::string& name) { - if (!is_top_level) - return; - - name_ = name; - SendMessageToEmbedder(new BrowserPluginMsg_UpdatedName(instance_id_, name)); -} - void BrowserPluginGuest::RequestMediaAccessPermission( WebContents* web_contents, const MediaStreamRequest& request, diff --git a/content/browser/browser_plugin/browser_plugin_guest.h b/content/browser/browser_plugin/browser_plugin_guest.h index b3466c0..3b7dce9 100644 --- a/content/browser/browser_plugin/browser_plugin_guest.h +++ b/content/browser/browser_plugin/browser_plugin_guest.h @@ -327,9 +327,6 @@ class CONTENT_EXPORT BrowserPluginGuest int instance_id, const BrowserPluginHostMsg_ResizeGuest_Params& params); // Overridden in tests. virtual void OnSetFocus(int instance_id, bool focused); - // Sets the name of the guest so that other guests in the same partition can - // access it. - void OnSetName(int instance_id, const std::string& name); // Updates the size state of the guest. void OnSetSize( int instance_id, @@ -397,9 +394,6 @@ class CONTENT_EXPORT BrowserPluginGuest void OnShowWidget(int route_id, const gfx::Rect& initial_pos); // Overridden in tests. virtual void OnTakeFocus(bool reverse); - void OnUpdateFrameName(int frame_id, - bool is_top_level, - const std::string& name); void OnUpdateRect(const ViewHostMsg_UpdateRect_Params& params); // Forwards all messages from the |pending_messages_| queue to the embedder. diff --git a/content/common/browser_plugin/browser_plugin_messages.h b/content/common/browser_plugin/browser_plugin_messages.h index d428447..32e8f29 100644 --- a/content/common/browser_plugin/browser_plugin_messages.h +++ b/content/common/browser_plugin/browser_plugin_messages.h @@ -61,7 +61,6 @@ IPC_STRUCT_BEGIN(BrowserPluginHostMsg_Attach_Params) IPC_STRUCT_MEMBER(bool, focused) IPC_STRUCT_MEMBER(bool, visible) IPC_STRUCT_MEMBER(bool, opaque) - IPC_STRUCT_MEMBER(std::string, name) IPC_STRUCT_MEMBER(std::string, src) IPC_STRUCT_MEMBER(GURL, embedder_frame_url) IPC_STRUCT_MEMBER(BrowserPluginHostMsg_AutoSize_Params, auto_size_params) @@ -72,7 +71,6 @@ IPC_STRUCT_END() IPC_STRUCT_BEGIN(BrowserPluginMsg_Attach_ACK_Params) IPC_STRUCT_MEMBER(std::string, storage_partition_id) IPC_STRUCT_MEMBER(bool, persist_storage) - IPC_STRUCT_MEMBER(std::string, name) IPC_STRUCT_END() IPC_STRUCT_BEGIN(BrowserPluginMsg_UpdateRect_Params) @@ -209,11 +207,6 @@ IPC_MESSAGE_ROUTED5(BrowserPluginHostMsg_DragStatusUpdate, blink::WebDragOperationsMask /* operation_mask */, gfx::Point /* plugin_location */) -// Sets the name of the guest window to the provided |name|. -IPC_MESSAGE_ROUTED2(BrowserPluginHostMsg_SetName, - int /* instance_id */, - std::string /* name */) - // Sends a PointerLock Lock ACK to the BrowserPluginGuest. IPC_MESSAGE_ROUTED2(BrowserPluginHostMsg_LockMouse_ACK, int /* instance_id */, @@ -294,11 +287,6 @@ IPC_MESSAGE_CONTROL4(BrowserPluginMsg_CopyFromCompositingSurface, gfx::Rect /* source_rect */, gfx::Size /* dest_size */) -// Informs BrowserPlugin of a new name set for the top-level guest frame. -IPC_MESSAGE_CONTROL2(BrowserPluginMsg_UpdatedName, - int /* instance_id */, - std::string /* name */) - // Guest renders into an FBO with textures provided by the embedder. // BrowserPlugin shares mostly the same logic as out-of-process RenderFrames but // because BrowserPlugins implement custom a second level of routing logic, diff --git a/content/common/view_messages.h b/content/common/view_messages.h index de626ca..ae8ea61 100644 --- a/content/common/view_messages.h +++ b/content/common/view_messages.h @@ -529,10 +529,6 @@ IPC_MESSAGE_ROUTED2(ViewMsg_UpdateVSyncParameters, base::TimeTicks /* timebase */, base::TimeDelta /* interval */) -// Set the top-level frame to the provided name. -IPC_MESSAGE_ROUTED1(ViewMsg_SetName, - std::string /* frame_name */) - // Sent to the RenderView when a new tab is swapped into an existing // tab and the histories need to be merged. The existing tab has a history of // |merged_history_length| which precedes the history of the new tab. All @@ -1468,13 +1464,6 @@ IPC_MESSAGE_ROUTED3(ViewHostMsg_UpdateZoomLimits, IPC_MESSAGE_CONTROL1(ViewHostMsg_SuddenTerminationChanged, bool /* enabled */) -// Informs the browser of updated frame names. -IPC_MESSAGE_ROUTED3(ViewHostMsg_UpdateFrameName, - int /* frame_id */, - bool /* is_top_level */, - std::string /* name */) - - IPC_STRUCT_BEGIN(ViewHostMsg_CompositorSurfaceBuffersSwapped_Params) IPC_STRUCT_MEMBER(int32, surface_id) IPC_STRUCT_MEMBER(uint64, surface_handle) diff --git a/content/public/renderer/render_frame_observer.h b/content/public/renderer/render_frame_observer.h index c6e6609a..9dd2de6e 100644 --- a/content/public/renderer/render_frame_observer.h +++ b/content/public/renderer/render_frame_observer.h @@ -48,6 +48,7 @@ class CONTENT_EXPORT RenderFrameObserver : public IPC::Listener, virtual void WillReleaseScriptContext(v8::Handle<v8::Context> context, int world_id) {} virtual void DidClearWindowObject() {} + virtual void DidChangeName(const base::string16& name) {} // Called when we receive a console message from Blink for which we requested // extra details (like the stack trace). |message| is the error message, diff --git a/content/renderer/browser_plugin/browser_plugin.cc b/content/renderer/browser_plugin/browser_plugin.cc index 3f7ef26..9f6f406 100644 --- a/content/renderer/browser_plugin/browser_plugin.cc +++ b/content/renderer/browser_plugin/browser_plugin.cc @@ -117,7 +117,6 @@ bool BrowserPlugin::OnMessageReceived(const IPC::Message& message) { IPC_MESSAGE_HANDLER(BrowserPluginMsg_SetMouseLock, OnSetMouseLock) IPC_MESSAGE_HANDLER(BrowserPluginMsg_ShouldAcceptTouchEvents, OnShouldAcceptTouchEvents) - IPC_MESSAGE_HANDLER(BrowserPluginMsg_UpdatedName, OnUpdatedName) IPC_MESSAGE_HANDLER(BrowserPluginMsg_UpdateRect, OnUpdateRect) IPC_MESSAGE_UNHANDLED(handled = false) IPC_END_MESSAGE_MAP() @@ -165,10 +164,6 @@ bool BrowserPlugin::HasDOMAttribute(const std::string& attribute_name) const { blink::WebString::fromUTF8(attribute_name)); } -std::string BrowserPlugin::GetNameAttribute() const { - return GetDOMAttributeValue(browser_plugin::kAttributeName); -} - bool BrowserPlugin::GetAllowTransparencyAttribute() const { return HasDOMAttribute(browser_plugin::kAttributeAllowTransparency); } @@ -241,15 +236,6 @@ std::string BrowserPlugin::GetPartitionAttribute() const { return GetDOMAttributeValue(browser_plugin::kAttributePartition); } -void BrowserPlugin::ParseNameAttribute() { - if (!HasGuestInstanceID()) - return; - browser_plugin_manager()->Send( - new BrowserPluginHostMsg_SetName(render_view_routing_id_, - guest_instance_id_, - GetNameAttribute())); -} - void BrowserPlugin::ParseAllowTransparencyAttribute() { if (!HasGuestInstanceID()) return; @@ -380,7 +366,6 @@ void BrowserPlugin::Attach(int guest_instance_id, attach_params.focused = ShouldGuestBeFocused(); attach_params.visible = visible_; attach_params.opaque = !GetAllowTransparencyAttribute(); - attach_params.name = GetNameAttribute(); attach_params.storage_partition_id = storage_partition_id_; attach_params.persist_storage = persist_storage_; attach_params.src = GetSrcAttribute(); @@ -408,9 +393,6 @@ void BrowserPlugin::OnAdvanceFocus(int guest_instance_id, bool reverse) { void BrowserPlugin::OnAttachACK( int guest_instance_id, const BrowserPluginMsg_Attach_ACK_Params& params) { - // Update BrowserPlugin attributes to match the state of the guest. - if (!params.name.empty()) - OnUpdatedName(guest_instance_id, params.name); if (!params.storage_partition_id.empty()) { std::string partition_name = (params.persist_storage ? browser_plugin::kPersistPrefix : "") + @@ -516,11 +498,6 @@ void BrowserPlugin::OnShouldAcceptTouchEvents(int guest_instance_id, } } -void BrowserPlugin::OnUpdatedName(int guest_instance_id, - const std::string& name) { - UpdateDOMAttribute(browser_plugin::kAttributeName, name); -} - void BrowserPlugin::OnUpdateRect( int guest_instance_id, const BrowserPluginMsg_UpdateRect_Params& params) { @@ -869,7 +846,6 @@ bool BrowserPlugin::ShouldForwardToBrowserPlugin( case BrowserPluginMsg_SetCursor::ID: case BrowserPluginMsg_SetMouseLock::ID: case BrowserPluginMsg_ShouldAcceptTouchEvents::ID: - case BrowserPluginMsg_UpdatedName::ID: case BrowserPluginMsg_UpdateRect::ID: return true; default: diff --git a/content/renderer/browser_plugin/browser_plugin.h b/content/renderer/browser_plugin/browser_plugin.h index e7fed85..2008303 100644 --- a/content/renderer/browser_plugin/browser_plugin.h +++ b/content/renderer/browser_plugin/browser_plugin.h @@ -55,10 +55,6 @@ class CONTENT_EXPORT BrowserPlugin : // Checks if the attribute |attribute_name| exists in the DOM. bool HasDOMAttribute(const std::string& attribute_name) const; - // Get the name attribute value. - std::string GetNameAttribute() const; - // Parse the name attribute value. - void ParseNameAttribute(); // Get the allowtransparency attribute value. bool GetAllowTransparencyAttribute() const; // Parse the allowtransparency attribute and adjust transparency of @@ -275,7 +271,6 @@ class CONTENT_EXPORT BrowserPlugin : void OnSetCursor(int instance_id, const WebCursor& cursor); void OnSetMouseLock(int instance_id, bool enable); void OnShouldAcceptTouchEvents(int instance_id, bool accept); - void OnUpdatedName(int instance_id, const std::string& name); void OnUpdateRect(int instance_id, const BrowserPluginMsg_UpdateRect_Params& params); diff --git a/content/renderer/browser_plugin/browser_plugin_bindings.cc b/content/renderer/browser_plugin/browser_plugin_bindings.cc index 4284e2b..e78248f 100644 --- a/content/renderer/browser_plugin/browser_plugin_bindings.cc +++ b/content/renderer/browser_plugin/browser_plugin_bindings.cc @@ -510,36 +510,6 @@ class BrowserPluginPropertyBindingMinWidth DISALLOW_COPY_AND_ASSIGN(BrowserPluginPropertyBindingMinWidth); }; -class BrowserPluginPropertyBindingName - : public BrowserPluginPropertyBinding { - public: - BrowserPluginPropertyBindingName() - : BrowserPluginPropertyBinding(browser_plugin::kAttributeName) { - } - virtual bool GetProperty(BrowserPluginBindings* bindings, - NPVariant* result) OVERRIDE { - std::string name = bindings->instance()->GetNameAttribute(); - return StringToNPVariant(name, result); - } - virtual bool SetProperty(BrowserPluginBindings* bindings, - NPObject* np_obj, - const NPVariant* variant) OVERRIDE { - std::string new_value = StringFromNPVariant(*variant); - if (bindings->instance()->GetNameAttribute() != new_value) { - UpdateDOMAttribute(bindings, new_value); - bindings->instance()->ParseNameAttribute(); - } - return true; - } - virtual void RemoveProperty(BrowserPluginBindings* bindings, - NPObject* np_obj) OVERRIDE { - bindings->instance()->RemoveDOMAttribute(name()); - bindings->instance()->ParseNameAttribute(); - } - private: - DISALLOW_COPY_AND_ASSIGN(BrowserPluginPropertyBindingName); -}; - class BrowserPluginPropertyBindingPartition : public BrowserPluginPropertyBinding { public: @@ -660,7 +630,6 @@ BrowserPluginBindings::BrowserPluginBindings(BrowserPlugin* instance) property_bindings_.push_back(new BrowserPluginPropertyBindingMaxWidth); property_bindings_.push_back(new BrowserPluginPropertyBindingMinHeight); property_bindings_.push_back(new BrowserPluginPropertyBindingMinWidth); - property_bindings_.push_back(new BrowserPluginPropertyBindingName); property_bindings_.push_back(new BrowserPluginPropertyBindingPartition); property_bindings_.push_back(new BrowserPluginPropertyBindingSrc); } diff --git a/content/renderer/render_frame_impl.cc b/content/renderer/render_frame_impl.cc index a667a59..a7a3245 100644 --- a/content/renderer/render_frame_impl.cc +++ b/content/renderer/render_frame_impl.cc @@ -1566,11 +1566,7 @@ void RenderFrameImpl::didChangeName(blink::WebLocalFrame* frame, if (!render_view_->renderer_preferences_.report_frame_name_changes) return; - render_view_->Send( - new ViewHostMsg_UpdateFrameName(render_view_->GetRoutingID(), - routing_id_, - !frame->parent(), - base::UTF16ToUTF8(name))); + FOR_EACH_OBSERVER(RenderFrameObserver, observers_, DidChangeName(name)); } void RenderFrameImpl::didMatchCSS( diff --git a/content/renderer/render_view_impl.cc b/content/renderer/render_view_impl.cc index bea25aa..9047168 100644 --- a/content/renderer/render_view_impl.cc +++ b/content/renderer/render_view_impl.cc @@ -1073,7 +1073,6 @@ bool RenderViewImpl::OnMessageReceived(const IPC::Message& message) { OnSetEditCommandsForNextKeyEvent) IPC_MESSAGE_HANDLER(FrameMsg_Navigate, OnNavigate) IPC_MESSAGE_HANDLER(ViewMsg_Stop, OnStop) - IPC_MESSAGE_HANDLER(ViewMsg_SetName, OnSetName) IPC_MESSAGE_HANDLER(ViewMsg_CopyImageAt, OnCopyImageAt) IPC_MESSAGE_HANDLER(ViewMsg_SaveImageAt, OnSaveImageAt) IPC_MESSAGE_HANDLER(ViewMsg_Find, OnFind) @@ -1275,13 +1274,6 @@ void RenderViewImpl::OnSetEditCommandsForNextKeyEvent( edit_commands_ = edit_commands; } -void RenderViewImpl::OnSetName(const std::string& name) { - if (!webview()) - return; - - webview()->mainFrame()->setName(WebString::fromUTF8(name)); -} - void RenderViewImpl::OnSetHistoryLengthAndPrune(int history_length, int32 minimum_page_id) { DCHECK_GE(history_length, 0); diff --git a/content/renderer/render_view_impl.h b/content/renderer/render_view_impl.h index 7237e98..2e4fb14 100644 --- a/content/renderer/render_view_impl.h +++ b/content/renderer/render_view_impl.h @@ -700,7 +700,6 @@ class CONTENT_EXPORT RenderViewImpl void OnShowContextMenu(const gfx::Point& location); void OnCopyImageAt(int x, int y); void OnSaveImageAt(int x, int y); - void OnSetName(const std::string& name); void OnDeterminePageLanguage(); void OnDisableScrollbarsForSmallWindows( const gfx::Size& disable_scrollbars_size_limit); diff --git a/extensions/browser/extension_function_histogram_value.h b/extensions/browser/extension_function_histogram_value.h index d9e091f..58fee8b 100644 --- a/extensions/browser/extension_function_histogram_value.h +++ b/extensions/browser/extension_function_histogram_value.h @@ -833,6 +833,7 @@ enum HistogramValue { FILESYSTEMPROVIDERINTERNAL_READFILEREQUESTEDSUCCESS, FILESYSTEMPROVIDERINTERNAL_READFILEREQUESTEDERROR, NETWORKINGPRIVATE_GETNETWORKS, + WEBVIEW_SETNAME, // Last entry: Add new entries above and ensure to update // tools/metrics/histograms/histograms/histograms.xml. ENUM_BOUNDARY diff --git a/tools/metrics/histograms/histograms.xml b/tools/metrics/histograms/histograms.xml index edb5a82..37632e3 100644 --- a/tools/metrics/histograms/histograms.xml +++ b/tools/metrics/histograms/histograms.xml @@ -34781,6 +34781,7 @@ Therefore, the affected-histogram name has to have at least one dot in it. <int value="772" label="FILESYSTEMPROVIDERINTERNAL_READFILEREQUESTEDSUCCESS"/> <int value="773" label="FILESYSTEMPROVIDERINTERNAL_READFILEREQUESTEDERROR"/> <int value="774" label="NETWORKINGPRIVATE_GETNETWORKS"/> + <int value="775" label="WEBVIEW_SETNAME"/> </enum> <enum name="ExtensionInstallCause" type="int"> |