Chromium Code Reviews| 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/views/extensions/extension_popup.h" | 5 #include "chrome/browser/ui/views/extensions/extension_popup.h" |
| 6 | 6 |
| 7 #include <vector> | 7 #include <vector> |
| 8 | 8 |
| 9 #include "base/bind.h" | 9 #include "base/bind.h" |
| 10 #include "chrome/browser/debugger/devtools_window.h" | 10 #include "chrome/browser/debugger/devtools_window.h" |
| 11 #include "chrome/browser/extensions/extension_host.h" | 11 #include "chrome/browser/extensions/extension_host.h" |
| 12 #include "chrome/browser/extensions/extension_process_manager.h" | 12 #include "chrome/browser/extensions/extension_process_manager.h" |
| 13 #include "chrome/browser/profiles/profile.h" | 13 #include "chrome/browser/profiles/profile.h" |
| 14 #include "chrome/browser/ui/browser.h" | 14 #include "chrome/browser/ui/browser.h" |
| 15 #include "chrome/browser/ui/browser_window.h" | 15 #include "chrome/browser/ui/browser_window.h" |
| 16 #include "chrome/common/chrome_notification_types.h" | 16 #include "chrome/common/chrome_notification_types.h" |
| 17 #include "chrome/common/extensions/extension.h" | 17 #include "chrome/common/extensions/extension.h" |
| 18 #include "content/browser/renderer_host/render_view_host.h" | 18 #include "content/browser/renderer_host/render_view_host.h" |
| 19 #include "content/browser/renderer_host/render_widget_host_view.h" | 19 #include "content/browser/renderer_host/render_widget_host_view.h" |
| 20 #include "content/browser/tab_contents/tab_contents.h" | |
| 20 #include "content/public/browser/notification_details.h" | 21 #include "content/public/browser/notification_details.h" |
| 21 #include "content/public/browser/notification_source.h" | 22 #include "content/public/browser/notification_source.h" |
| 22 #include "views/widget/root_view.h" | 23 #include "views/widget/root_view.h" |
| 23 #include "views/widget/widget.h" | 24 #include "views/widget/widget.h" |
| 24 | 25 |
| 25 #if defined(OS_CHROMEOS) && defined(TOOLKIT_USES_GTK) | 26 #if defined(OS_CHROMEOS) && defined(TOOLKIT_USES_GTK) |
| 26 #include "chrome/browser/chromeos/wm_ipc.h" | 27 #include "chrome/browser/chromeos/wm_ipc.h" |
| 27 #include "third_party/cros_system_api/window_manager/chromeos_wm_ipc_enums.h" | 28 #include "third_party/cros_system_api/window_manager/chromeos_wm_ipc_enums.h" |
| 28 #endif | 29 #endif |
| 29 | 30 |
| (...skipping 33 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... | |
| 63 registrar_.Add(this, | 64 registrar_.Add(this, |
| 64 chrome::NOTIFICATION_EXTENSION_HOST_DID_STOP_LOADING, | 65 chrome::NOTIFICATION_EXTENSION_HOST_DID_STOP_LOADING, |
| 65 content::Source<Profile>(host->profile())); | 66 content::Source<Profile>(host->profile())); |
| 66 | 67 |
| 67 // Listen for the containing view calling window.close(); | 68 // Listen for the containing view calling window.close(); |
| 68 registrar_.Add(this, chrome::NOTIFICATION_EXTENSION_HOST_VIEW_SHOULD_CLOSE, | 69 registrar_.Add(this, chrome::NOTIFICATION_EXTENSION_HOST_VIEW_SHOULD_CLOSE, |
| 69 content::Source<Profile>(host->profile())); | 70 content::Source<Profile>(host->profile())); |
| 70 } | 71 } |
| 71 | 72 |
| 72 ExtensionPopup::~ExtensionPopup() { | 73 ExtensionPopup::~ExtensionPopup() { |
| 74 // Clear the delegate, because we might trigger UI events during destruction, | |
| 75 // and we don't want to be called into anymore. | |
| 76 set_delegate(NULL); | |
|
Matt Perry
2011/11/16 21:44:10
This fixes the crash bug I mention. (BrowserBubble
| |
| 73 } | 77 } |
| 74 | 78 |
| 75 void ExtensionPopup::Show(bool activate) { | 79 void ExtensionPopup::Show(bool activate) { |
| 76 if (popup_->IsVisible()) | 80 if (popup_->IsVisible()) |
| 77 return; | 81 return; |
| 78 | 82 |
| 79 #if defined(OS_WIN) | 83 #if defined(OS_WIN) |
| 80 frame_->GetTopLevelWidget()->DisableInactiveRendering(); | 84 frame_->GetTopLevelWidget()->DisableInactiveRendering(); |
| 81 #endif | 85 #endif |
| 82 | 86 |
| 83 ResizeToView(); | 87 ResizeToView(); |
| 84 BrowserBubble::Show(activate); | 88 BrowserBubble::Show(activate); |
| 85 } | 89 } |
| 86 | 90 |
| 87 void ExtensionPopup::BubbleBrowserWindowMoved(BrowserBubble* bubble) { | 91 void ExtensionPopup::BubbleBrowserWindowMoved(BrowserBubble* bubble) { |
| 88 ResizeToView(); | 92 ResizeToView(); |
| 89 } | 93 } |
| 90 | 94 |
| 91 void ExtensionPopup::BubbleBrowserWindowClosing(BrowserBubble* bubble) { | 95 void ExtensionPopup::BubbleBrowserWindowClosing(BrowserBubble* bubble) { |
| 92 if (!closing_) | 96 if (!closing_) |
| 93 Close(); | 97 Close(); |
| 94 } | 98 } |
| 95 | 99 |
| 96 void ExtensionPopup::BubbleGotFocus(BrowserBubble* bubble) { | 100 void ExtensionPopup::BubbleGotFocus(BrowserBubble* bubble) { |
| 97 // Forward the focus to the renderer. | 101 // Forward the focus to the renderer. |
| 98 host()->render_view_host()->view()->Focus(); | 102 host()->host_contents()->Focus(); |
| 99 } | 103 } |
| 100 | 104 |
| 101 void ExtensionPopup::BubbleLostFocus(BrowserBubble* bubble, | 105 void ExtensionPopup::BubbleLostFocus(BrowserBubble* bubble, |
| 102 bool lost_focus_to_child) { | 106 bool lost_focus_to_child) { |
| 103 if (closing_ || // We are already closing. | 107 if (closing_ || // We are already closing. |
| 104 inspect_with_devtools_ || // The popup is being inspected. | 108 inspect_with_devtools_ || // The popup is being inspected. |
| 105 !close_on_lost_focus_ || // Our client is handling focus listening. | 109 !close_on_lost_focus_ || // Our client is handling focus listening. |
| 106 lost_focus_to_child) // A child of this view got focus. | 110 lost_focus_to_child) // A child of this view got focus. |
| 107 return; | 111 return; |
| 108 | 112 |
| (...skipping 96 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... | |
| 205 if (closing_) | 209 if (closing_) |
| 206 return; | 210 return; |
| 207 closing_ = true; | 211 closing_ = true; |
| 208 DetachFromBrowser(); | 212 DetachFromBrowser(); |
| 209 | 213 |
| 210 if (observer_) | 214 if (observer_) |
| 211 observer_->ExtensionPopupIsClosing(this); | 215 observer_->ExtensionPopupIsClosing(this); |
| 212 | 216 |
| 213 Release(); // Balanced in ctor. | 217 Release(); // Balanced in ctor. |
| 214 } | 218 } |
| OLD | NEW |