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

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: fix typo, rebase 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
« no previous file with comments | « content/shell/shell.h ('k') | content/test/test_web_contents.cc » ('j') | no next file with comments »
Expand Comments ('e') | Collapse Comments ('c') | Show Comments Hide Comments ('s')
Index: content/shell/shell.cc
diff --git a/content/shell/shell.cc b/content/shell/shell.cc
index ff14a7c6af0501a95839aa0d850cbbf0ee1a1737..4911043f18ac090811ef6432a65557735a24b890 100644
--- a/content/shell/shell.cc
+++ b/content/shell/shell.cc
@@ -20,6 +20,7 @@
#include "content/public/browser/notification_types.h"
#include "content/public/browser/render_view_host.h"
#include "content/public/browser/web_contents.h"
+#include "content/public/browser/web_contents_observer.h"
#include "content/public/browser/web_contents_view.h"
#include "content/public/common/renderer_preferences.h"
#include "content/shell/common/shell_messages.h"
@@ -42,6 +43,24 @@ base::Callback<void(Shell*)> Shell::shell_created_callback_;
bool Shell::quit_message_loop_ = true;
+class Shell::DevToolsWebContentsObserver : public WebContentsObserver {
+ public:
+ DevToolsWebContentsObserver(Shell* shell, WebContents* web_contents)
+ : WebContentsObserver(web_contents),
+ shell_(shell) {
+ }
+
+ // WebContentsObserver
+ virtual void WebContentsDestroyed(WebContents* web_contents) OVERRIDE {
+ shell_->OnDevToolsWebContentsDestroyed();
+ }
+
+ private:
+ Shell* shell_;
+
+ DISALLOW_COPY_AND_ASSIGN(DevToolsWebContentsObserver);
+};
+
Shell::Shell(WebContents* web_contents)
: devtools_frontend_(NULL),
is_fullscreen_(false),
@@ -192,19 +211,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()));
+ devtools_observer_.reset(new DevToolsWebContentsObserver(
+ this, 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()));
+ devtools_observer_.reset();
devtools_frontend_->Close();
devtools_frontend_ = NULL;
}
@@ -321,12 +335,14 @@ 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();
}
}
+void Shell::OnDevToolsWebContentsDestroyed() {
+ devtools_observer_.reset();
+ devtools_frontend_ = NULL;
+}
+
} // namespace content
« no previous file with comments | « content/shell/shell.h ('k') | content/test/test_web_contents.cc » ('j') | no next file with comments »

Powered by Google App Engine
This is Rietveld 408576698