Chromium Code Reviews
chromiumcodereview-hr@appspot.gserviceaccount.com (chromiumcodereview-hr) | Please choose your nickname with Settings | Help | Chromium Project | Gerrit Changes | Sign out
(887)

Side by Side Diff: chrome/browser/ui/gtk/extensions/extension_popup_gtk.cc

Issue 10913243: extensions: Add ExtensionView interface. (Closed) Base URL: svn://svn.chromium.org/chrome/trunk/src
Patch Set: last mac fix Created 8 years, 3 months ago
Use n/p to move between diff chunks; N/P to move between comments. Draft comments are only viewable by you.
Jump to:
View unified diff | Download patch | Annotate | Revision Log
OLDNEW
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
11 #include "base/bind.h" 11 #include "base/bind.h"
12 #include "base/bind_helpers.h" 12 #include "base/bind_helpers.h"
13 #include "base/callback.h" 13 #include "base/callback.h"
14 #include "base/i18n/rtl.h" 14 #include "base/i18n/rtl.h"
15 #include "base/message_loop.h" 15 #include "base/message_loop.h"
16 #include "chrome/browser/debugger/devtools_window.h" 16 #include "chrome/browser/debugger/devtools_window.h"
17 #include "chrome/browser/extensions/extension_host.h" 17 #include "chrome/browser/extensions/extension_host.h"
18 #include "chrome/browser/extensions/extension_process_manager.h" 18 #include "chrome/browser/extensions/extension_process_manager.h"
19 #include "chrome/browser/extensions/extension_view.h"
19 #include "chrome/browser/profiles/profile.h" 20 #include "chrome/browser/profiles/profile.h"
20 #include "chrome/browser/ui/browser.h" 21 #include "chrome/browser/ui/browser.h"
21 #include "chrome/browser/ui/browser_window.h" 22 #include "chrome/browser/ui/browser_window.h"
22 #include "chrome/browser/ui/gtk/gtk_theme_service.h" 23 #include "chrome/browser/ui/gtk/gtk_theme_service.h"
23 #include "chrome/common/chrome_notification_types.h" 24 #include "chrome/common/chrome_notification_types.h"
24 #include "content/public/browser/notification_details.h" 25 #include "content/public/browser/notification_details.h"
25 #include "content/public/browser/notification_source.h" 26 #include "content/public/browser/notification_source.h"
26 #include "content/public/browser/render_view_host.h" 27 #include "content/public/browser/render_view_host.h"
27 #include "content/public/browser/render_widget_host_view.h" 28 #include "content/public/browser/render_widget_host_view.h"
28 #include "googleurl/src/gurl.h" 29 #include "googleurl/src/gurl.h"
(...skipping 12 matching lines...) Expand all
41 42
42 ExtensionPopupGtk::ExtensionPopupGtk(Browser* browser, 43 ExtensionPopupGtk::ExtensionPopupGtk(Browser* browser,
43 extensions::ExtensionHost* host, 44 extensions::ExtensionHost* host,
44 GtkWidget* anchor, 45 GtkWidget* anchor,
45 ShowAction show_action) 46 ShowAction show_action)
46 : browser_(browser), 47 : browser_(browser),
47 bubble_(NULL), 48 bubble_(NULL),
48 host_(host), 49 host_(host),
49 anchor_(anchor), 50 anchor_(anchor),
50 weak_factory_(this) { 51 weak_factory_(this) {
51 host_->view()->SetContainer(this); 52 host_->GetExtensionView()->SetContainer(this);
52 being_inspected_ = show_action == SHOW_AND_INSPECT; 53 being_inspected_ = show_action == SHOW_AND_INSPECT;
53 54
54 // If the host had somehow finished loading, then we'd miss the notification 55 // If the host had somehow finished loading, then we'd miss the notification
55 // and not show. This seems to happen in single-process mode. 56 // and not show. This seems to happen in single-process mode.
56 if (host->did_stop_loading()) { 57 if (host->did_stop_loading()) {
57 ShowPopup(); 58 ShowPopup();
58 } else { 59 } else {
59 registrar_.Add(this, chrome::NOTIFICATION_EXTENSION_HOST_DID_STOP_LOADING, 60 registrar_.Add(this, chrome::NOTIFICATION_EXTENSION_HOST_DID_STOP_LOADING,
60 content::Source<Profile>(host->profile())); 61 content::Source<Profile>(host->profile()));
61 } 62 }
(...skipping 69 matching lines...) Expand 10 before | Expand all | Expand 10 after
131 NOTREACHED() << "Received unexpected notification"; 132 NOTREACHED() << "Received unexpected notification";
132 } 133 }
133 } 134 }
134 135
135 void ExtensionPopupGtk::BubbleClosing(BubbleGtk* bubble, 136 void ExtensionPopupGtk::BubbleClosing(BubbleGtk* bubble,
136 bool closed_by_escape) { 137 bool closed_by_escape) {
137 current_extension_popup_ = NULL; 138 current_extension_popup_ = NULL;
138 delete this; 139 delete this;
139 } 140 }
140 141
141 void ExtensionPopupGtk::OnExtensionSizeChanged( 142 void ExtensionPopupGtk::OnExtensionSizeChanged(ExtensionView* view,
142 ExtensionViewGtk* view, 143 const gfx::Size& new_size) {
143 const gfx::Size& new_size) {
144 int width = std::max(kMinWidth, std::min(kMaxWidth, new_size.width())); 144 int width = std::max(kMinWidth, std::min(kMaxWidth, new_size.width()));
145 int height = std::max(kMinHeight, std::min(kMaxHeight, new_size.height())); 145 int height = std::max(kMinHeight, std::min(kMaxHeight, new_size.height()));
146 146
147 view->render_view_host()->GetView()->SetSize(gfx::Size(width, height)); 147 view->GetRenderViewHost()->GetView()->SetSize(gfx::Size(width, height));
148 gtk_widget_set_size_request(view->native_view(), width, height); 148 gtk_widget_set_size_request(view->GetNativeView(), width, height);
149 }
150
151 void ExtensionPopupGtk::OnExtensionViewDidShow(ExtensionView* view) {
149 } 152 }
150 153
151 bool ExtensionPopupGtk::DestroyPopup() { 154 bool ExtensionPopupGtk::DestroyPopup() {
152 if (!bubble_) { 155 if (!bubble_) {
153 NOTREACHED(); 156 NOTREACHED();
154 return false; 157 return false;
155 } 158 }
156 159
157 bubble_->Close(); 160 bubble_->Close();
158 return true; 161 return true;
(...skipping 18 matching lines...) Expand all
177 180
178 // We'll be in the upper-right corner of the window for LTR languages, so we 181 // We'll be in the upper-right corner of the window for LTR languages, so we
179 // want to put the arrow at the upper-right corner of the bubble to match the 182 // want to put the arrow at the upper-right corner of the bubble to match the
180 // page and app menus. 183 // page and app menus.
181 BubbleGtk::ArrowLocationGtk arrow_location = 184 BubbleGtk::ArrowLocationGtk arrow_location =
182 !base::i18n::IsRTL() ? 185 !base::i18n::IsRTL() ?
183 BubbleGtk::ARROW_LOCATION_TOP_RIGHT : 186 BubbleGtk::ARROW_LOCATION_TOP_RIGHT :
184 BubbleGtk::ARROW_LOCATION_TOP_LEFT; 187 BubbleGtk::ARROW_LOCATION_TOP_LEFT;
185 bubble_ = BubbleGtk::Show(anchor_, 188 bubble_ = BubbleGtk::Show(anchor_,
186 NULL, 189 NULL,
187 host_->view()->native_view(), 190 host_->GetExtensionView()->GetNativeView(),
188 arrow_location, 191 arrow_location,
189 being_inspected_ ? 0 : 192 being_inspected_ ? 0 :
190 BubbleGtk::POPUP_WINDOW | BubbleGtk::GRAB_INPUT, 193 BubbleGtk::POPUP_WINDOW | BubbleGtk::GRAB_INPUT,
191 GtkThemeService::GetFrom(browser_->profile()), 194 GtkThemeService::GetFrom(browser_->profile()),
192 this); 195 this);
193 } 196 }
194 197
195 void ExtensionPopupGtk::DestroyPopupWithoutResult() { 198 void ExtensionPopupGtk::DestroyPopupWithoutResult() {
196 DestroyPopup(); 199 DestroyPopup();
197 } 200 }
198 201
199 gfx::Rect ExtensionPopupGtk::GetViewBounds() { 202 gfx::Rect ExtensionPopupGtk::GetViewBounds() {
200 GtkAllocation allocation; 203 GtkAllocation allocation;
201 gtk_widget_get_allocation(host_->view()->native_view(), &allocation); 204 gtk_widget_get_allocation(host_->GetExtensionView()->GetNativeView(),
205 &allocation);
202 return gfx::Rect(allocation); 206 return gfx::Rect(allocation);
203 } 207 }
OLDNEW

Powered by Google App Engine
This is Rietveld 408576698