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

Side by Side Diff: chrome/browser/ui/sad_tab_observer.cc

Issue 9030010: Move most of the remaining users of WebContentsObserver::tab_contents() to use web_contents(). (Closed) Base URL: svn://chrome-svn/chrome/trunk/src/
Patch Set: '' Created 8 years, 12 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
« no previous file with comments | « chrome/browser/ui/prefs/prefs_tab_helper.cc ('k') | chrome/browser/ui/snapshot_tab_helper.cc » ('j') | no next file with comments »
Toggle Intra-line Diffs ('i') | Expand Comments ('e') | Collapse Comments ('c') | Show Comments Hide Comments ('s')
OLDNEW
1 // Copyright (c) 2011 The Chromium Authors. All rights reserved. 1 // Copyright (c) 2011 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 "chrome/browser/ui/sad_tab_observer.h" 5 #include "chrome/browser/ui/sad_tab_observer.h"
6 6
7 #include "chrome/browser/browser_shutdown.h" 7 #include "chrome/browser/browser_shutdown.h"
8 #include "content/browser/tab_contents/tab_contents.h" 8 #include "content/browser/tab_contents/tab_contents.h"
9 #include "content/browser/tab_contents/tab_contents_view.h" 9 #include "content/browser/tab_contents/tab_contents_view.h"
10 #include "content/public/browser/notification_source.h" 10 #include "content/public/browser/notification_source.h"
(...skipping 21 matching lines...) Expand all
32 // Only show the sad tab if we're not in browser shutdown, so that TabContents 32 // Only show the sad tab if we're not in browser shutdown, so that TabContents
33 // objects that are not in a browser (e.g., HTML dialogs) and thus are 33 // objects that are not in a browser (e.g., HTML dialogs) and thus are
34 // visible do not flash a sad tab page. 34 // visible do not flash a sad tab page.
35 if (browser_shutdown::GetShutdownType() != browser_shutdown::NOT_VALID) 35 if (browser_shutdown::GetShutdownType() != browser_shutdown::NOT_VALID)
36 return; 36 return;
37 37
38 if (HasSadTab()) 38 if (HasSadTab())
39 return; 39 return;
40 40
41 gfx::NativeView view = AcquireSadTab(status); 41 gfx::NativeView view = AcquireSadTab(status);
42 tab_contents()->GetView()->InstallOverlayView(view); 42 web_contents()->GetView()->InstallOverlayView(view);
43 } 43 }
44 44
45 void SadTabObserver::Observe(int type, 45 void SadTabObserver::Observe(int type,
46 const content::NotificationSource& source, 46 const content::NotificationSource& source,
47 const content::NotificationDetails& details) { 47 const content::NotificationDetails& details) {
48 switch (type) { 48 switch (type) {
49 case content::NOTIFICATION_TAB_CONTENTS_CONNECTED: 49 case content::NOTIFICATION_TAB_CONTENTS_CONNECTED:
50 if (HasSadTab()) { 50 if (HasSadTab()) {
51 tab_contents()->GetView()->RemoveOverlayView(); 51 web_contents()->GetView()->RemoveOverlayView();
52 ReleaseSadTab(); 52 ReleaseSadTab();
53 } 53 }
54 break; 54 break;
55 55
56 default: 56 default:
57 NOTREACHED() << "Got a notification we didn't register for."; 57 NOTREACHED() << "Got a notification we didn't register for.";
58 } 58 }
59 } 59 }
60 60
61 gfx::NativeView SadTabObserver::AcquireSadTab(base::TerminationStatus status) { 61 gfx::NativeView SadTabObserver::AcquireSadTab(base::TerminationStatus status) {
62 #if defined(OS_MACOSX) 62 #if defined(OS_MACOSX)
63 sad_tab_.reset( 63 sad_tab_.reset(
64 sad_tab_controller_mac::CreateSadTabController(tab_contents())); 64 sad_tab_controller_mac::CreateSadTabController(tab_contents()));
65 return sad_tab_controller_mac::GetViewOfSadTabController(sad_tab_.get()); 65 return sad_tab_controller_mac::GetViewOfSadTabController(sad_tab_.get());
66 #elif defined(TOOLKIT_VIEWS) 66 #elif defined(TOOLKIT_VIEWS)
67 SadTabView::Kind kind = 67 SadTabView::Kind kind =
68 status == base::TERMINATION_STATUS_PROCESS_WAS_KILLED ? 68 status == base::TERMINATION_STATUS_PROCESS_WAS_KILLED ?
69 SadTabView::KILLED : SadTabView::CRASHED; 69 SadTabView::KILLED : SadTabView::CRASHED;
70 views::Widget::InitParams sad_tab_params( 70 views::Widget::InitParams sad_tab_params(
71 views::Widget::InitParams::TYPE_CONTROL); 71 views::Widget::InitParams::TYPE_CONTROL);
72 // It is not possible to create a native_widget_win that has no parent in 72 // It is not possible to create a native_widget_win that has no parent in
73 // and later re-parent it. 73 // and later re-parent it.
74 // TODO(avi): This is a cheat. Can this be made cleaner? 74 // TODO(avi): This is a cheat. Can this be made cleaner?
75 sad_tab_params.parent_widget = 75 sad_tab_params.parent_widget =
76 static_cast<TabContentsViewViews*>(tab_contents()->GetView()); 76 static_cast<TabContentsViewViews*>(web_contents()->GetView());
77 sad_tab_params.ownership = 77 sad_tab_params.ownership =
78 views::Widget::InitParams::WIDGET_OWNS_NATIVE_WIDGET; 78 views::Widget::InitParams::WIDGET_OWNS_NATIVE_WIDGET;
79 sad_tab_.reset(new views::Widget); 79 sad_tab_.reset(new views::Widget);
80 sad_tab_->Init(sad_tab_params); 80 sad_tab_->Init(sad_tab_params);
81 sad_tab_->SetContentsView(new SadTabView(tab_contents(), kind)); 81 sad_tab_->SetContentsView(new SadTabView(web_contents(), kind));
82 return sad_tab_->GetNativeView(); 82 return sad_tab_->GetNativeView();
83 #elif defined(TOOLKIT_GTK) 83 #elif defined(TOOLKIT_GTK)
84 sad_tab_.reset(new SadTabGtk( 84 sad_tab_.reset(new SadTabGtk(
85 tab_contents(), 85 tab_contents(),
86 status == base::TERMINATION_STATUS_PROCESS_WAS_KILLED 86 status == base::TERMINATION_STATUS_PROCESS_WAS_KILLED
87 ? SadTabGtk::KILLED 87 ? SadTabGtk::KILLED
88 : SadTabGtk::CRASHED)); 88 : SadTabGtk::CRASHED));
89 return sad_tab_->widget(); 89 return sad_tab_->widget();
90 #else 90 #else
91 #error Unknown platform 91 #error Unknown platform
92 #endif 92 #endif
93 } 93 }
94 94
95 void SadTabObserver::ReleaseSadTab() { 95 void SadTabObserver::ReleaseSadTab() {
96 sad_tab_.reset(); 96 sad_tab_.reset();
97 } 97 }
98 98
99 bool SadTabObserver::HasSadTab() { 99 bool SadTabObserver::HasSadTab() {
100 return sad_tab_.get() != NULL; 100 return sad_tab_.get() != NULL;
101 } 101 }
OLDNEW
« no previous file with comments | « chrome/browser/ui/prefs/prefs_tab_helper.cc ('k') | chrome/browser/ui/snapshot_tab_helper.cc » ('j') | no next file with comments »

Powered by Google App Engine
This is Rietveld 408576698