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

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

Issue 9030032: Get rid of a bunch of tab_contents.h includes from chrome. These are all trivial changes to use W... (Closed) Base URL: svn://chrome-svn/chrome/trunk/src/
Patch Set: fix cros Created 8 years, 11 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) 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"
11 #include "content/public/browser/notification_types.h" 11 #include "content/public/browser/notification_types.h"
12 12
13 #if defined(OS_MACOSX) 13 #if defined(OS_MACOSX)
14 #include "chrome/browser/ui/cocoa/tab_contents/sad_tab_controller.h" 14 #include "chrome/browser/ui/cocoa/tab_contents/sad_tab_controller.h"
15 #elif defined(TOOLKIT_VIEWS) 15 #elif defined(TOOLKIT_VIEWS)
16 #include "chrome/browser/ui/views/sad_tab_view.h" 16 #include "chrome/browser/ui/views/sad_tab_view.h"
17 #include "chrome/browser/ui/views/tab_contents/tab_contents_view_views.h" 17 #include "chrome/browser/ui/views/tab_contents/tab_contents_view_views.h"
18 #elif defined(TOOLKIT_GTK) 18 #elif defined(TOOLKIT_GTK)
19 #include "chrome/browser/ui/gtk/sad_tab_gtk.h" 19 #include "chrome/browser/ui/gtk/sad_tab_gtk.h"
20 #endif 20 #endif
21 21
22 using content::WebContents;
23
22 SadTabObserver::SadTabObserver(TabContents* tab_contents) 24 SadTabObserver::SadTabObserver(TabContents* tab_contents)
23 : content::WebContentsObserver(tab_contents) { 25 : content::WebContentsObserver(tab_contents) {
24 registrar_.Add(this, content::NOTIFICATION_TAB_CONTENTS_CONNECTED, 26 registrar_.Add(this, content::NOTIFICATION_WEB_CONTENTS_CONNECTED,
25 content::Source<TabContents>(tab_contents)); 27 content::Source<WebContents>(tab_contents));
26 } 28 }
27 29
28 SadTabObserver::~SadTabObserver() { 30 SadTabObserver::~SadTabObserver() {
29 } 31 }
30 32
31 void SadTabObserver::RenderViewGone(base::TerminationStatus status) { 33 void SadTabObserver::RenderViewGone(base::TerminationStatus status) {
32 // Only show the sad tab if we're not in browser shutdown, so that TabContents 34 // 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 35 // objects that are not in a browser (e.g., HTML dialogs) and thus are
34 // visible do not flash a sad tab page. 36 // visible do not flash a sad tab page.
35 if (browser_shutdown::GetShutdownType() != browser_shutdown::NOT_VALID) 37 if (browser_shutdown::GetShutdownType() != browser_shutdown::NOT_VALID)
36 return; 38 return;
37 39
38 if (HasSadTab()) 40 if (HasSadTab())
39 return; 41 return;
40 42
41 gfx::NativeView view = AcquireSadTab(status); 43 gfx::NativeView view = AcquireSadTab(status);
42 web_contents()->GetView()->InstallOverlayView(view); 44 web_contents()->GetView()->InstallOverlayView(view);
43 } 45 }
44 46
45 void SadTabObserver::Observe(int type, 47 void SadTabObserver::Observe(int type,
46 const content::NotificationSource& source, 48 const content::NotificationSource& source,
47 const content::NotificationDetails& details) { 49 const content::NotificationDetails& details) {
48 switch (type) { 50 switch (type) {
49 case content::NOTIFICATION_TAB_CONTENTS_CONNECTED: 51 case content::NOTIFICATION_WEB_CONTENTS_CONNECTED:
50 if (HasSadTab()) { 52 if (HasSadTab()) {
51 web_contents()->GetView()->RemoveOverlayView(); 53 web_contents()->GetView()->RemoveOverlayView();
52 ReleaseSadTab(); 54 ReleaseSadTab();
53 } 55 }
54 break; 56 break;
55 57
56 default: 58 default:
57 NOTREACHED() << "Got a notification we didn't register for."; 59 NOTREACHED() << "Got a notification we didn't register for.";
58 } 60 }
59 } 61 }
(...skipping 32 matching lines...) Expand 10 before | Expand all | Expand 10 after
92 #endif 94 #endif
93 } 95 }
94 96
95 void SadTabObserver::ReleaseSadTab() { 97 void SadTabObserver::ReleaseSadTab() {
96 sad_tab_.reset(); 98 sad_tab_.reset();
97 } 99 }
98 100
99 bool SadTabObserver::HasSadTab() { 101 bool SadTabObserver::HasSadTab() {
100 return sad_tab_.get() != NULL; 102 return sad_tab_.get() != NULL;
101 } 103 }
OLDNEW

Powered by Google App Engine
This is Rietveld 408576698