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

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

Issue 10961066: Revert 158199 - extensions: Add ExtensionView interface. (Closed) Base URL: svn://svn.chromium.org/chrome/trunk/src/
Patch Set: 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"
20 #include "chrome/browser/profiles/profile.h" 19 #include "chrome/browser/profiles/profile.h"
21 #include "chrome/browser/ui/browser.h" 20 #include "chrome/browser/ui/browser.h"
22 #include "chrome/browser/ui/browser_window.h" 21 #include "chrome/browser/ui/browser_window.h"
23 #include "chrome/browser/ui/gtk/gtk_theme_service.h" 22 #include "chrome/browser/ui/gtk/gtk_theme_service.h"
24 #include "chrome/common/chrome_notification_types.h" 23 #include "chrome/common/chrome_notification_types.h"
25 #include "content/public/browser/notification_details.h" 24 #include "content/public/browser/notification_details.h"
26 #include "content/public/browser/notification_source.h" 25 #include "content/public/browser/notification_source.h"
27 #include "content/public/browser/render_view_host.h" 26 #include "content/public/browser/render_view_host.h"
28 #include "content/public/browser/render_widget_host_view.h" 27 #include "content/public/browser/render_widget_host_view.h"
29 #include "googleurl/src/gurl.h" 28 #include "googleurl/src/gurl.h"
(...skipping 12 matching lines...) Expand all
42 41
43 ExtensionPopupGtk::ExtensionPopupGtk(Browser* browser, 42 ExtensionPopupGtk::ExtensionPopupGtk(Browser* browser,
44 extensions::ExtensionHost* host, 43 extensions::ExtensionHost* host,
45 GtkWidget* anchor, 44 GtkWidget* anchor,
46 ShowAction show_action) 45 ShowAction show_action)
47 : browser_(browser), 46 : browser_(browser),
48 bubble_(NULL), 47 bubble_(NULL),
49 host_(host), 48 host_(host),
50 anchor_(anchor), 49 anchor_(anchor),
51 weak_factory_(this) { 50 weak_factory_(this) {
52 host_->GetExtensionView()->SetContainer(this); 51 host_->view()->SetContainer(this);
53 being_inspected_ = show_action == SHOW_AND_INSPECT; 52 being_inspected_ = show_action == SHOW_AND_INSPECT;
54 53
55 // If the host had somehow finished loading, then we'd miss the notification 54 // If the host had somehow finished loading, then we'd miss the notification
56 // and not show. This seems to happen in single-process mode. 55 // and not show. This seems to happen in single-process mode.
57 if (host->did_stop_loading()) { 56 if (host->did_stop_loading()) {
58 ShowPopup(); 57 ShowPopup();
59 } else { 58 } else {
60 registrar_.Add(this, chrome::NOTIFICATION_EXTENSION_HOST_DID_STOP_LOADING, 59 registrar_.Add(this, chrome::NOTIFICATION_EXTENSION_HOST_DID_STOP_LOADING,
61 content::Source<Profile>(host->profile())); 60 content::Source<Profile>(host->profile()));
62 } 61 }
(...skipping 69 matching lines...) Expand 10 before | Expand all | Expand 10 after
132 NOTREACHED() << "Received unexpected notification"; 131 NOTREACHED() << "Received unexpected notification";
133 } 132 }
134 } 133 }
135 134
136 void ExtensionPopupGtk::BubbleClosing(BubbleGtk* bubble, 135 void ExtensionPopupGtk::BubbleClosing(BubbleGtk* bubble,
137 bool closed_by_escape) { 136 bool closed_by_escape) {
138 current_extension_popup_ = NULL; 137 current_extension_popup_ = NULL;
139 delete this; 138 delete this;
140 } 139 }
141 140
142 void ExtensionPopupGtk::OnExtensionSizeChanged(ExtensionView* view, 141 void ExtensionPopupGtk::OnExtensionSizeChanged(
143 const gfx::Size& new_size) { 142 ExtensionViewGtk* view,
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->GetRenderViewHost()->GetView()->SetSize(gfx::Size(width, height)); 147 view->render_view_host()->GetView()->SetSize(gfx::Size(width, height));
148 gtk_widget_set_size_request(view->GetNativeView(), width, height); 148 gtk_widget_set_size_request(view->native_view(), width, height);
149 }
150
151 void ExtensionPopupGtk::OnExtensionViewDidShow(ExtensionView* view) {
152 } 149 }
153 150
154 bool ExtensionPopupGtk::DestroyPopup() { 151 bool ExtensionPopupGtk::DestroyPopup() {
155 if (!bubble_) { 152 if (!bubble_) {
156 NOTREACHED(); 153 NOTREACHED();
157 return false; 154 return false;
158 } 155 }
159 156
160 bubble_->Close(); 157 bubble_->Close();
161 return true; 158 return true;
(...skipping 13 matching lines...) Expand all
175 // non-NULL if a browser action button is clicked while another extension 172 // non-NULL if a browser action button is clicked while another extension
176 // popup's extension host is still loading. 173 // popup's extension host is still loading.
177 if (current_extension_popup_) 174 if (current_extension_popup_)
178 current_extension_popup_->DestroyPopup(); 175 current_extension_popup_->DestroyPopup();
179 current_extension_popup_ = this; 176 current_extension_popup_ = this;
180 177
181 GtkWidget* border_box = gtk_alignment_new(0, 0, 1.0, 1.0); 178 GtkWidget* border_box = gtk_alignment_new(0, 0, 1.0, 1.0);
182 // This border is necessary so the bubble's corners do not get cut off by the 179 // This border is necessary so the bubble's corners do not get cut off by the
183 // render view. 180 // render view.
184 gtk_container_set_border_width(GTK_CONTAINER(border_box), 2); 181 gtk_container_set_border_width(GTK_CONTAINER(border_box), 2);
185 gtk_container_add(GTK_CONTAINER(border_box), 182 gtk_container_add(GTK_CONTAINER(border_box), host_->view()->native_view());
186 host_->GetExtensionView()->GetNativeView());
187 183
188 // We'll be in the upper-right corner of the window for LTR languages, so we 184 // We'll be in the upper-right corner of the window for LTR languages, so we
189 // want to put the arrow at the upper-right corner of the bubble to match the 185 // want to put the arrow at the upper-right corner of the bubble to match the
190 // page and app menus. 186 // page and app menus.
191 BubbleGtk::ArrowLocationGtk arrow_location = 187 BubbleGtk::ArrowLocationGtk arrow_location =
192 !base::i18n::IsRTL() ? 188 !base::i18n::IsRTL() ?
193 BubbleGtk::ARROW_LOCATION_TOP_RIGHT : 189 BubbleGtk::ARROW_LOCATION_TOP_RIGHT :
194 BubbleGtk::ARROW_LOCATION_TOP_LEFT; 190 BubbleGtk::ARROW_LOCATION_TOP_LEFT;
195 bubble_ = BubbleGtk::Show(anchor_, 191 bubble_ = BubbleGtk::Show(anchor_,
196 NULL, 192 NULL,
197 border_box, 193 border_box,
198 arrow_location, 194 arrow_location,
199 being_inspected_ ? 0 : 195 being_inspected_ ? 0 :
200 BubbleGtk::POPUP_WINDOW | BubbleGtk::GRAB_INPUT, 196 BubbleGtk::POPUP_WINDOW | BubbleGtk::GRAB_INPUT,
201 GtkThemeService::GetFrom(browser_->profile()), 197 GtkThemeService::GetFrom(browser_->profile()),
202 this); 198 this);
203 } 199 }
204 200
205 void ExtensionPopupGtk::DestroyPopupWithoutResult() { 201 void ExtensionPopupGtk::DestroyPopupWithoutResult() {
206 DestroyPopup(); 202 DestroyPopup();
207 } 203 }
208 204
209 gfx::Rect ExtensionPopupGtk::GetViewBounds() { 205 gfx::Rect ExtensionPopupGtk::GetViewBounds() {
210 GtkAllocation allocation; 206 GtkAllocation allocation;
211 gtk_widget_get_allocation(host_->GetExtensionView()->GetNativeView(), 207 gtk_widget_get_allocation(host_->view()->native_view(), &allocation);
212 &allocation);
213 return gfx::Rect(allocation); 208 return gfx::Rect(allocation);
214 } 209 }
OLDNEW
« no previous file with comments | « chrome/browser/ui/gtk/extensions/extension_popup_gtk.h ('k') | chrome/browser/ui/gtk/extensions/extension_view_gtk.h » ('j') | no next file with comments »

Powered by Google App Engine
This is Rietveld 408576698