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

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

Issue 2753005: Infobars on GTK (first part).... (Closed) Base URL: svn://chrome-svn/chrome/trunk/src/
Patch Set: Created 10 years, 6 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
« no previous file with comments | « chrome/browser/gtk/extension_infobar_gtk.h ('k') | chrome/chrome_browser.gypi » ('j') | no next file with comments »
Toggle Intra-line Diffs ('i') | Expand Comments ('e') | Collapse Comments ('c') | Show Comments Hide Comments ('s')
Property Changes:
Added: svn:eol-style
+ LF
OLDNEW
(Empty)
1 // Copyright (c) 2010 The Chromium Authors. All rights reserved.
2 // Use of this source code is governed by a BSD-style license that can be
3 // found in the LICENSE file.
4
5 #include "chrome/browser/gtk/extension_infobar_gtk.h"
6
7 #include "app/resource_bundle.h"
8 #include "chrome/browser/extensions/extension_host.h"
9 #include "chrome/common/extensions/extension.h"
10 #include "chrome/common/extensions/extension_resource.h"
11 #include "gfx/gtk_util.h"
12 #include "grit/theme_resources.h"
13
14 ExtensionInfoBarGtk::ExtensionInfoBarGtk(ExtensionInfoBarDelegate* delegate)
15 : InfoBar(delegate),
16 tracker_(this),
17 delegate_(delegate),
18 view_(NULL) {
19 BuildWidgets();
20 }
21
22 ExtensionInfoBarGtk::~ExtensionInfoBarGtk() {
23 // This view is not owned by us, so unparent.
24 gtk_widget_unparent(view_->native_view());
25 }
26
27 void ExtensionInfoBarGtk::OnImageLoaded(
28 SkBitmap* image, ExtensionResource resource, int index) {
29 if (!delegate_)
30 return; // The delegate can go away while we asynchronously load images.
31
32 ResourceBundle& rb = ResourceBundle::GetSharedInstance();
33
34 SkBitmap* icon;
35 if (!image || image->empty())
36 icon = rb.GetBitmapNamed(IDR_EXTENSIONS_SECTION);
37 else
38 icon = image;
39
40 // TODO(finnur): We now have the icon for the menu button, show the menu
41 // button and layout.
42 }
43
44 void ExtensionInfoBarGtk::BuildWidgets() {
45 // Start loading the image for the menu button.
46 ExtensionResource icon_resource;
47 Extension* extension = delegate_->extension_host()->extension();
48 Extension::Icons size =
49 extension->GetIconPathAllowLargerSize(&icon_resource,
50 Extension::EXTENSION_ICON_BITTY);
51 if (!icon_resource.relative_path().empty()) {
52 // Create a tracker to load the image. It will report back on OnImageLoaded.
53 tracker_.LoadImage(extension, icon_resource, gfx::Size(size, size),
54 ImageLoadingTracker::DONT_CACHE);
55 } else {
56 OnImageLoaded(NULL, icon_resource, 0); // |image|, |index|.
57 }
58
59 ExtensionHost* extension_host = delegate_->extension_host();
60 view_ = extension_host->view();
61 gtk_box_pack_start(GTK_BOX(hbox_), view_->native_view(), TRUE, TRUE, 0);
62
63 g_signal_connect(view_->native_view(), "size_allocate",
64 G_CALLBACK(&OnSizeAllocateThunk), this);
65 gtk_widget_show_all(border_bin_.get());
66 }
67
68 void ExtensionInfoBarGtk::OnSizeAllocate(GtkWidget* widget,
69 GtkAllocation* allocation) {
70 gfx::Size new_size(allocation->width, allocation->height);
71
72 // TODO(finnur): Size the infobar based on HTML content (up to 72 pixels).
73 }
74
75 InfoBar* ExtensionInfoBarDelegate::CreateInfoBar() {
76 return new ExtensionInfoBarGtk(this);
77 }
OLDNEW
« no previous file with comments | « chrome/browser/gtk/extension_infobar_gtk.h ('k') | chrome/chrome_browser.gypi » ('j') | no next file with comments »

Powered by Google App Engine
This is Rietveld 408576698