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

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

Issue 7635019: Set Extension Infobars to have a fixed height determined by the developer (clamped to sane min an... (Closed) Base URL: svn://svn.chromium.org/chrome/trunk/src/
Patch Set: '' Created 9 years, 4 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) 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/gtk/infobars/extension_infobar_gtk.h" 5 #include "chrome/browser/ui/gtk/infobars/extension_infobar_gtk.h"
6 6
7 #include "chrome/browser/extensions/extension_host.h" 7 #include "chrome/browser/extensions/extension_host.h"
8 #include "chrome/common/extensions/extension.h" 8 #include "chrome/common/extensions/extension.h"
9 #include "chrome/common/extensions/extension_icon_set.h" 9 #include "chrome/common/extensions/extension_icon_set.h"
10 #include "chrome/common/extensions/extension_resource.h" 10 #include "chrome/common/extensions/extension_resource.h"
11 #include "content/browser/renderer_host/render_view_host.h" 11 #include "content/browser/renderer_host/render_view_host.h"
12 #include "content/browser/renderer_host/render_widget_host_view.h" 12 #include "content/browser/renderer_host/render_widget_host_view.h"
13 #include "grit/theme_resources.h" 13 #include "grit/theme_resources.h"
14 #include "ui/base/resource/resource_bundle.h" 14 #include "ui/base/resource/resource_bundle.h"
15 #include "ui/gfx/gtk_util.h" 15 #include "ui/gfx/gtk_util.h"
16 16
17 ExtensionInfoBarGtk::ExtensionInfoBarGtk(TabContentsWrapper* owner, 17 ExtensionInfoBarGtk::ExtensionInfoBarGtk(TabContentsWrapper* owner,
18 ExtensionInfoBarDelegate* delegate) 18 ExtensionInfoBarDelegate* delegate)
19 : InfoBarGtk(owner, delegate), 19 : InfoBarGtk(owner, delegate),
20 tracker_(this), 20 tracker_(this),
21 delegate_(delegate), 21 delegate_(delegate),
22 view_(NULL) { 22 view_(NULL) {
23 delegate_->extension_host()->view()->SetContainer(this);
24 BuildWidgets(); 23 BuildWidgets();
25 } 24 }
26 25
27 ExtensionInfoBarGtk::~ExtensionInfoBarGtk() { 26 ExtensionInfoBarGtk::~ExtensionInfoBarGtk() {
28 // This view is not owned by us, so unparent. 27 // This view is not owned by us, so unparent.
29 gtk_widget_unparent(view_->native_view()); 28 gtk_widget_unparent(view_->native_view());
30 } 29 }
31 30
32 void ExtensionInfoBarGtk::OnImageLoaded( 31 void ExtensionInfoBarGtk::OnImageLoaded(
33 SkBitmap* image, const ExtensionResource& resource, int index) { 32 SkBitmap* image, const ExtensionResource& resource, int index) {
(...skipping 16 matching lines...) Expand all
50 const Extension* extension = delegate_->extension_host()->extension(); 49 const Extension* extension = delegate_->extension_host()->extension();
51 ExtensionResource icon_resource = extension->GetIconResource( 50 ExtensionResource icon_resource = extension->GetIconResource(
52 Extension::EXTENSION_ICON_BITTY, ExtensionIconSet::MATCH_EXACTLY); 51 Extension::EXTENSION_ICON_BITTY, ExtensionIconSet::MATCH_EXACTLY);
53 if (!icon_resource.relative_path().empty()) { 52 if (!icon_resource.relative_path().empty()) {
54 // Create a tracker to load the image. It will report back on OnImageLoaded. 53 // Create a tracker to load the image. It will report back on OnImageLoaded.
55 tracker_.LoadImage(extension, icon_resource, 54 tracker_.LoadImage(extension, icon_resource,
56 gfx::Size(Extension::EXTENSION_ICON_BITTY, 55 gfx::Size(Extension::EXTENSION_ICON_BITTY,
57 Extension::EXTENSION_ICON_BITTY), 56 Extension::EXTENSION_ICON_BITTY),
58 ImageLoadingTracker::DONT_CACHE); 57 ImageLoadingTracker::DONT_CACHE);
59 } else { 58 } else {
60 OnImageLoaded(NULL, icon_resource, 0); // |image|, |index|. 59 OnImageLoaded(NULL, icon_resource, 0); // |image|, ..., |index|.
Evan Stade 2011/08/16 18:35:04 this comment doesn't really help at all, I'd just
61 } 60 }
62 61
63 ExtensionHost* extension_host = delegate_->extension_host(); 62 ExtensionHost* extension_host = delegate_->extension_host();
64 view_ = extension_host->view(); 63 view_ = extension_host->view();
65 if (gtk_widget_get_parent(view_->native_view())) { 64 if (gtk_widget_get_parent(view_->native_view())) {
66 gtk_widget_reparent(view_->native_view(), hbox_); 65 gtk_widget_reparent(view_->native_view(), hbox_);
67 gtk_box_set_child_packing(GTK_BOX(hbox_), view_->native_view(), 66 gtk_box_set_child_packing(GTK_BOX(hbox_), view_->native_view(),
68 TRUE, TRUE, 0, GTK_PACK_START); 67 TRUE, TRUE, 0, GTK_PACK_START);
69 } else { 68 } else {
70 gtk_box_pack_start(GTK_BOX(hbox_), view_->native_view(), TRUE, TRUE, 0); 69 gtk_box_pack_start(GTK_BOX(hbox_), view_->native_view(), TRUE, TRUE, 0);
71 } 70 }
72 71
73 g_signal_connect(view_->native_view(), "size_allocate", 72 g_signal_connect(view_->native_view(), "size_allocate",
74 G_CALLBACK(&OnSizeAllocateThunk), this); 73 G_CALLBACK(&OnSizeAllocateThunk), this);
75 } 74 }
76 75
77 void ExtensionInfoBarGtk::OnSizeAllocate(GtkWidget* widget, 76 void ExtensionInfoBarGtk::OnSizeAllocate(GtkWidget* widget,
78 GtkAllocation* allocation) { 77 GtkAllocation* allocation) {
79 gfx::Size new_size(allocation->width, allocation->height); 78 gfx::Size new_size(allocation->width, allocation->height);
80 79
81 delegate_->extension_host()->view()->render_view_host()->view() 80 delegate_->extension_host()->view()->render_view_host()->view()
82 ->SetSize(new_size); 81 ->SetSize(new_size);
83 } 82 }
84 83
85 void ExtensionInfoBarGtk::OnExtensionPreferredSizeChanged(
86 ExtensionViewGtk* view,
87 const gfx::Size& new_size) {
88 // TODO(rafaelw) - Size the InfobarGtk vertically based on the preferred size
89 // of the content.
90 }
91
92 InfoBar* ExtensionInfoBarDelegate::CreateInfoBar(TabContentsWrapper* owner) { 84 InfoBar* ExtensionInfoBarDelegate::CreateInfoBar(TabContentsWrapper* owner) {
93 return new ExtensionInfoBarGtk(owner, this); 85 return new ExtensionInfoBarGtk(owner, this);
94 } 86 }
OLDNEW
« no previous file with comments | « chrome/browser/ui/gtk/infobars/extension_infobar_gtk.h ('k') | chrome/browser/ui/views/infobars/extension_infobar.h » ('j') | no next file with comments »

Powered by Google App Engine
This is Rietveld 408576698