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" |
(...skipping 21 matching lines...) Expand all Loading... | |
32 using views::Widget; | 32 using views::Widget; |
33 | 33 |
34 // The minimum/maximum dimensions of the popup. | 34 // The minimum/maximum dimensions of the popup. |
35 // The minimum is just a little larger than the size of the button itself. | 35 // The minimum is just a little larger than the size of the button itself. |
36 // The maximum is an arbitrary number that should be smaller than most screens. | 36 // The maximum is an arbitrary number that should be smaller than most screens. |
37 const int ExtensionPopup::kMinWidth = 25; | 37 const int ExtensionPopup::kMinWidth = 25; |
38 const int ExtensionPopup::kMinHeight = 25; | 38 const int ExtensionPopup::kMinHeight = 25; |
39 const int ExtensionPopup::kMaxWidth = 800; | 39 const int ExtensionPopup::kMaxWidth = 800; |
40 const int ExtensionPopup::kMaxHeight = 600; | 40 const int ExtensionPopup::kMaxHeight = 600; |
41 | 41 |
42 // @@@MP ownership: EH owns TC. We have weakref to TC. when we tell TC to close, | |
43 // EH deletes itself? Or maybe we hold a ref to a TCHolderInterface that has | |
44 // a GetTC and Close method? | |
Matt Perry
2011/11/23 02:51:20
ignore this file
| |
45 | |
42 ExtensionPopup::ExtensionPopup( | 46 ExtensionPopup::ExtensionPopup( |
43 Browser* browser, | 47 Browser* browser, |
44 ExtensionHost* host, | 48 ExtensionHost* host, |
45 const gfx::Rect& relative_to, | 49 const gfx::Rect& relative_to, |
46 views::BubbleBorder::ArrowLocation arrow_location, | 50 views::BubbleBorder::ArrowLocation arrow_location, |
47 bool inspect_with_devtools, | 51 bool inspect_with_devtools, |
48 Observer* observer) | 52 Observer* observer) |
49 : BrowserBubble(browser, | 53 : BrowserBubble(browser, |
50 host->view(), | 54 host->view(), |
51 relative_to, | 55 relative_to, |
52 arrow_location), | 56 arrow_location), |
53 relative_to_(relative_to), | 57 relative_to_(relative_to), |
54 extension_host_(host), | 58 extension_host_(host), |
55 inspect_with_devtools_(inspect_with_devtools), | 59 inspect_with_devtools_(inspect_with_devtools), |
56 close_on_lost_focus_(true), | 60 close_on_lost_focus_(true), |
57 closing_(false), | 61 closing_(false), |
58 observer_(observer) { | 62 observer_(observer) { |
59 AddRef(); // Balanced in Close(); | 63 AddRef(); // Balanced in Close(); |
60 set_delegate(this); | 64 set_delegate(this); |
61 host->view()->SetContainer(this); | 65 host->view()->SetContainer(this); |
62 | 66 |
63 // We wait to show the popup until the contained host finishes loading. | 67 // We wait to show the popup until the contained host finishes loading. |
68 // @@@MP listen for TCO::DidStopLoading | |
64 registrar_.Add(this, | 69 registrar_.Add(this, |
65 chrome::NOTIFICATION_EXTENSION_HOST_DID_STOP_LOADING, | 70 chrome::NOTIFICATION_EXTENSION_HOST_DID_STOP_LOADING, |
66 content::Source<Profile>(host->profile())); | 71 content::Source<Profile>(host->profile())); |
67 | 72 |
68 // Listen for the containing view calling window.close(); | 73 // Listen for the containing view calling window.close(); |
74 // @@@MP listen for TCO::TabContentsDestroyed? see ownership | |
69 registrar_.Add(this, chrome::NOTIFICATION_EXTENSION_HOST_VIEW_SHOULD_CLOSE, | 75 registrar_.Add(this, chrome::NOTIFICATION_EXTENSION_HOST_VIEW_SHOULD_CLOSE, |
70 content::Source<Profile>(host->profile())); | 76 content::Source<Profile>(host->profile())); |
71 } | 77 } |
72 | 78 |
73 ExtensionPopup::~ExtensionPopup() { | 79 ExtensionPopup::~ExtensionPopup() { |
74 // Clear the delegate, because we might trigger UI events during destruction, | 80 // Clear the delegate, because we might trigger UI events during destruction, |
75 // and we don't want to be called into anymore. | 81 // and we don't want to be called into anymore. |
76 set_delegate(NULL); | 82 set_delegate(NULL); |
77 } | 83 } |
78 | 84 |
(...skipping 130 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... | |
209 if (closing_) | 215 if (closing_) |
210 return; | 216 return; |
211 closing_ = true; | 217 closing_ = true; |
212 DetachFromBrowser(); | 218 DetachFromBrowser(); |
213 | 219 |
214 if (observer_) | 220 if (observer_) |
215 observer_->ExtensionPopupIsClosing(this); | 221 observer_->ExtensionPopupIsClosing(this); |
216 | 222 |
217 Release(); // Balanced in ctor. | 223 Release(); // Balanced in ctor. |
218 } | 224 } |
OLD | NEW |