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

Unified 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 side-by-side diff with in-line comments
Download patch
« no previous file with comments | « chrome/browser/gtk/extension_infobar_gtk.h ('k') | chrome/chrome_browser.gypi » ('j') | no next file with comments »
Expand Comments ('e') | Collapse Comments ('c') | Show Comments Hide Comments ('s')
Index: chrome/browser/gtk/extension_infobar_gtk.cc
===================================================================
--- chrome/browser/gtk/extension_infobar_gtk.cc (revision 0)
+++ chrome/browser/gtk/extension_infobar_gtk.cc (revision 0)
@@ -0,0 +1,77 @@
+// Copyright (c) 2010 The Chromium Authors. All rights reserved.
+// Use of this source code is governed by a BSD-style license that can be
+// found in the LICENSE file.
+
+#include "chrome/browser/gtk/extension_infobar_gtk.h"
+
+#include "app/resource_bundle.h"
+#include "chrome/browser/extensions/extension_host.h"
+#include "chrome/common/extensions/extension.h"
+#include "chrome/common/extensions/extension_resource.h"
+#include "gfx/gtk_util.h"
+#include "grit/theme_resources.h"
+
+ExtensionInfoBarGtk::ExtensionInfoBarGtk(ExtensionInfoBarDelegate* delegate)
+ : InfoBar(delegate),
+ tracker_(this),
+ delegate_(delegate),
+ view_(NULL) {
+ BuildWidgets();
+}
+
+ExtensionInfoBarGtk::~ExtensionInfoBarGtk() {
+ // This view is not owned by us, so unparent.
+ gtk_widget_unparent(view_->native_view());
+}
+
+void ExtensionInfoBarGtk::OnImageLoaded(
+ SkBitmap* image, ExtensionResource resource, int index) {
+ if (!delegate_)
+ return; // The delegate can go away while we asynchronously load images.
+
+ ResourceBundle& rb = ResourceBundle::GetSharedInstance();
+
+ SkBitmap* icon;
+ if (!image || image->empty())
+ icon = rb.GetBitmapNamed(IDR_EXTENSIONS_SECTION);
+ else
+ icon = image;
+
+ // TODO(finnur): We now have the icon for the menu button, show the menu
+ // button and layout.
+}
+
+void ExtensionInfoBarGtk::BuildWidgets() {
+ // Start loading the image for the menu button.
+ ExtensionResource icon_resource;
+ Extension* extension = delegate_->extension_host()->extension();
+ Extension::Icons size =
+ extension->GetIconPathAllowLargerSize(&icon_resource,
+ Extension::EXTENSION_ICON_BITTY);
+ if (!icon_resource.relative_path().empty()) {
+ // Create a tracker to load the image. It will report back on OnImageLoaded.
+ tracker_.LoadImage(extension, icon_resource, gfx::Size(size, size),
+ ImageLoadingTracker::DONT_CACHE);
+ } else {
+ OnImageLoaded(NULL, icon_resource, 0); // |image|, |index|.
+ }
+
+ ExtensionHost* extension_host = delegate_->extension_host();
+ view_ = extension_host->view();
+ gtk_box_pack_start(GTK_BOX(hbox_), view_->native_view(), TRUE, TRUE, 0);
+
+ g_signal_connect(view_->native_view(), "size_allocate",
+ G_CALLBACK(&OnSizeAllocateThunk), this);
+ gtk_widget_show_all(border_bin_.get());
+}
+
+void ExtensionInfoBarGtk::OnSizeAllocate(GtkWidget* widget,
+ GtkAllocation* allocation) {
+ gfx::Size new_size(allocation->width, allocation->height);
+
+ // TODO(finnur): Size the infobar based on HTML content (up to 72 pixels).
+}
+
+InfoBar* ExtensionInfoBarDelegate::CreateInfoBar() {
+ return new ExtensionInfoBarGtk(this);
+}
Property changes on: chrome\browser\gtk\extension_infobar_gtk.cc
___________________________________________________________________
Added: svn:eol-style
+ LF
« 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