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

Side by Side Diff: chrome/browser/ui/gtk/infobars/extension_infobar_gtk.cc

Issue 10913243: extensions: Add ExtensionView interface. (Closed) Base URL: svn://svn.chromium.org/chrome/trunk/src
Patch Set: weak 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/infobars/extension_infobar_gtk.h" 5 #include "chrome/browser/ui/gtk/infobars/extension_infobar_gtk.h"
6 6
7 #include "base/debug/trace_event.h" 7 #include "base/debug/trace_event.h"
8 #include "chrome/browser/extensions/extension_context_menu_model.h" 8 #include "chrome/browser/extensions/extension_context_menu_model.h"
9 #include "chrome/browser/extensions/extension_host.h" 9 #include "chrome/browser/extensions/extension_host.h"
10 #include "chrome/browser/extensions/extension_view.h"
10 #include "chrome/browser/infobars/infobar_tab_helper.h" 11 #include "chrome/browser/infobars/infobar_tab_helper.h"
11 #include "chrome/browser/platform_util.h" 12 #include "chrome/browser/platform_util.h"
12 #include "chrome/browser/ui/gtk/browser_window_gtk.h" 13 #include "chrome/browser/ui/gtk/browser_window_gtk.h"
13 #include "chrome/browser/ui/gtk/custom_button.h" 14 #include "chrome/browser/ui/gtk/custom_button.h"
14 #include "chrome/browser/ui/gtk/gtk_chrome_button.h" 15 #include "chrome/browser/ui/gtk/gtk_chrome_button.h"
15 #include "chrome/browser/ui/gtk/gtk_util.h" 16 #include "chrome/browser/ui/gtk/gtk_util.h"
16 #include "chrome/browser/ui/gtk/infobars/infobar_container_gtk.h" 17 #include "chrome/browser/ui/gtk/infobars/infobar_container_gtk.h"
17 #include "chrome/common/extensions/extension.h" 18 #include "chrome/common/extensions/extension.h"
18 #include "chrome/common/extensions/extension_constants.h" 19 #include "chrome/common/extensions/extension_constants.h"
19 #include "chrome/common/extensions/extension_icon_set.h" 20 #include "chrome/common/extensions/extension_icon_set.h"
(...skipping 24 matching lines...) Expand all
44 SetBarTargetHeight((height > 0) ? (height + kSeparatorLineHeight) : 0); 45 SetBarTargetHeight((height > 0) ? (height + kSeparatorLineHeight) : 0);
45 46
46 BuildWidgets(); 47 BuildWidgets();
47 } 48 }
48 49
49 ExtensionInfoBarGtk::~ExtensionInfoBarGtk() {} 50 ExtensionInfoBarGtk::~ExtensionInfoBarGtk() {}
50 51
51 void ExtensionInfoBarGtk::PlatformSpecificHide(bool animate) { 52 void ExtensionInfoBarGtk::PlatformSpecificHide(bool animate) {
52 // This view is not owned by us; we can't unparent it because we aren't the 53 // This view is not owned by us; we can't unparent it because we aren't the
53 // owning container. 54 // owning container.
54 gtk_container_remove(GTK_CONTAINER(alignment_), view_->native_view()); 55 gtk_container_remove(GTK_CONTAINER(alignment_), view_->GetNativeView());
55 } 56 }
56 57
57 void ExtensionInfoBarGtk::GetTopColor(InfoBarDelegate::Type type, 58 void ExtensionInfoBarGtk::GetTopColor(InfoBarDelegate::Type type,
58 double* r, double* g, double* b) { 59 double* r, double* g, double* b) {
59 // Extension infobars are always drawn with chrome-theme colors. 60 // Extension infobars are always drawn with chrome-theme colors.
60 *r = *g = *b = 233.0 / 255.0; 61 *r = *g = *b = 233.0 / 255.0;
61 } 62 }
62 63
63 void ExtensionInfoBarGtk::GetBottomColor(InfoBarDelegate::Type type, 64 void ExtensionInfoBarGtk::GetBottomColor(InfoBarDelegate::Type type,
64 double* r, double* g, double* b) { 65 double* r, double* g, double* b) {
(...skipping 55 matching lines...) Expand 10 before | Expand all | Expand 10 after
120 gfx::Size(extension_misc::EXTENSION_ICON_BITTY, 121 gfx::Size(extension_misc::EXTENSION_ICON_BITTY,
121 extension_misc::EXTENSION_ICON_BITTY), 122 extension_misc::EXTENSION_ICON_BITTY),
122 ImageLoadingTracker::DONT_CACHE); 123 ImageLoadingTracker::DONT_CACHE);
123 124
124 // Pad the bottom of the infobar by one pixel for the border. 125 // Pad the bottom of the infobar by one pixel for the border.
125 alignment_ = gtk_alignment_new(0.0, 0.0, 1.0, 1.0); 126 alignment_ = gtk_alignment_new(0.0, 0.0, 1.0, 1.0);
126 gtk_alignment_set_padding(GTK_ALIGNMENT(alignment_), 0, 1, 0, 0); 127 gtk_alignment_set_padding(GTK_ALIGNMENT(alignment_), 0, 1, 0, 0);
127 gtk_box_pack_start(GTK_BOX(hbox_), alignment_, TRUE, TRUE, 0); 128 gtk_box_pack_start(GTK_BOX(hbox_), alignment_, TRUE, TRUE, 0);
128 129
129 extensions::ExtensionHost* extension_host = delegate_->extension_host(); 130 extensions::ExtensionHost* extension_host = delegate_->extension_host();
130 view_ = extension_host->view(); 131 view_ = extension_host->GetExtensionView();
131 132
132 if (gtk_widget_get_parent(view_->native_view())) { 133 if (gtk_widget_get_parent(view_->GetNativeView())) {
133 gtk_widget_reparent(view_->native_view(), alignment_); 134 gtk_widget_reparent(view_->GetNativeView(), alignment_);
134 } else { 135 } else {
135 gtk_container_add(GTK_CONTAINER(alignment_), view_->native_view()); 136 gtk_container_add(GTK_CONTAINER(alignment_), view_->GetNativeView());
136 } 137 }
137 138
138 Signals()->Connect(button_, "button-press-event", 139 Signals()->Connect(button_, "button-press-event",
139 G_CALLBACK(&OnButtonPressThunk), this); 140 G_CALLBACK(&OnButtonPressThunk), this);
140 Signals()->Connect(view_->native_view(), "expose-event", 141 Signals()->Connect(view_->GetNativeView(), "expose-event",
141 G_CALLBACK(&OnExposeThunk), this); 142 G_CALLBACK(&OnExposeThunk), this);
142 Signals()->Connect(view_->native_view(), "size_allocate", 143 Signals()->Connect(view_->GetNativeView(), "size_allocate",
143 G_CALLBACK(&OnSizeAllocateThunk), this); 144 G_CALLBACK(&OnSizeAllocateThunk), this);
144 } 145 }
145 146
146 void ExtensionInfoBarGtk::StoppedShowing() { 147 void ExtensionInfoBarGtk::StoppedShowing() {
147 gtk_chrome_button_unset_paint_state(GTK_CHROME_BUTTON(button_)); 148 gtk_chrome_button_unset_paint_state(GTK_CHROME_BUTTON(button_));
148 } 149 }
149 150
150 Browser* ExtensionInfoBarGtk::GetBrowser() { 151 Browser* ExtensionInfoBarGtk::GetBrowser() {
151 // Get the Browser object this infobar is attached to. 152 // Get the Browser object this infobar is attached to.
152 GtkWindow* parent = platform_util::GetTopLevel(icon_); 153 GtkWindow* parent = platform_util::GetTopLevel(icon_);
(...skipping 12 matching lines...) Expand all
165 if (!browser) 166 if (!browser)
166 return NULL; 167 return NULL;
167 168
168 return new ExtensionContextMenuModel(extension, browser); 169 return new ExtensionContextMenuModel(extension, browser);
169 } 170 }
170 171
171 void ExtensionInfoBarGtk::OnSizeAllocate(GtkWidget* widget, 172 void ExtensionInfoBarGtk::OnSizeAllocate(GtkWidget* widget,
172 GtkAllocation* allocation) { 173 GtkAllocation* allocation) {
173 gfx::Size new_size(allocation->width, allocation->height); 174 gfx::Size new_size(allocation->width, allocation->height);
174 175
175 delegate_->extension_host()->view()->render_view_host()->GetView() 176 delegate_->extension_host()->GetExtensionView()->GetRenderViewHost()->
176 ->SetSize(new_size); 177 GetView()->SetSize(new_size);
177 } 178 }
178 179
179 gboolean ExtensionInfoBarGtk::OnButtonPress(GtkWidget* widget, 180 gboolean ExtensionInfoBarGtk::OnButtonPress(GtkWidget* widget,
180 GdkEventButton* event) { 181 GdkEventButton* event) {
181 if (event->button != 1) 182 if (event->button != 1)
182 return FALSE; 183 return FALSE;
183 184
184 ui::MenuModel* model = BuildMenuModel(); 185 ui::MenuModel* model = BuildMenuModel();
185 if (!model) 186 if (!model)
186 return FALSE; 187 return FALSE;
(...skipping 12 matching lines...) Expand all
199 // We also need to draw our infobar arrows over the renderer. 200 // We also need to draw our infobar arrows over the renderer.
200 static_cast<InfoBarContainerGtk*>(container())-> 201 static_cast<InfoBarContainerGtk*>(container())->
201 PaintInfobarBitsOn(sender, event, this); 202 PaintInfobarBitsOn(sender, event, this);
202 203
203 return FALSE; 204 return FALSE;
204 } 205 }
205 206
206 InfoBar* ExtensionInfoBarDelegate::CreateInfoBar(InfoBarService* owner) { 207 InfoBar* ExtensionInfoBarDelegate::CreateInfoBar(InfoBarService* owner) {
207 return new ExtensionInfoBarGtk(static_cast<InfoBarTabHelper*>(owner), this); 208 return new ExtensionInfoBarGtk(static_cast<InfoBarTabHelper*>(owner), this);
208 } 209 }
OLDNEW
« no previous file with comments | « chrome/browser/ui/gtk/infobars/extension_infobar_gtk.h ('k') | chrome/browser/ui/views/extensions/extension_dialog.h » ('j') | no next file with comments »

Powered by Google App Engine
This is Rietveld 408576698