Index: chrome/browser/ui/panels/panel.cc |
diff --git a/chrome/browser/ui/panels/panel.cc b/chrome/browser/ui/panels/panel.cc |
index 949c612a845b03667f95e7eda74920108d6feaf2..72c38f335bb97e1accc3c68d469a6a8f69c8ec38 100644 |
--- a/chrome/browser/ui/panels/panel.cc |
+++ b/chrome/browser/ui/panels/panel.cc |
@@ -437,9 +437,6 @@ void Panel::Observe(int type, |
const content::NotificationSource& source, |
const content::NotificationDetails& details) { |
switch (type) { |
- case content::NOTIFICATION_RENDER_VIEW_HOST_CHANGED: |
- ConfigureAutoResize(content::Source<content::WebContents>(source).ptr()); |
- break; |
case chrome::NOTIFICATION_APP_TERMINATING: |
Close(); |
break; |
@@ -448,6 +445,11 @@ void Panel::Observe(int type, |
} |
} |
+void Panel::RenderViewHostChanged(content::RenderViewHost* old_host, |
+ content::RenderViewHost* new_host) { |
+ ConfigureAutoResize(web_contents()); |
+} |
+ |
void Panel::OnExtensionUnloaded( |
content::BrowserContext* browser_context, |
const extensions::Extension* extension, |
@@ -593,8 +595,7 @@ void Panel::SetAutoResizable(bool resizable) { |
EnableWebContentsAutoResize(web_contents); |
} else { |
if (web_contents) { |
- registrar_.Remove(this, content::NOTIFICATION_RENDER_VIEW_HOST_CHANGED, |
- content::Source<content::WebContents>(web_contents)); |
+ content::WebContentsObserver::Observe(nullptr); |
// NULL might be returned if the tab has not been added. |
RenderViewHost* render_view_host = web_contents->GetRenderViewHost(); |
@@ -610,14 +611,7 @@ 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_RENDER_VIEW_HOST_CHANGED, |
- content::Source<content::WebContents>(web_contents))) { |
- registrar_.Add( |
- this, |
- content::NOTIFICATION_RENDER_VIEW_HOST_CHANGED, |
- content::Source<content::WebContents>(web_contents)); |
- } |
+ content::WebContentsObserver::Observe(web_contents); |
} |
void Panel::OnContentsAutoResized(const gfx::Size& new_content_size) { |
@@ -803,7 +797,8 @@ Panel::Panel(Profile* profile, |
const std::string& app_name, |
const gfx::Size& min_size, |
const gfx::Size& max_size) |
- : app_name_(app_name), |
+ : content::WebContentsObserver(), |
+ app_name_(app_name), |
profile_(profile), |
collection_(NULL), |
initialized_(false), |