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/sad_tab_helper.h" | 5 #include "chrome/browser/ui/sad_tab_helper.h" |
6 | 6 |
7 #include "chrome/browser/browser_shutdown.h" | 7 #include "chrome/browser/browser_shutdown.h" |
8 #include "content/public/browser/notification_source.h" | 8 #include "content/public/browser/notification_source.h" |
9 #include "content/public/browser/notification_types.h" | 9 #include "content/public/browser/notification_types.h" |
10 #include "content/public/browser/web_contents.h" | 10 #include "content/public/browser/web_contents.h" |
(...skipping 39 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
50 void SadTabHelper::Observe(int type, | 50 void SadTabHelper::Observe(int type, |
51 const content::NotificationSource& source, | 51 const content::NotificationSource& source, |
52 const content::NotificationDetails& details) { | 52 const content::NotificationDetails& details) { |
53 switch (type) { | 53 switch (type) { |
54 case content::NOTIFICATION_WEB_CONTENTS_CONNECTED: | 54 case content::NOTIFICATION_WEB_CONTENTS_CONNECTED: |
55 if (HasSadTab()) { | 55 if (HasSadTab()) { |
56 #if defined(OS_MACOSX) | 56 #if defined(OS_MACOSX) |
57 sad_tab_controller_mac::RemoveSadTab(sad_tab_.get()); | 57 sad_tab_controller_mac::RemoveSadTab(sad_tab_.get()); |
58 #elif defined(TOOLKIT_VIEWS) | 58 #elif defined(TOOLKIT_VIEWS) |
59 sad_tab_->Close(); | 59 sad_tab_->Close(); |
| 60 // See http://crbug.com/117668. When the Widget is being destructed, we |
| 61 // want calls to sad_tab() to return NULL. |
| 62 scoped_ptr<views::Widget> local_sad_tab; |
| 63 local_sad_tab.swap(sad_tab_); |
60 #elif defined(TOOLKIT_GTK) | 64 #elif defined(TOOLKIT_GTK) |
61 GtkWidget* expanded_container = | 65 GtkWidget* expanded_container = |
62 ChromeWebContentsViewDelegateGtk::GetFor(web_contents())-> | 66 ChromeWebContentsViewDelegateGtk::GetFor(web_contents())-> |
63 expanded_container(); | 67 expanded_container(); |
64 gtk_container_remove( | 68 gtk_container_remove( |
65 GTK_CONTAINER(expanded_container), sad_tab_->widget()); | 69 GTK_CONTAINER(expanded_container), sad_tab_->widget()); |
66 #else | 70 #else |
67 #error Unknown platform | 71 #error Unknown platform |
68 #endif | 72 #endif |
69 sad_tab_.reset(); | 73 sad_tab_.reset(); |
(...skipping 42 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
112 gtk_container_add(GTK_CONTAINER(expanded_container), sad_tab_->widget()); | 116 gtk_container_add(GTK_CONTAINER(expanded_container), sad_tab_->widget()); |
113 gtk_widget_show(sad_tab_->widget()); | 117 gtk_widget_show(sad_tab_->widget()); |
114 #else | 118 #else |
115 #error Unknown platform | 119 #error Unknown platform |
116 #endif | 120 #endif |
117 } | 121 } |
118 | 122 |
119 bool SadTabHelper::HasSadTab() { | 123 bool SadTabHelper::HasSadTab() { |
120 return sad_tab_.get() != NULL; | 124 return sad_tab_.get() != NULL; |
121 } | 125 } |
OLD | NEW |