summaryrefslogtreecommitdiffstats
diff options
context:
space:
mode:
-rw-r--r--apps/app_window_contents.cc17
-rw-r--r--apps/native_app_window.h4
-rw-r--r--apps/shell_window.cc10
-rw-r--r--chrome/browser/extensions/extension_process_manager.cc24
-rw-r--r--chrome/browser/speech/chrome_speech_recognition_manager_delegate.cc6
-rw-r--r--chrome/browser/task_manager/tab_contents_resource_provider.cc6
-rw-r--r--chrome/browser/ui/cocoa/apps/native_app_window_cocoa.h11
-rw-r--r--chrome/browser/ui/cocoa/apps/native_app_window_cocoa.mm10
-rw-r--r--chrome/browser/ui/gtk/apps/native_app_window_gtk.cc6
-rw-r--r--chrome/browser/ui/gtk/apps/native_app_window_gtk.h10
-rw-r--r--chrome/browser/ui/panels/panel.cc10
-rw-r--r--chrome/browser/ui/views/apps/native_app_window_views.cc4
-rw-r--r--chrome/browser/ui/views/apps/native_app_window_views.h4
-rw-r--r--content/browser/android/content_view_core_impl.cc12
-rw-r--r--content/browser/browser_plugin/browser_plugin_host_browsertest.cc2
-rw-r--r--content/browser/web_contents/render_view_host_manager.cc28
-rw-r--r--content/browser/web_contents/render_view_host_manager.h2
-rw-r--r--content/browser/web_contents/render_view_host_manager_unittest.cc31
-rw-r--r--content/browser/web_contents/web_contents_impl.cc21
-rw-r--r--content/browser/web_contents/web_contents_impl.h4
-rw-r--r--content/browser/web_contents/web_drag_source_win.cc4
-rw-r--r--content/public/android/java/src/org/chromium/content/browser/ContentViewCore.java6
-rw-r--r--content/public/browser/notification_types.h16
-rw-r--r--content/public/browser/web_contents_observer.h3
-rw-r--r--ui/views/controls/webview/webview.cc3
25 files changed, 110 insertions, 144 deletions
diff --git a/apps/app_window_contents.cc b/apps/app_window_contents.cc
index 7b88e67..56ae403 100644
--- a/apps/app_window_contents.cc
+++ b/apps/app_window_contents.cc
@@ -60,16 +60,15 @@ void AppWindowContents::LoadContents(int32 creator_process_id) {
}
// TODO(jeremya): there's a bug where navigating a web contents to an
- // extension URL causes it to create a new RVH and discard the old
- // (perfectly usable) one. To work around this, we watch for a RVH_CHANGED
- // message from the web contents (which will be sent during LoadURL) and
- // suspend resource requests on the new RVH to ensure that we block the new
- // RVH from loading anything. It should be okay to remove the
- // NOTIFICATION_RVH_CHANGED registration once http://crbug.com/123007 is
- // fixed.
+ // extension URL causes it to create a new RVH and discard the old (perfectly
+ // usable) one. To work around this, we watch for a
+ // NOTIFICATION_RENDER_VIEW_HOST_CHANGED message from the web contents (which
+ // will be sent during LoadURL) and suspend resource requests on the new RVH
+ // to ensure that we block the new RVH from loading anything. It should be
+ // okay to remove the NOTIFICATION_RENDER_VIEW_HOST_CHANGED registration once
+ // http://crbug.com/123007 is fixed.
registrar_.Add(this, content::NOTIFICATION_RENDER_VIEW_HOST_CHANGED,
- content::Source<content::NavigationController>(
- &web_contents()->GetController()));
+ content::Source<content::WebContents>(web_contents()));
web_contents_->GetController().LoadURL(
url_, content::Referrer(), content::PAGE_TRANSITION_LINK,
std::string());
diff --git a/apps/native_app_window.h b/apps/native_app_window.h
index 9a1e05b..b0a6b17 100644
--- a/apps/native_app_window.h
+++ b/apps/native_app_window.h
@@ -43,10 +43,6 @@ class NativeAppWindow : public ui::BaseWindow,
virtual void HandleKeyboardEvent(
const content::NativeWebKeyboardEvent& event) = 0;
- // TODO(jianli): once http://crbug.com/123007 is fixed, we'll no longer need
- // this.
- virtual void RenderViewHostChanged() = 0;
-
// Returns the difference between the window bounds (including titlebar and
// borders) and the content bounds, if any.
virtual gfx::Insets GetFrameInsets() const = 0;
diff --git a/apps/shell_window.cc b/apps/shell_window.cc
index 4317883..99c330c 100644
--- a/apps/shell_window.cc
+++ b/apps/shell_window.cc
@@ -183,9 +183,6 @@ void ShellWindow::Init(const GURL& url,
// about it in case it has any setup to do to make the renderer appear
// properly. In particular, on Windows, the view's clickthrough region needs
// to be set.
- registrar_.Add(this, content::NOTIFICATION_RENDER_VIEW_HOST_CHANGED,
- content::Source<content::NavigationController>(
- &web_contents->GetController()));
registrar_.Add(this, chrome::NOTIFICATION_EXTENSION_UNLOADED,
content::Source<Profile>(profile_));
// Close when the browser process is exiting.
@@ -543,13 +540,6 @@ void ShellWindow::Observe(int type,
const content::NotificationSource& source,
const content::NotificationDetails& details) {
switch (type) {
- case content::NOTIFICATION_RENDER_VIEW_HOST_CHANGED: {
- // TODO(jianli): once http://crbug.com/123007 is fixed, we'll no longer
- // need to make the native window (ShellWindowViews specially) update
- // the clickthrough region for the new RVH.
- native_app_window_->RenderViewHostChanged();
- break;
- }
case chrome::NOTIFICATION_EXTENSION_UNLOADED: {
const extensions::Extension* unloaded_extension =
content::Details<extensions::UnloadedExtensionInfo>(
diff --git a/chrome/browser/extensions/extension_process_manager.cc b/chrome/browser/extensions/extension_process_manager.cc
index d3163c7..b86df25 100644
--- a/chrome/browser/extensions/extension_process_manager.cc
+++ b/chrome/browser/extensions/extension_process_manager.cc
@@ -163,7 +163,7 @@ ExtensionProcessManager::ExtensionProcessManager(Profile* profile)
content::Source<Profile>(profile));
registrar_.Add(this, chrome::NOTIFICATION_EXTENSION_HOST_VIEW_SHOULD_CLOSE,
content::Source<Profile>(profile));
- registrar_.Add(this, content::NOTIFICATION_WEB_CONTENTS_SWAPPED,
+ registrar_.Add(this, content::NOTIFICATION_RENDER_VIEW_HOST_CHANGED,
content::NotificationService::AllSources());
registrar_.Add(this, content::NOTIFICATION_WEB_CONTENTS_CONNECTED,
content::NotificationService::AllSources());
@@ -350,7 +350,7 @@ std::set<RenderViewHost*>
}
const Extension* ExtensionProcessManager::GetExtensionForRenderViewHost(
- content::RenderViewHost* render_view_host) {
+ RenderViewHost* render_view_host) {
if (!render_view_host->GetSiteInstance())
return NULL;
@@ -640,28 +640,26 @@ void ExtensionProcessManager::Observe(
break;
}
- case content::NOTIFICATION_WEB_CONTENTS_SWAPPED: {
+ case content::NOTIFICATION_RENDER_VIEW_HOST_CHANGED: {
// We get this notification both for new WebContents and when one
// has its RenderViewHost replaced (e.g. when a user does a cross-site
// navigation away from an extension URL). For the replaced case, we must
// unregister the old RVH so it doesn't count as an active view that would
// keep the event page alive.
- content::WebContents* contents =
- content::Source<content::WebContents>(source).ptr();
+ WebContents* contents = content::Source<WebContents>(source).ptr();
if (contents->GetBrowserContext() != GetProfile())
break;
- content::RenderViewHost* old_render_view_host =
- content::Details<content::RenderViewHost>(details).ptr();
- if (old_render_view_host)
- UnregisterRenderViewHost(old_render_view_host);
- RegisterRenderViewHost(contents->GetRenderViewHost());
+ typedef std::pair<RenderViewHost*, RenderViewHost*> RVHPair;
+ RVHPair* switched_details = content::Details<RVHPair>(details).ptr();
+ if (switched_details->first)
+ UnregisterRenderViewHost(switched_details->first);
+ RegisterRenderViewHost(switched_details->second);
break;
}
case content::NOTIFICATION_WEB_CONTENTS_CONNECTED: {
- content::WebContents* contents =
- content::Source<content::WebContents>(source).ptr();
+ WebContents* contents = content::Source<WebContents>(source).ptr();
if (contents->GetBrowserContext() != GetProfile())
break;
const Extension* extension = GetExtensionForRenderViewHost(
@@ -693,7 +691,7 @@ void ExtensionProcessManager::Observe(
void ExtensionProcessManager::OnDevToolsStateChanged(
content::DevToolsAgentHost* agent_host, bool attached) {
- content::RenderViewHost* rvh = agent_host->GetRenderViewHost();
+ RenderViewHost* rvh = agent_host->GetRenderViewHost();
// Ignore unrelated notifications.
if (!rvh ||
rvh->GetSiteInstance()->GetProcess()->GetBrowserContext() != GetProfile())
diff --git a/chrome/browser/speech/chrome_speech_recognition_manager_delegate.cc b/chrome/browser/speech/chrome_speech_recognition_manager_delegate.cc
index 1012975..e2d991f 100644
--- a/chrome/browser/speech/chrome_speech_recognition_manager_delegate.cc
+++ b/chrome/browser/speech/chrome_speech_recognition_manager_delegate.cc
@@ -160,7 +160,7 @@ class ChromeSpeechRecognitionManagerDelegate::TabWatcher
registrar_.reset(new content::NotificationRegistrar());
registrar_->Add(this,
- content::NOTIFICATION_WEB_CONTENTS_SWAPPED,
+ content::NOTIFICATION_RENDER_VIEW_HOST_CHANGED,
content::Source<WebContents>(web_contents));
registrar_->Add(this,
content::NOTIFICATION_WEB_CONTENTS_DISCONNECTED,
@@ -173,7 +173,7 @@ class ChromeSpeechRecognitionManagerDelegate::TabWatcher
const content::NotificationDetails& details) OVERRIDE {
DCHECK(BrowserThread::CurrentlyOn(BrowserThread::UI));
DCHECK(type == content::NOTIFICATION_WEB_CONTENTS_DISCONNECTED ||
- type == content::NOTIFICATION_WEB_CONTENTS_SWAPPED);
+ type == content::NOTIFICATION_RENDER_VIEW_HOST_CHANGED);
WebContents* web_contents = content::Source<WebContents>(source).ptr();
std::vector<WebContentsInfo>::iterator iter = FindWebContents(web_contents);
@@ -183,7 +183,7 @@ class ChromeSpeechRecognitionManagerDelegate::TabWatcher
registered_web_contents_.erase(iter);
registrar_->Remove(this,
- content::NOTIFICATION_WEB_CONTENTS_SWAPPED,
+ content::NOTIFICATION_RENDER_VIEW_HOST_CHANGED,
content::Source<WebContents>(web_contents));
registrar_->Remove(this,
content::NOTIFICATION_WEB_CONTENTS_DISCONNECTED,
diff --git a/chrome/browser/task_manager/tab_contents_resource_provider.cc b/chrome/browser/task_manager/tab_contents_resource_provider.cc
index d8a4e01..549f9a5 100644
--- a/chrome/browser/task_manager/tab_contents_resource_provider.cc
+++ b/chrome/browser/task_manager/tab_contents_resource_provider.cc
@@ -258,7 +258,7 @@ void TabContentsResourceProvider::StartUpdating() {
// Then we register for notifications to get new web contents.
registrar_.Add(this, content::NOTIFICATION_WEB_CONTENTS_CONNECTED,
content::NotificationService::AllBrowserContextsAndSources());
- registrar_.Add(this, content::NOTIFICATION_WEB_CONTENTS_SWAPPED,
+ registrar_.Add(this, content::NOTIFICATION_RENDER_VIEW_HOST_CHANGED,
content::NotificationService::AllBrowserContextsAndSources());
registrar_.Add(this, content::NOTIFICATION_WEB_CONTENTS_DISCONNECTED,
content::NotificationService::AllBrowserContextsAndSources());
@@ -271,7 +271,7 @@ void TabContentsResourceProvider::StopUpdating() {
// Then we unregister for notifications to get new web contents.
registrar_.Remove(this, content::NOTIFICATION_WEB_CONTENTS_CONNECTED,
content::NotificationService::AllBrowserContextsAndSources());
- registrar_.Remove(this, content::NOTIFICATION_WEB_CONTENTS_SWAPPED,
+ registrar_.Remove(this, content::NOTIFICATION_RENDER_VIEW_HOST_CHANGED,
content::NotificationService::AllBrowserContextsAndSources());
registrar_.Remove(this, content::NOTIFICATION_WEB_CONTENTS_DISCONNECTED,
content::NotificationService::AllBrowserContextsAndSources());
@@ -351,7 +351,7 @@ void TabContentsResourceProvider::Observe(
case content::NOTIFICATION_WEB_CONTENTS_CONNECTED:
Add(web_contents);
break;
- case content::NOTIFICATION_WEB_CONTENTS_SWAPPED:
+ case content::NOTIFICATION_RENDER_VIEW_HOST_CHANGED:
Remove(web_contents);
Add(web_contents);
break;
diff --git a/chrome/browser/ui/cocoa/apps/native_app_window_cocoa.h b/chrome/browser/ui/cocoa/apps/native_app_window_cocoa.h
index a8108a7..d4621dd 100644
--- a/chrome/browser/ui/cocoa/apps/native_app_window_cocoa.h
+++ b/chrome/browser/ui/cocoa/apps/native_app_window_cocoa.h
@@ -13,7 +13,7 @@
#include "base/mac/scoped_nsobject.h"
#include "base/memory/scoped_ptr.h"
#import "chrome/browser/ui/cocoa/browser_command_executor.h"
-#include "content/public/browser/notification_registrar.h"
+#include "content/public/browser/web_contents_observer.h"
#include "extensions/common/draggable_region.h"
#include "ui/gfx/rect.h"
@@ -41,7 +41,8 @@ class SkRegion;
@end
// Cocoa bridge to AppWindow.
-class NativeAppWindowCocoa : public apps::NativeAppWindow {
+class NativeAppWindowCocoa : public apps::NativeAppWindow,
+ public content::WebContentsObserver {
public:
NativeAppWindowCocoa(apps::ShellWindow* shell_window,
const apps::ShellWindow::CreateParams& params);
@@ -122,9 +123,13 @@ class NativeAppWindowCocoa : public apps::NativeAppWindow {
const std::vector<extensions::DraggableRegion>& regions) OVERRIDE;
virtual void HandleKeyboardEvent(
const content::NativeWebKeyboardEvent& event) OVERRIDE;
- virtual void RenderViewHostChanged() OVERRIDE;
virtual gfx::Insets GetFrameInsets() const OVERRIDE;
+ // WebContentsObserver implementation.
+ virtual void RenderViewHostChanged(
+ content::RenderViewHost* old_host,
+ content::RenderViewHost* new_host) OVERRIDE;
+
// These are used to simulate Mac-style hide/show. Since windows can be hidden
// and shown using the app.window API, this sets is_hidden_with_app_ to
// differentiate the reason a window was hidden.
diff --git a/chrome/browser/ui/cocoa/apps/native_app_window_cocoa.mm b/chrome/browser/ui/cocoa/apps/native_app_window_cocoa.mm
index 6a5c58d..73d995a 100644
--- a/chrome/browser/ui/cocoa/apps/native_app_window_cocoa.mm
+++ b/chrome/browser/ui/cocoa/apps/native_app_window_cocoa.mm
@@ -16,8 +16,6 @@
#include "chrome/common/chrome_switches.h"
#include "chrome/common/extensions/extension.h"
#include "content/public/browser/native_web_keyboard_event.h"
-#include "content/public/browser/notification_source.h"
-#include "content/public/browser/notification_types.h"
#include "content/public/browser/render_widget_host_view.h"
#include "content/public/browser/web_contents.h"
#include "content/public/browser/web_contents_view.h"
@@ -257,13 +255,15 @@ NativeAppWindowCocoa::NativeAppWindowCocoa(
is_fullscreen_(false),
attention_request_id_(0),
use_system_drag_(true) {
+ Observe(web_contents());
+
// Flip coordinates based on the primary screen.
NSRect main_screen_rect = [[[NSScreen screens] objectAtIndex:0] frame];
NSRect cocoa_bounds = NSMakeRect(params.bounds.x(),
NSHeight(main_screen_rect) - params.bounds.y() - params.bounds.height(),
params.bounds.width(), params.bounds.height());
- // If coordinates are < 0, center window on primary screen
+ // If coordinates are < 0, center window on primary screen.
if (params.bounds.x() == INT_MIN) {
cocoa_bounds.origin.x =
floor((NSWidth(main_screen_rect) - NSWidth(cocoa_bounds)) / 2);
@@ -782,7 +782,9 @@ bool NativeAppWindowCocoa::IsAlwaysOnTop() const {
return false;
}
-void NativeAppWindowCocoa::RenderViewHostChanged() {
+void NativeAppWindowCocoa::RenderViewHostChanged(
+ content::RenderViewHost* old_host,
+ content::RenderViewHost* new_host) {
web_contents()->GetView()->Focus();
}
diff --git a/chrome/browser/ui/gtk/apps/native_app_window_gtk.cc b/chrome/browser/ui/gtk/apps/native_app_window_gtk.cc
index 4819a02..aabb388 100644
--- a/chrome/browser/ui/gtk/apps/native_app_window_gtk.cc
+++ b/chrome/browser/ui/gtk/apps/native_app_window_gtk.cc
@@ -51,6 +51,8 @@ NativeAppWindowGtk::NativeAppWindowGtk(ShellWindow* shell_window,
frame_cursor_(NULL),
atom_cache_(base::MessagePumpGtk::GetDefaultXDisplay(), kAtomsToCache),
is_x_event_listened_(false) {
+ Observe(web_contents());
+
window_ = GTK_WINDOW(gtk_window_new(GTK_WINDOW_TOPLEVEL));
gfx::NativeView native_view =
@@ -340,7 +342,9 @@ bool NativeAppWindowGtk::IsAlwaysOnTop() const {
return false;
}
-void NativeAppWindowGtk::RenderViewHostChanged() {
+void NativeAppWindowGtk::RenderViewHostChanged(
+ content::RenderViewHost* old_host,
+ content::RenderViewHost* new_host) {
web_contents()->GetView()->Focus();
}
diff --git a/chrome/browser/ui/gtk/apps/native_app_window_gtk.h b/chrome/browser/ui/gtk/apps/native_app_window_gtk.h
index 1827416..30d5be9 100644
--- a/chrome/browser/ui/gtk/apps/native_app_window_gtk.h
+++ b/chrome/browser/ui/gtk/apps/native_app_window_gtk.h
@@ -12,6 +12,7 @@
#include "base/observer_list.h"
#include "base/timer/timer.h"
#include "chrome/browser/ui/gtk/extensions/extension_view_gtk.h"
+#include "content/public/browser/web_contents_observer.h"
#include "third_party/skia/include/core/SkRegion.h"
#include "ui/base/gtk/gtk_signal.h"
#include "ui/base/x/active_window_watcher_x_observer.h"
@@ -27,7 +28,8 @@ class Extension;
class NativeAppWindowGtk : public apps::NativeAppWindow,
public ExtensionViewGtk::Container,
- public ui::ActiveWindowWatcherXObserver {
+ public ui::ActiveWindowWatcherXObserver,
+ public content::WebContentsObserver {
public:
NativeAppWindowGtk(apps::ShellWindow* shell_window,
const apps::ShellWindow::CreateParams& params);
@@ -58,6 +60,11 @@ class NativeAppWindowGtk : public apps::NativeAppWindow,
// ActiveWindowWatcherXObserver implementation.
virtual void ActiveWindowChanged(GdkWindow* active_window) OVERRIDE;
+ // WebContentsObserver implementation.
+ virtual void RenderViewHostChanged(
+ content::RenderViewHost* old_host,
+ content::RenderViewHost* new_host) OVERRIDE;
+
private:
// NativeAppWindow implementation.
virtual void SetFullscreen(bool fullscreen) OVERRIDE;
@@ -69,7 +76,6 @@ class NativeAppWindowGtk : public apps::NativeAppWindow,
virtual void UpdateInputRegion(scoped_ptr<SkRegion> region) OVERRIDE;
virtual void UpdateDraggableRegions(
const std::vector<extensions::DraggableRegion>& regions) OVERRIDE;
- virtual void RenderViewHostChanged() OVERRIDE;
virtual gfx::Insets GetFrameInsets() const OVERRIDE;
virtual void HideWithApp() OVERRIDE;
virtual void ShowWithApp() OVERRIDE;
diff --git a/chrome/browser/ui/panels/panel.cc b/chrome/browser/ui/panels/panel.cc
index 4189284..2b21bc7 100644
--- a/chrome/browser/ui/panels/panel.cc
+++ b/chrome/browser/ui/panels/panel.cc
@@ -150,7 +150,7 @@ bool PanelExtensionWindowController::IsVisibleToExtension(
return extension->id() == panel_->extension_id();
}
-} // namespace internal
+} // namespace panel_internal
Panel::~Panel() {
DCHECK(!collection_);
@@ -431,7 +431,7 @@ void Panel::Observe(int type,
const content::NotificationSource& source,
const content::NotificationDetails& details) {
switch (type) {
- case content::NOTIFICATION_WEB_CONTENTS_SWAPPED:
+ case content::NOTIFICATION_RENDER_VIEW_HOST_CHANGED:
ConfigureAutoResize(content::Source<content::WebContents>(source).ptr());
break;
case chrome::NOTIFICATION_EXTENSION_UNLOADED:
@@ -582,7 +582,7 @@ void Panel::SetAutoResizable(bool resizable) {
EnableWebContentsAutoResize(web_contents);
} else {
if (web_contents) {
- registrar_.Remove(this, content::NOTIFICATION_WEB_CONTENTS_SWAPPED,
+ registrar_.Remove(this, content::NOTIFICATION_RENDER_VIEW_HOST_CHANGED,
content::Source<content::WebContents>(web_contents));
// NULL might be returned if the tab has not been added.
@@ -600,11 +600,11 @@ void Panel::EnableWebContentsAutoResize(content::WebContents* web_contents) {
// We also need to know when the render view host changes in order
// to turn on auto-resize notifications in the new render view host.
if (!registrar_.IsRegistered(
- this, content::NOTIFICATION_WEB_CONTENTS_SWAPPED,
+ this, content::NOTIFICATION_RENDER_VIEW_HOST_CHANGED,
content::Source<content::WebContents>(web_contents))) {
registrar_.Add(
this,
- content::NOTIFICATION_WEB_CONTENTS_SWAPPED,
+ content::NOTIFICATION_RENDER_VIEW_HOST_CHANGED,
content::Source<content::WebContents>(web_contents));
}
}
diff --git a/chrome/browser/ui/views/apps/native_app_window_views.cc b/chrome/browser/ui/views/apps/native_app_window_views.cc
index 6e0c449..6a07a7b 100644
--- a/chrome/browser/ui/views/apps/native_app_window_views.cc
+++ b/chrome/browser/ui/views/apps/native_app_window_views.cc
@@ -786,6 +786,8 @@ void NativeAppWindowViews::HandleKeyboardEvent(
GetFocusManager());
}
-void NativeAppWindowViews::RenderViewHostChanged() {
+void NativeAppWindowViews::RenderViewHostChanged(
+ content::RenderViewHost* old_host,
+ content::RenderViewHost* new_host) {
OnViewWasResized();
}
diff --git a/chrome/browser/ui/views/apps/native_app_window_views.h b/chrome/browser/ui/views/apps/native_app_window_views.h
index 9f4d969..359f835 100644
--- a/chrome/browser/ui/views/apps/native_app_window_views.h
+++ b/chrome/browser/ui/views/apps/native_app_window_views.h
@@ -118,6 +118,9 @@ class NativeAppWindowViews : public apps::NativeAppWindow,
// WebContentsObserver implementation.
virtual void RenderViewCreated(
content::RenderViewHost* render_view_host) OVERRIDE;
+ virtual void RenderViewHostChanged(
+ content::RenderViewHost* old_host,
+ content::RenderViewHost* new_host) OVERRIDE;
// views::View implementation.
virtual void Layout() OVERRIDE;
@@ -140,7 +143,6 @@ class NativeAppWindowViews : public apps::NativeAppWindow,
const std::vector<extensions::DraggableRegion>& regions) OVERRIDE;
virtual void HandleKeyboardEvent(
const content::NativeWebKeyboardEvent& event) OVERRIDE;
- virtual void RenderViewHostChanged() OVERRIDE;
virtual gfx::Insets GetFrameInsets() const OVERRIDE;
virtual void HideWithApp() OVERRIDE;
virtual void ShowWithApp() OVERRIDE;
diff --git a/content/browser/android/content_view_core_impl.cc b/content/browser/android/content_view_core_impl.cc
index 606343d..fbbf0d8 100644
--- a/content/browser/android/content_view_core_impl.cc
+++ b/content/browser/android/content_view_core_impl.cc
@@ -219,16 +219,13 @@ void ContentViewCoreImpl::InitWebContents() {
DCHECK(web_contents_);
notification_registrar_.Add(
this, NOTIFICATION_RENDER_VIEW_HOST_CHANGED,
- Source<NavigationController>(&web_contents_->GetController()));
+ Source<WebContents>(web_contents_));
notification_registrar_.Add(
this, NOTIFICATION_RENDERER_PROCESS_CREATED,
content::NotificationService::AllBrowserContextsAndSources());
notification_registrar_.Add(
this, NOTIFICATION_WEB_CONTENTS_CONNECTED,
Source<WebContents>(web_contents_));
- notification_registrar_.Add(
- this, NOTIFICATION_WEB_CONTENTS_SWAPPED,
- Source<WebContents>(web_contents_));
static_cast<WebContentsViewAndroid*>(web_contents_->GetView())->
SetContentViewCore(this);
@@ -289,13 +286,6 @@ void ContentViewCoreImpl::Observe(int type,
}
break;
}
- case NOTIFICATION_WEB_CONTENTS_SWAPPED: {
- JNIEnv* env = AttachCurrentThread();
- ScopedJavaLocalRef<jobject> obj = java_ref_.get(env);
- if (!obj.is_null()) {
- Java_ContentViewCore_onWebContentsSwapped(env, obj.obj());
- }
- }
}
}
diff --git a/content/browser/browser_plugin/browser_plugin_host_browsertest.cc b/content/browser/browser_plugin/browser_plugin_host_browsertest.cc
index 32feb26..771b77e 100644
--- a/content/browser/browser_plugin/browser_plugin_host_browsertest.cc
+++ b/content/browser/browser_plugin/browser_plugin_host_browsertest.cc
@@ -431,7 +431,7 @@ IN_PROC_BROWSER_TEST_F(BrowserPluginHostTest, EmbedderChangedAfterSwap) {
GURL test_https_url(https_server.GetURL(
"files/browser_plugin_title_change.html"));
content::WindowedNotificationObserver swap_observer(
- content::NOTIFICATION_WEB_CONTENTS_SWAPPED,
+ content::NOTIFICATION_RENDER_VIEW_HOST_CHANGED,
content::Source<WebContents>(test_embedder()->web_contents()));
NavigateToURL(shell(), test_https_url);
swap_observer.Wait();
diff --git a/content/browser/web_contents/render_view_host_manager.cc b/content/browser/web_contents/render_view_host_manager.cc
index f07729c..99f2662 100644
--- a/content/browser/web_contents/render_view_host_manager.cc
+++ b/content/browser/web_contents/render_view_host_manager.cc
@@ -165,15 +165,7 @@ RenderViewHostImpl* RenderViewHostManager::Navigate(
} else {
// This is our primary renderer, notify here as we won't be calling
// CommitPending (which does the notify).
- RenderViewHost* null_rvh = NULL;
- std::pair<RenderViewHost*, RenderViewHost*> details =
- std::make_pair(null_rvh, render_view_host_);
- NotificationService::current()->Notify(
- NOTIFICATION_RENDER_VIEW_HOST_CHANGED,
- Source<NavigationController>(
- &delegate_->GetControllerForRenderManager()),
- Details<std::pair<RenderViewHost*, RenderViewHost*> >(
- &details));
+ delegate_->NotifySwappedFromRenderManager(NULL, render_view_host_);
}
}
@@ -778,23 +770,15 @@ void RenderViewHostManager::CommitPending() {
else if (focus_render_view && render_view_host_->GetView())
RenderWidgetHostViewPort::FromRWHV(render_view_host_->GetView())->Focus();
- std::pair<RenderViewHost*, RenderViewHost*> details =
- std::make_pair(old_render_view_host, render_view_host_);
- NotificationService::current()->Notify(
- NOTIFICATION_RENDER_VIEW_HOST_CHANGED,
- Source<NavigationController>(
- &delegate_->GetControllerForRenderManager()),
- Details<std::pair<RenderViewHost*, RenderViewHost*> >(&details));
+ // Notify that we've swapped RenderViewHosts. We do this
+ // before shutting down the RVH so that we can clean up
+ // RendererResources related to the RVH first.
+ delegate_->NotifySwappedFromRenderManager(old_render_view_host,
+ render_view_host_);
// If the pending view was on the swapped out list, we can remove it.
swapped_out_hosts_.erase(render_view_host_->GetSiteInstance()->GetId());
- // Let the task manager know that we've swapped RenderViewHosts,
- // since it might need to update its process groupings. We do this
- // before shutting down the RVH so that we can clean up
- // RendererResources related to the RVH first.
- delegate_->NotifySwappedFromRenderManager(old_render_view_host);
-
// If there are no active RVHs in this SiteInstance, it means that
// this RVH was the last active one in the SiteInstance. Now that we
// know that all RVHs are swapped out, we can delete all the RVHs in
diff --git a/content/browser/web_contents/render_view_host_manager.h b/content/browser/web_contents/render_view_host_manager.h
index 8f73610..a7104ba 100644
--- a/content/browser/web_contents/render_view_host_manager.h
+++ b/content/browser/web_contents/render_view_host_manager.h
@@ -66,7 +66,7 @@ class CONTENT_EXPORT RenderViewHostManager
virtual void UpdateRenderViewSizeForRenderManager() = 0;
virtual void CancelModalDialogsForRenderManager() = 0;
virtual void NotifySwappedFromRenderManager(
- RenderViewHost* old_render_view_host) = 0;
+ RenderViewHost* old_host, RenderViewHost* new_host) = 0;
virtual NavigationControllerImpl&
GetControllerForRenderManager() = 0;
diff --git a/content/browser/web_contents/render_view_host_manager_unittest.cc b/content/browser/web_contents/render_view_host_manager_unittest.cc
index 7e071f1..17ac84b 100644
--- a/content/browser/web_contents/render_view_host_manager_unittest.cc
+++ b/content/browser/web_contents/render_view_host_manager_unittest.cc
@@ -584,9 +584,8 @@ TEST_F(RenderViewHostManagerTest, Navigate) {
scoped_ptr<TestWebContents> web_contents(
TestWebContents::Create(browser_context(), instance));
- notifications.ListenFor(
- NOTIFICATION_RENDER_VIEW_HOST_CHANGED,
- Source<NavigationController>(&web_contents->GetController()));
+ notifications.ListenFor(NOTIFICATION_RENDER_VIEW_HOST_CHANGED,
+ Source<WebContents>(web_contents.get()));
// Create.
RenderViewHostManager manager(web_contents.get(), web_contents.get(),
@@ -662,8 +661,8 @@ TEST_F(RenderViewHostManagerTest, Navigate) {
EXPECT_FALSE(manager.pending_render_view_host());
// We should observe a notification.
- EXPECT_TRUE(notifications.Check1AndReset(
- NOTIFICATION_RENDER_VIEW_HOST_CHANGED));
+ EXPECT_TRUE(
+ notifications.Check1AndReset(NOTIFICATION_RENDER_VIEW_HOST_CHANGED));
}
// Tests the Navigate function. In this unit test we verify that the Navigate
@@ -677,9 +676,8 @@ TEST_F(RenderViewHostManagerTest, NavigateWithEarlyReNavigation) {
scoped_ptr<TestWebContents> web_contents(
TestWebContents::Create(browser_context(), instance));
- notifications.ListenFor(
- NOTIFICATION_RENDER_VIEW_HOST_CHANGED,
- Source<NavigationController>(&web_contents->GetController()));
+ notifications.ListenFor(NOTIFICATION_RENDER_VIEW_HOST_CHANGED,
+ Source<WebContents>(web_contents.get()));
// Create.
RenderViewHostManager manager(web_contents.get(), web_contents.get(),
@@ -700,8 +698,8 @@ TEST_F(RenderViewHostManagerTest, NavigateWithEarlyReNavigation) {
EXPECT_FALSE(manager.pending_render_view_host());
// We should observe a notification.
- EXPECT_TRUE(notifications.Check1AndReset(
- NOTIFICATION_RENDER_VIEW_HOST_CHANGED));
+ EXPECT_TRUE(
+ notifications.Check1AndReset(NOTIFICATION_RENDER_VIEW_HOST_CHANGED));
notifications.Reset();
// Commit.
@@ -814,8 +812,8 @@ TEST_F(RenderViewHostManagerTest, NavigateWithEarlyReNavigation) {
EXPECT_FALSE(manager.pending_render_view_host());
// We should observe a notification.
- EXPECT_TRUE(notifications.Check1AndReset(
- NOTIFICATION_RENDER_VIEW_HOST_CHANGED));
+ EXPECT_TRUE(
+ notifications.Check1AndReset(NOTIFICATION_RENDER_VIEW_HOST_CHANGED));
}
// Tests WebUI creation.
@@ -1242,9 +1240,8 @@ TEST_F(RenderViewHostManagerTest, NavigateWithEarlyClose) {
scoped_ptr<TestWebContents> web_contents(
TestWebContents::Create(browser_context(), instance));
web_contents->SetDelegate(&delegate);
- notifications.ListenFor(
- NOTIFICATION_RENDER_VIEW_HOST_CHANGED,
- Source<NavigationController>(&web_contents->GetController()));
+ notifications.ListenFor(NOTIFICATION_RENDER_VIEW_HOST_CHANGED,
+ Source<WebContents>(web_contents.get()));
// Create.
RenderViewHostManager manager(web_contents.get(), web_contents.get(),
@@ -1265,8 +1262,8 @@ TEST_F(RenderViewHostManagerTest, NavigateWithEarlyClose) {
EXPECT_FALSE(manager.pending_render_view_host());
// We should observe a notification.
- EXPECT_TRUE(notifications.Check1AndReset(
- NOTIFICATION_RENDER_VIEW_HOST_CHANGED));
+ EXPECT_TRUE(
+ notifications.Check1AndReset(NOTIFICATION_RENDER_VIEW_HOST_CHANGED));
notifications.Reset();
// Commit.
diff --git a/content/browser/web_contents/web_contents_impl.cc b/content/browser/web_contents/web_contents_impl.cc
index a5eedd1..e4f4a8d 100644
--- a/content/browser/web_contents/web_contents_impl.cc
+++ b/content/browser/web_contents/web_contents_impl.cc
@@ -2866,19 +2866,22 @@ bool WebContentsImpl::UpdateTitleForEntry(NavigationEntryImpl* entry,
return true;
}
-void WebContentsImpl::NotifySwapped(RenderViewHost* old_render_view_host) {
+void WebContentsImpl::NotifySwapped(RenderViewHost* old_host,
+ RenderViewHost* new_host) {
// After sending out a swap notification, we need to send a disconnect
// notification so that clients that pick up a pointer to |this| can NULL the
// pointer. See Bug 1230284.
notify_disconnection_ = true;
FOR_EACH_OBSERVER(WebContentsObserver, observers_,
- RenderViewHostSwapped(old_render_view_host));
+ RenderViewHostChanged(old_host, new_host));
// TODO(avi): Remove. http://crbug.com/170921
+ std::pair<RenderViewHost*, RenderViewHost*> details =
+ std::make_pair(old_host, new_host);
NotificationService::current()->Notify(
- NOTIFICATION_WEB_CONTENTS_SWAPPED,
+ NOTIFICATION_RENDER_VIEW_HOST_CHANGED,
Source<WebContents>(this),
- Details<RenderViewHost>(old_render_view_host));
+ Details<std::pair<RenderViewHost*, RenderViewHost*> >(&details));
// Ensure that the associated embedder gets cleared after a RenderViewHost
// gets swapped, so we don't reuse the same embedder next time a
@@ -3680,18 +3683,18 @@ void WebContentsImpl::CancelModalDialogsForRenderManager() {
dialog_manager_->CancelActiveAndPendingDialogs(this);
}
-void WebContentsImpl::NotifySwappedFromRenderManager(RenderViewHost* rvh) {
- NotifySwapped(rvh);
+void WebContentsImpl::NotifySwappedFromRenderManager(RenderViewHost* old_host,
+ RenderViewHost* new_host) {
+ NotifySwapped(old_host, new_host);
// Make sure the visible RVH reflects the new delegate's preferences.
if (delegate_)
view_->SetOverscrollControllerEnabled(delegate_->CanOverscrollContent());
- view_->RenderViewSwappedIn(render_manager_.current_host());
+ view_->RenderViewSwappedIn(new_host);
FrameTreeNode* root = NULL;
- RenderViewHostImpl* new_rvh = static_cast<RenderViewHostImpl*>(
- render_manager_.current_host());
+ RenderViewHostImpl* new_rvh = static_cast<RenderViewHostImpl*>(new_host);
// We are doing a cross-site navigation and swapping processes. Since frame
// ids are unique to a process, we need to recreate the frame tree with the
diff --git a/content/browser/web_contents/web_contents_impl.h b/content/browser/web_contents/web_contents_impl.h
index c60aeba..0a44a31 100644
--- a/content/browser/web_contents/web_contents_impl.h
+++ b/content/browser/web_contents/web_contents_impl.h
@@ -495,7 +495,7 @@ class CONTENT_EXPORT WebContentsImpl
virtual void UpdateRenderViewSizeForRenderManager() OVERRIDE;
virtual void CancelModalDialogsForRenderManager() OVERRIDE;
virtual void NotifySwappedFromRenderManager(
- RenderViewHost* old_render_view_host) OVERRIDE;
+ RenderViewHost* old_host, RenderViewHost* new_host) OVERRIDE;
virtual int CreateOpenerRenderViewsForRenderManager(
SiteInstance* instance) OVERRIDE;
virtual NavigationControllerImpl&
@@ -745,7 +745,7 @@ class CONTENT_EXPORT WebContentsImpl
// Misc non-view stuff -------------------------------------------------------
// Helper functions for sending notifications.
- void NotifySwapped(RenderViewHost* old_render_view_host);
+ void NotifySwapped(RenderViewHost* old_host, RenderViewHost* new_host);
void NotifyDisconnected();
void NotifyNavigationEntryCommitted(const LoadCommittedDetails& load_details);
diff --git a/content/browser/web_contents/web_drag_source_win.cc b/content/browser/web_contents/web_drag_source_win.cc
index 53df4e8..77dc4c4 100644
--- a/content/browser/web_contents/web_drag_source_win.cc
+++ b/content/browser/web_contents/web_drag_source_win.cc
@@ -39,7 +39,7 @@ WebDragSource::WebDragSource(gfx::NativeWindow source_wnd,
web_contents_(static_cast<WebContentsImpl*>(web_contents)),
effect_(DROPEFFECT_NONE),
data_(NULL) {
- registrar_.Add(this, NOTIFICATION_WEB_CONTENTS_SWAPPED,
+ registrar_.Add(this, NOTIFICATION_RENDER_VIEW_HOST_CHANGED,
Source<WebContents>(web_contents));
registrar_.Add(this, NOTIFICATION_WEB_CONTENTS_DISCONNECTED,
Source<WebContents>(web_contents));
@@ -114,7 +114,7 @@ void WebDragSource::OnDragSourceMove() {
void WebDragSource::Observe(int type,
const NotificationSource& source,
const NotificationDetails& details) {
- if (type == NOTIFICATION_WEB_CONTENTS_SWAPPED) {
+ if (type == NOTIFICATION_RENDER_VIEW_HOST_CHANGED) {
// When the WebContents get swapped, our render view host goes away.
// That's OK, we can continue the drag, we just can't send messages back to
// our drag source.
diff --git a/content/public/android/java/src/org/chromium/content/browser/ContentViewCore.java b/content/public/android/java/src/org/chromium/content/browser/ContentViewCore.java
index 4af9cc5..6ed81ec 100644
--- a/content/public/android/java/src/org/chromium/content/browser/ContentViewCore.java
+++ b/content/public/android/java/src/org/chromium/content/browser/ContentViewCore.java
@@ -2559,17 +2559,13 @@ import java.util.Map;
// renderers for ContentViews loading in background do not retain the high priority.
ChildProcessLauncher.getBindingManager().removeInitialBinding(newPid);
mPid = newPid;
- }
- @SuppressWarnings("unused")
- @CalledByNative
- private void onWebContentsConnected() {
attachImeAdapter();
}
@SuppressWarnings("unused")
@CalledByNative
- private void onWebContentsSwapped() {
+ private void onWebContentsConnected() {
attachImeAdapter();
}
diff --git a/content/public/browser/notification_types.h b/content/public/browser/notification_types.h
index 549c871..c3b5f2e 100644
--- a/content/public/browser/notification_types.h
+++ b/content/public/browser/notification_types.h
@@ -119,12 +119,10 @@ enum NotificationType {
// This notification is sent when a WebContents swaps its render view host
// with another one, possibly changing processes. The source is a
- // Source<WebContents> with a pointer to the WebContents. A
- // NOTIFICATION_WEB_CONTENTS_DISCONNECTED notification is guaranteed before
- // the source pointer becomes junk. Details are the RenderViewHost that
- // has been replaced, or NULL if the old RVH was shut down.
- // DEPRECATED: Use WebContentsObserver::RenderViewHostSwapped()
- NOTIFICATION_WEB_CONTENTS_SWAPPED,
+ // Source<WebContents> with a pointer to the WebContents, details is a
+ // std::pair::<old RenderViewHost, new RenderViewHost>.
+ // DEPRECATED: Use WebContentsObserver::RenderViewHostChanged()
+ NOTIFICATION_RENDER_VIEW_HOST_CHANGED,
// This message is sent after a WebContents is disconnected from the
// renderer process. The source is a Source<WebContents> with a pointer to
@@ -183,12 +181,6 @@ enum NotificationType {
// hung view, and no details are expected.
NOTIFICATION_RENDERER_PROCESS_HANG,
- // This is sent to notify that the RenderViewHost displayed in a WebContents
- // has changed. Source is the NavigationController for which the change
- // happened, details is a
- // std::pair::<old RenderViewHost, new RenderViewHost>).
- NOTIFICATION_RENDER_VIEW_HOST_CHANGED,
-
// This is sent when a RenderWidgetHost is being destroyed. The source is
// the RenderWidgetHost, the details are not used.
NOTIFICATION_RENDER_WIDGET_HOST_DESTROYED,
diff --git a/content/public/browser/web_contents_observer.h b/content/public/browser/web_contents_observer.h
index 28c6766..fb0523c 100644
--- a/content/public/browser/web_contents_observer.h
+++ b/content/public/browser/web_contents_observer.h
@@ -70,7 +70,8 @@ class CONTENT_EXPORT WebContentsObserver : public IPC::Listener,
// another one, possibly changing processes. The RenderViewHost that has
// been replaced is in |old_render_view_host|, which is NULL if the old RVH
// was shut down.
- virtual void RenderViewHostSwapped(RenderViewHost* old_render_view_host) {}
+ virtual void RenderViewHostChanged(RenderViewHost* old_host,
+ RenderViewHost* new_host) {}
// This method is invoked after the WebContents decided which RenderViewHost
// to use for the next navigation, but before the navigation starts.
diff --git a/ui/views/controls/webview/webview.cc b/ui/views/controls/webview/webview.cc
index 9169ac0..7d12655 100644
--- a/ui/views/controls/webview/webview.cc
+++ b/ui/views/controls/webview/webview.cc
@@ -262,8 +262,7 @@ void WebView::AttachWebContents() {
registrar_.Add(
this,
content::NOTIFICATION_RENDER_VIEW_HOST_CHANGED,
- content::Source<content::NavigationController>(
- &web_contents_->GetController()));
+ content::Source<content::WebContents>(web_contents_));
registrar_.Add(
this,
content::NOTIFICATION_WEB_CONTENTS_DESTROYED,