OLD | NEW |
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 51 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
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 widget that has no parent, and later | 72 // It is not possible to create a native_widget_win that has no parent in |
73 // re-parent it. TODO(avi): This is a cheat. Can this be made cleaner? | 73 // and later re-parent it. |
| 74 // TODO(avi): This is a cheat. Can this be made cleaner? |
74 sad_tab_params.parent_widget = | 75 sad_tab_params.parent_widget = |
75 static_cast<TabContentsViewViews*>(tab_contents()->view()); | 76 static_cast<TabContentsViewViews*>(tab_contents()->view()); |
76 sad_tab_params.ownership = | 77 sad_tab_params.ownership = |
77 views::Widget::InitParams::WIDGET_OWNS_NATIVE_WIDGET; | 78 views::Widget::InitParams::WIDGET_OWNS_NATIVE_WIDGET; |
78 sad_tab_.reset(new views::Widget); | 79 sad_tab_.reset(new views::Widget); |
79 sad_tab_->Init(sad_tab_params); | 80 sad_tab_->Init(sad_tab_params); |
80 sad_tab_->SetContentsView(new SadTabView(tab_contents(), kind)); | 81 sad_tab_->SetContentsView(new SadTabView(tab_contents(), kind)); |
81 return sad_tab_->GetNativeView(); | 82 return sad_tab_->GetNativeView(); |
82 #elif defined(TOOLKIT_GTK) | 83 #elif defined(TOOLKIT_GTK) |
83 sad_tab_.reset(new SadTabGtk( | 84 sad_tab_.reset(new SadTabGtk( |
84 tab_contents(), | 85 tab_contents(), |
85 status == base::TERMINATION_STATUS_PROCESS_WAS_KILLED | 86 status == base::TERMINATION_STATUS_PROCESS_WAS_KILLED |
86 ? SadTabGtk::KILLED | 87 ? SadTabGtk::KILLED |
87 : SadTabGtk::CRASHED)); | 88 : SadTabGtk::CRASHED)); |
88 return sad_tab_->widget(); | 89 return sad_tab_->widget(); |
89 #else | 90 #else |
90 #error Unknown platform | 91 #error Unknown platform |
91 #endif | 92 #endif |
92 } | 93 } |
93 | 94 |
94 void SadTabObserver::ReleaseSadTab() { | 95 void SadTabObserver::ReleaseSadTab() { |
95 sad_tab_.reset(); | 96 sad_tab_.reset(); |
96 } | 97 } |
97 | 98 |
98 bool SadTabObserver::HasSadTab() { | 99 bool SadTabObserver::HasSadTab() { |
99 return sad_tab_.get() != NULL; | 100 return sad_tab_.get() != NULL; |
100 } | 101 } |
OLD | NEW |