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

Side by Side Diff: chrome/browser/ui/gtk/global_error_bubble.cc

Issue 15745022: Add custom icon support to GlobalError. Show extension icon in permissions increase bubble. (Closed) Base URL: svn://svn.chromium.org/chrome/trunk/src
Patch Set: Created 7 years, 7 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/global_error_bubble.h" 5 #include "chrome/browser/ui/gtk/global_error_bubble.h"
6 6
7 #include <gtk/gtk.h> 7 #include <gtk/gtk.h>
8 8
9 #include "base/i18n/rtl.h" 9 #include "base/i18n/rtl.h"
10 #include "base/utf_string_conversions.h" 10 #include "base/utf_string_conversions.h"
(...skipping 30 matching lines...) Expand all
41 DCHECK(browser_); 41 DCHECK(browser_);
42 DCHECK(error_); 42 DCHECK(error_);
43 GtkWidget* content = gtk_vbox_new(FALSE, ui::kControlSpacing); 43 GtkWidget* content = gtk_vbox_new(FALSE, ui::kControlSpacing);
44 gtk_container_set_border_width(GTK_CONTAINER(content), 44 gtk_container_set_border_width(GTK_CONTAINER(content),
45 ui::kContentAreaBorder); 45 ui::kContentAreaBorder);
46 g_signal_connect(content, "destroy", G_CALLBACK(OnDestroyThunk), this); 46 g_signal_connect(content, "destroy", G_CALLBACK(OnDestroyThunk), this);
47 47
48 GtkThemeService* theme_service = 48 GtkThemeService* theme_service =
49 GtkThemeService::GetFrom(browser_->profile()); 49 GtkThemeService::GetFrom(browser_->profile());
50 50
51 int resource_id = error_->GetBubbleViewIconResourceID(); 51 gfx::Image* image = error_->GetBubbleViewCustomIcon();
52 ui::ResourceBundle& rb = ui::ResourceBundle::GetSharedInstance(); 52 if (!image) {
53 GdkPixbuf* pixbuf = rb.GetNativeImageNamed(resource_id).ToGdkPixbuf(); 53 int resource_id = error_->GetBubbleViewIconResourceID();
54 ui::ResourceBundle& rb = ui::ResourceBundle::GetSharedInstance();
55 image = &rb.GetNativeImageNamed(resource_id);
56 }
57 GdkPixbuf* pixbuf = image->ToGdkPixbuf();
54 GtkWidget* image_view = gtk_image_new_from_pixbuf(pixbuf); 58 GtkWidget* image_view = gtk_image_new_from_pixbuf(pixbuf);
55 59
56 GtkWidget* title_label = theme_service->BuildLabel( 60 GtkWidget* title_label = theme_service->BuildLabel(
57 UTF16ToUTF8(error_->GetBubbleViewTitle()), 61 UTF16ToUTF8(error_->GetBubbleViewTitle()),
58 ui::kGdkBlack); 62 ui::kGdkBlack);
59 std::vector<string16> messages = error_->GetBubbleViewMessages(); 63 std::vector<string16> messages = error_->GetBubbleViewMessages();
60 for (size_t i = 0; i < messages.size(); ++i) { 64 for (size_t i = 0; i < messages.size(); ++i) {
61 message_labels_.push_back(theme_service->BuildLabel( 65 message_labels_.push_back(theme_service->BuildLabel(
62 UTF16ToUTF8(messages[i]), 66 UTF16ToUTF8(messages[i]),
63 ui::kGdkBlack)); 67 ui::kGdkBlack));
(...skipping 94 matching lines...) Expand 10 before | Expand all | Expand 10 after
158 Browser* browser, 162 Browser* browser,
159 const base::WeakPtr<GlobalError>& error) { 163 const base::WeakPtr<GlobalError>& error) {
160 BrowserWindowGtk* browser_window = 164 BrowserWindowGtk* browser_window =
161 BrowserWindowGtk::GetBrowserWindowForNativeWindow( 165 BrowserWindowGtk::GetBrowserWindowForNativeWindow(
162 browser->window()->GetNativeWindow()); 166 browser->window()->GetNativeWindow());
163 GtkWidget* anchor = browser_window->GetToolbar()->GetAppMenuButton(); 167 GtkWidget* anchor = browser_window->GetToolbar()->GetAppMenuButton();
164 168
165 // The bubble will be automatically deleted when it's closed. 169 // The bubble will be automatically deleted when it's closed.
166 return new GlobalErrorBubble(browser, error, anchor); 170 return new GlobalErrorBubble(browser, error, anchor);
167 } 171 }
OLDNEW

Powered by Google App Engine
This is Rietveld 408576698