OLD | NEW |
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 "chrome/browser/ui/views/sad_tab_view.h" | 5 #include "chrome/browser/ui/views/sad_tab_view.h" |
6 | 6 |
7 #include <string> | 7 #include <string> |
8 | 8 |
9 #include "base/metrics/field_trial.h" | 9 #include "base/metrics/field_trial.h" |
10 #include "base/metrics/histogram.h" | 10 #include "base/metrics/histogram.h" |
(...skipping 218 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
229 | 229 |
230 void SadTabView::Show() { | 230 void SadTabView::Show() { |
231 views::Widget::InitParams sad_tab_params( | 231 views::Widget::InitParams sad_tab_params( |
232 views::Widget::InitParams::TYPE_CONTROL); | 232 views::Widget::InitParams::TYPE_CONTROL); |
233 | 233 |
234 // It is not possible to create a native_widget_win that has no parent in | 234 // It is not possible to create a native_widget_win that has no parent in |
235 // and later re-parent it. | 235 // and later re-parent it. |
236 // TODO(avi): This is a cheat. Can this be made cleaner? | 236 // TODO(avi): This is a cheat. Can this be made cleaner? |
237 sad_tab_params.parent = web_contents_->GetView()->GetNativeView(); | 237 sad_tab_params.parent = web_contents_->GetView()->GetNativeView(); |
238 | 238 |
239 #if defined(OS_WIN) && !defined(USE_AURA) | |
240 // Crash data indicates we can get here when the parent is no longer valid. | |
241 // Attempting to create a child window with a bogus parent crashes. So, we | |
242 // don't show a sad tab in this case in hopes the tab is in the process of | |
243 // shutting down. | |
244 if (!IsWindow(sad_tab_params.parent)) | |
245 return; | |
246 #endif | |
247 | |
248 set_owned_by_client(); | 239 set_owned_by_client(); |
249 | 240 |
250 views::Widget* sad_tab = new views::Widget; | 241 views::Widget* sad_tab = new views::Widget; |
251 sad_tab->Init(sad_tab_params); | 242 sad_tab->Init(sad_tab_params); |
252 sad_tab->SetContentsView(this); | 243 sad_tab->SetContentsView(this); |
253 | 244 |
254 views::Widget::ReparentNativeView(sad_tab->GetNativeView(), | 245 views::Widget::ReparentNativeView(sad_tab->GetNativeView(), |
255 web_contents_->GetView()->GetNativeView()); | 246 web_contents_->GetView()->GetNativeView()); |
256 gfx::Rect bounds; | 247 gfx::Rect bounds; |
257 web_contents_->GetView()->GetContainerBounds(&bounds); | 248 web_contents_->GetView()->GetContainerBounds(&bounds); |
(...skipping 21 matching lines...) Expand all Loading... |
279 } | 270 } |
280 | 271 |
281 namespace chrome { | 272 namespace chrome { |
282 | 273 |
283 SadTab* SadTab::Create(content::WebContents* web_contents, | 274 SadTab* SadTab::Create(content::WebContents* web_contents, |
284 SadTabKind kind) { | 275 SadTabKind kind) { |
285 return new SadTabView(web_contents, kind); | 276 return new SadTabView(web_contents, kind); |
286 } | 277 } |
287 | 278 |
288 } // namespace chrome | 279 } // namespace chrome |
OLD | NEW |