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/gtk/extensions/extension_popup_gtk.h" | 5 #include "chrome/browser/ui/gtk/extensions/extension_popup_gtk.h" |
6 | 6 |
7 #include <gtk/gtk.h> | 7 #include <gtk/gtk.h> |
8 | 8 |
9 #include <algorithm> | 9 #include <algorithm> |
10 | 10 |
(...skipping 22 matching lines...) Expand all Loading... |
33 | 33 |
34 // The minimum/maximum dimensions of the extension popup. | 34 // The minimum/maximum dimensions of the extension popup. |
35 // The minimum is just a little larger than the size of a browser action button. | 35 // The minimum is just a little larger than the size of a browser action button. |
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 ExtensionPopupGtk::kMinWidth = 25; | 37 const int ExtensionPopupGtk::kMinWidth = 25; |
38 const int ExtensionPopupGtk::kMinHeight = 25; | 38 const int ExtensionPopupGtk::kMinHeight = 25; |
39 const int ExtensionPopupGtk::kMaxWidth = 800; | 39 const int ExtensionPopupGtk::kMaxWidth = 800; |
40 const int ExtensionPopupGtk::kMaxHeight = 600; | 40 const int ExtensionPopupGtk::kMaxHeight = 600; |
41 | 41 |
42 ExtensionPopupGtk::ExtensionPopupGtk(Browser* browser, | 42 ExtensionPopupGtk::ExtensionPopupGtk(Browser* browser, |
43 ExtensionHost* host, | 43 extensions::ExtensionHost* host, |
44 GtkWidget* anchor, | 44 GtkWidget* anchor, |
45 ShowAction show_action) | 45 ShowAction show_action) |
46 : browser_(browser), | 46 : browser_(browser), |
47 bubble_(NULL), | 47 bubble_(NULL), |
48 host_(host), | 48 host_(host), |
49 anchor_(anchor), | 49 anchor_(anchor), |
50 weak_factory_(this) { | 50 weak_factory_(this) { |
51 host_->view()->SetContainer(this); | 51 host_->view()->SetContainer(this); |
52 being_inspected_ = show_action == SHOW_AND_INSPECT; | 52 being_inspected_ = show_action == SHOW_AND_INSPECT; |
53 | 53 |
(...skipping 23 matching lines...) Expand all Loading... |
77 | 77 |
78 // static | 78 // static |
79 void ExtensionPopupGtk::Show(const GURL& url, Browser* browser, | 79 void ExtensionPopupGtk::Show(const GURL& url, Browser* browser, |
80 GtkWidget* anchor, ShowAction show_action) { | 80 GtkWidget* anchor, ShowAction show_action) { |
81 ExtensionProcessManager* manager = | 81 ExtensionProcessManager* manager = |
82 browser->profile()->GetExtensionProcessManager(); | 82 browser->profile()->GetExtensionProcessManager(); |
83 DCHECK(manager); | 83 DCHECK(manager); |
84 if (!manager) | 84 if (!manager) |
85 return; | 85 return; |
86 | 86 |
87 ExtensionHost* host = manager->CreatePopupHost(url, browser); | 87 extensions::ExtensionHost* host = manager->CreatePopupHost(url, browser); |
88 // This object will delete itself when the bubble is closed. | 88 // This object will delete itself when the bubble is closed. |
89 new ExtensionPopupGtk(browser, host, anchor, show_action); | 89 new ExtensionPopupGtk(browser, host, anchor, show_action); |
90 } | 90 } |
91 | 91 |
92 void ExtensionPopupGtk::Observe(int type, | 92 void ExtensionPopupGtk::Observe(int type, |
93 const content::NotificationSource& source, | 93 const content::NotificationSource& source, |
94 const content::NotificationDetails& details) { | 94 const content::NotificationDetails& details) { |
95 switch (type) { | 95 switch (type) { |
96 case chrome::NOTIFICATION_EXTENSION_HOST_DID_STOP_LOADING: | 96 case chrome::NOTIFICATION_EXTENSION_HOST_DID_STOP_LOADING: |
97 if (content::Details<ExtensionHost>(host_.get()) == details) | 97 if (content::Details<extensions::ExtensionHost>(host_.get()) == details) |
98 ShowPopup(); | 98 ShowPopup(); |
99 break; | 99 break; |
100 case chrome::NOTIFICATION_EXTENSION_HOST_VIEW_SHOULD_CLOSE: | 100 case chrome::NOTIFICATION_EXTENSION_HOST_VIEW_SHOULD_CLOSE: |
101 if (content::Details<ExtensionHost>(host_.get()) == details) | 101 if (content::Details<extensions::ExtensionHost>(host_.get()) == details) |
102 DestroyPopup(); | 102 DestroyPopup(); |
103 break; | 103 break; |
104 case content::NOTIFICATION_DEVTOOLS_WINDOW_OPENING: | 104 case content::NOTIFICATION_DEVTOOLS_WINDOW_OPENING: |
105 // Make sure it's the devtools window that is inspecting our popup. | 105 // Make sure it's the devtools window that is inspecting our popup. |
106 if (content::Details<RenderViewHost>(host_->render_view_host()) != | 106 if (content::Details<RenderViewHost>(host_->render_view_host()) != |
107 details) | 107 details) |
108 break; | 108 break; |
109 | 109 |
110 // Make sure that the popup won't go away when the inspector is activated. | 110 // Make sure that the popup won't go away when the inspector is activated. |
111 if (bubble_) | 111 if (bubble_) |
(...skipping 82 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
194 | 194 |
195 void ExtensionPopupGtk::DestroyPopupWithoutResult() { | 195 void ExtensionPopupGtk::DestroyPopupWithoutResult() { |
196 DestroyPopup(); | 196 DestroyPopup(); |
197 } | 197 } |
198 | 198 |
199 gfx::Rect ExtensionPopupGtk::GetViewBounds() { | 199 gfx::Rect ExtensionPopupGtk::GetViewBounds() { |
200 GtkAllocation allocation; | 200 GtkAllocation allocation; |
201 gtk_widget_get_allocation(host_->view()->native_view(), &allocation); | 201 gtk_widget_get_allocation(host_->view()->native_view(), &allocation); |
202 return gfx::Rect(allocation); | 202 return gfx::Rect(allocation); |
203 } | 203 } |
OLD | NEW |