Chromium Code Reviews
chromiumcodereview-hr@appspot.gserviceaccount.com (chromiumcodereview-hr) | Please choose your nickname with Settings | Help | Chromium Project | Gerrit Changes | Sign out
(227)

Unified Diff: content/shell/shell.cc

Issue 14651029: content: Remove usage of NOTIFICATION_WEB_CONTENTS_DESTROYED from content (Closed) Base URL: svn://svn.chromium.org/chrome/trunk/src
Patch Set: Created 7 years, 7 months ago
Use n/p to move between diff chunks; N/P to move between comments. Draft comments are only viewable by you.
Jump to:
View side-by-side diff with in-line comments
Download patch
Index: content/shell/shell.cc
diff --git a/content/shell/shell.cc b/content/shell/shell.cc
index ff14a7c6af0501a95839aa0d850cbbf0ee1a1737..7cf568e0676fd148a362863bc29ea6091ea1d6b0 100644
--- a/content/shell/shell.cc
+++ b/content/shell/shell.cc
@@ -43,7 +43,8 @@ base::Callback<void(Shell*)> Shell::shell_created_callback_;
bool Shell::quit_message_loop_ = true;
Shell::Shell(WebContents* web_contents)
- : devtools_frontend_(NULL),
+ : WebContentsObserver(NULL), // Watch DevTools WebContents, not the above.
+ devtools_frontend_(NULL),
is_fullscreen_(false),
window_(NULL),
url_edit_view_(NULL),
@@ -192,19 +193,14 @@ void Shell::ShowDevTools() {
return;
}
devtools_frontend_ = ShellDevToolsFrontend::Show(web_contents());
- registrar_.Add(this,
- NOTIFICATION_WEB_CONTENTS_DESTROYED,
- Source<WebContents>(
- devtools_frontend_->frontend_shell()->web_contents()));
+ WebContentsObserver::Observe(
+ devtools_frontend_->frontend_shell()->web_contents());
}
void Shell::CloseDevTools() {
if (!devtools_frontend_)
return;
- registrar_.Remove(this,
- NOTIFICATION_WEB_CONTENTS_DESTROYED,
- Source<WebContents>(
- devtools_frontend_->frontend_shell()->web_contents()));
+ WebContentsObserver::Observe(NULL);
devtools_frontend_->Close();
devtools_frontend_ = NULL;
}
@@ -310,6 +306,11 @@ void Shell::DeactivateContents(WebContents* contents) {
contents->GetRenderViewHost()->Blur();
}
+void Shell::WebContentsDestroyed(WebContents* web_contents) {
+ devtools_frontend_ = NULL;
+ WebContentsObserver::Observe(NULL);
+}
+
void Shell::Observe(int type,
const NotificationSource& source,
const NotificationDetails& details) {
@@ -321,9 +322,6 @@ void Shell::Observe(int type,
string16 text = title->first->GetTitle();
PlatformSetTitle(text);
}
- } else if (type == NOTIFICATION_WEB_CONTENTS_DESTROYED) {
- devtools_frontend_ = NULL;
- registrar_.Remove(this, NOTIFICATION_WEB_CONTENTS_DESTROYED, source);
} else {
NOTREACHED();
}

Powered by Google App Engine
This is Rietveld 408576698