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

Side by Side 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 unified diff | Download patch | Annotate | Revision Log
OLDNEW
1 // Copyright (c) 2012 The Chromium Authors. All rights reserved. 1 // Copyright (c) 2012 The Chromium Authors. All rights reserved.
2 // Use of this source code is governed by a BSD-style license that can be 2 // Use of this source code is governed by a BSD-style license that can be
3 // found in the LICENSE file. 3 // found in the LICENSE file.
4 4
5 #include "content/shell/shell.h" 5 #include "content/shell/shell.h"
6 6
7 #include "base/auto_reset.h" 7 #include "base/auto_reset.h"
8 #include "base/command_line.h" 8 #include "base/command_line.h"
9 #include "base/message_loop.h" 9 #include "base/message_loop.h"
10 #include "base/path_service.h" 10 #include "base/path_service.h"
(...skipping 25 matching lines...) Expand all
36 static const int kTestWindowHeight = 600; 36 static const int kTestWindowHeight = 600;
37 37
38 namespace content { 38 namespace content {
39 39
40 std::vector<Shell*> Shell::windows_; 40 std::vector<Shell*> Shell::windows_;
41 base::Callback<void(Shell*)> Shell::shell_created_callback_; 41 base::Callback<void(Shell*)> Shell::shell_created_callback_;
42 42
43 bool Shell::quit_message_loop_ = true; 43 bool Shell::quit_message_loop_ = true;
44 44
45 Shell::Shell(WebContents* web_contents) 45 Shell::Shell(WebContents* web_contents)
46 : devtools_frontend_(NULL), 46 : WebContentsObserver(NULL), // Watch DevTools WebContents, not the above.
47 devtools_frontend_(NULL),
47 is_fullscreen_(false), 48 is_fullscreen_(false),
48 window_(NULL), 49 window_(NULL),
49 url_edit_view_(NULL), 50 url_edit_view_(NULL),
50 #if defined(OS_WIN) && !defined(USE_AURA) 51 #if defined(OS_WIN) && !defined(USE_AURA)
51 default_edit_wnd_proc_(0), 52 default_edit_wnd_proc_(0),
52 #endif 53 #endif
53 headless_(false) { 54 headless_(false) {
54 const CommandLine& command_line = *CommandLine::ForCurrentProcess(); 55 const CommandLine& command_line = *CommandLine::ForCurrentProcess();
55 if (command_line.HasSwitch(switches::kDumpRenderTree) && 56 if (command_line.HasSwitch(switches::kDumpRenderTree) &&
56 !command_line.HasSwitch(switches::kDisableHeadlessForLayoutTests)) { 57 !command_line.HasSwitch(switches::kDisableHeadlessForLayoutTests)) {
(...skipping 128 matching lines...) Expand 10 before | Expand all | Expand 10 after
185 PlatformEnableUIControl(FORWARD_BUTTON, current_index < max_index); 186 PlatformEnableUIControl(FORWARD_BUTTON, current_index < max_index);
186 PlatformEnableUIControl(STOP_BUTTON, web_contents_->IsLoading()); 187 PlatformEnableUIControl(STOP_BUTTON, web_contents_->IsLoading());
187 } 188 }
188 189
189 void Shell::ShowDevTools() { 190 void Shell::ShowDevTools() {
190 if (devtools_frontend_) { 191 if (devtools_frontend_) {
191 devtools_frontend_->Focus(); 192 devtools_frontend_->Focus();
192 return; 193 return;
193 } 194 }
194 devtools_frontend_ = ShellDevToolsFrontend::Show(web_contents()); 195 devtools_frontend_ = ShellDevToolsFrontend::Show(web_contents());
195 registrar_.Add(this, 196 WebContentsObserver::Observe(
196 NOTIFICATION_WEB_CONTENTS_DESTROYED, 197 devtools_frontend_->frontend_shell()->web_contents());
197 Source<WebContents>(
198 devtools_frontend_->frontend_shell()->web_contents()));
199 } 198 }
200 199
201 void Shell::CloseDevTools() { 200 void Shell::CloseDevTools() {
202 if (!devtools_frontend_) 201 if (!devtools_frontend_)
203 return; 202 return;
204 registrar_.Remove(this, 203 WebContentsObserver::Observe(NULL);
205 NOTIFICATION_WEB_CONTENTS_DESTROYED,
206 Source<WebContents>(
207 devtools_frontend_->frontend_shell()->web_contents()));
208 devtools_frontend_->Close(); 204 devtools_frontend_->Close();
209 devtools_frontend_ = NULL; 205 devtools_frontend_ = NULL;
210 } 206 }
211 207
212 gfx::NativeView Shell::GetContentView() { 208 gfx::NativeView Shell::GetContentView() {
213 if (!web_contents_) 209 if (!web_contents_)
214 return NULL; 210 return NULL;
215 return web_contents_->GetView()->GetNativeView(); 211 return web_contents_->GetView()->GetNativeView();
216 } 212 }
217 213
(...skipping 85 matching lines...) Expand 10 before | Expand all | Expand 10 after
303 } 299 }
304 300
305 void Shell::ActivateContents(WebContents* contents) { 301 void Shell::ActivateContents(WebContents* contents) {
306 contents->GetRenderViewHost()->Focus(); 302 contents->GetRenderViewHost()->Focus();
307 } 303 }
308 304
309 void Shell::DeactivateContents(WebContents* contents) { 305 void Shell::DeactivateContents(WebContents* contents) {
310 contents->GetRenderViewHost()->Blur(); 306 contents->GetRenderViewHost()->Blur();
311 } 307 }
312 308
309 void Shell::WebContentsDestroyed(WebContents* web_contents) {
310 devtools_frontend_ = NULL;
311 WebContentsObserver::Observe(NULL);
312 }
313
313 void Shell::Observe(int type, 314 void Shell::Observe(int type,
314 const NotificationSource& source, 315 const NotificationSource& source,
315 const NotificationDetails& details) { 316 const NotificationDetails& details) {
316 if (type == NOTIFICATION_WEB_CONTENTS_TITLE_UPDATED) { 317 if (type == NOTIFICATION_WEB_CONTENTS_TITLE_UPDATED) {
317 std::pair<NavigationEntry*, bool>* title = 318 std::pair<NavigationEntry*, bool>* title =
318 Details<std::pair<NavigationEntry*, bool> >(details).ptr(); 319 Details<std::pair<NavigationEntry*, bool> >(details).ptr();
319 320
320 if (title->first) { 321 if (title->first) {
321 string16 text = title->first->GetTitle(); 322 string16 text = title->first->GetTitle();
322 PlatformSetTitle(text); 323 PlatformSetTitle(text);
323 } 324 }
324 } else if (type == NOTIFICATION_WEB_CONTENTS_DESTROYED) {
325 devtools_frontend_ = NULL;
326 registrar_.Remove(this, NOTIFICATION_WEB_CONTENTS_DESTROYED, source);
327 } else { 325 } else {
328 NOTREACHED(); 326 NOTREACHED();
329 } 327 }
330 } 328 }
331 329
332 } // namespace content 330 } // namespace content
OLDNEW

Powered by Google App Engine
This is Rietveld 408576698