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

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: no defaults Created 7 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
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"
11 #include "chrome/browser/ui/browser.h" 11 #include "chrome/browser/ui/browser.h"
12 #include "chrome/browser/ui/global_error/global_error.h" 12 #include "chrome/browser/ui/global_error/global_error.h"
13 #include "chrome/browser/ui/global_error/global_error_service.h" 13 #include "chrome/browser/ui/global_error/global_error_service.h"
14 #include "chrome/browser/ui/global_error/global_error_service_factory.h" 14 #include "chrome/browser/ui/global_error/global_error_service_factory.h"
15 #include "chrome/browser/ui/gtk/browser_toolbar_gtk.h" 15 #include "chrome/browser/ui/gtk/browser_toolbar_gtk.h"
16 #include "chrome/browser/ui/gtk/browser_window_gtk.h" 16 #include "chrome/browser/ui/gtk/browser_window_gtk.h"
17 #include "chrome/browser/ui/gtk/gtk_theme_service.h" 17 #include "chrome/browser/ui/gtk/gtk_theme_service.h"
18 #include "chrome/browser/ui/gtk/gtk_util.h" 18 #include "chrome/browser/ui/gtk/gtk_util.h"
19 #include "ui/base/gtk/gtk_hig_constants.h" 19 #include "ui/base/gtk/gtk_hig_constants.h"
20 #include "ui/base/resource/resource_bundle.h"
21 #include "ui/gfx/gtk_util.h" 20 #include "ui/gfx/gtk_util.h"
22 #include "ui/gfx/image/image.h" 21 #include "ui/gfx/image/image.h"
23 22
24 namespace { 23 namespace {
25 24
26 // Text size of the message label. 12.1px = 9pt @ 96dpi. 25 // Text size of the message label. 12.1px = 9pt @ 96dpi.
27 const double kMessageTextSize = 12.1; 26 const double kMessageTextSize = 12.1;
28 27
29 // Minimum width of the message label. 28 // Minimum width of the message label.
30 const int kMinMessageLabelWidth = 250; 29 const int kMinMessageLabelWidth = 250;
(...skipping 10 matching lines...) Expand all
41 DCHECK(browser_); 40 DCHECK(browser_);
42 DCHECK(error_); 41 DCHECK(error_);
43 GtkWidget* content = gtk_vbox_new(FALSE, ui::kControlSpacing); 42 GtkWidget* content = gtk_vbox_new(FALSE, ui::kControlSpacing);
44 gtk_container_set_border_width(GTK_CONTAINER(content), 43 gtk_container_set_border_width(GTK_CONTAINER(content),
45 ui::kContentAreaBorder); 44 ui::kContentAreaBorder);
46 g_signal_connect(content, "destroy", G_CALLBACK(OnDestroyThunk), this); 45 g_signal_connect(content, "destroy", G_CALLBACK(OnDestroyThunk), this);
47 46
48 GtkThemeService* theme_service = 47 GtkThemeService* theme_service =
49 GtkThemeService::GetFrom(browser_->profile()); 48 GtkThemeService::GetFrom(browser_->profile());
50 49
51 int resource_id = error_->GetBubbleViewIconResourceID(); 50 gfx::Image image = error_->GetBubbleViewIcon();
52 ui::ResourceBundle& rb = ui::ResourceBundle::GetSharedInstance(); 51 CHECK(!image.IsEmpty());
53 GdkPixbuf* pixbuf = rb.GetNativeImageNamed(resource_id).ToGdkPixbuf(); 52 GdkPixbuf* pixbuf = image.ToGdkPixbuf();
54 GtkWidget* image_view = gtk_image_new_from_pixbuf(pixbuf); 53 GtkWidget* image_view = gtk_image_new_from_pixbuf(pixbuf);
55 54
56 GtkWidget* title_label = theme_service->BuildLabel( 55 GtkWidget* title_label = theme_service->BuildLabel(
57 UTF16ToUTF8(error_->GetBubbleViewTitle()), 56 UTF16ToUTF8(error_->GetBubbleViewTitle()),
58 ui::kGdkBlack); 57 ui::kGdkBlack);
59 std::vector<string16> messages = error_->GetBubbleViewMessages(); 58 std::vector<string16> messages = error_->GetBubbleViewMessages();
60 for (size_t i = 0; i < messages.size(); ++i) { 59 for (size_t i = 0; i < messages.size(); ++i) {
61 message_labels_.push_back(theme_service->BuildLabel( 60 message_labels_.push_back(theme_service->BuildLabel(
62 UTF16ToUTF8(messages[i]), 61 UTF16ToUTF8(messages[i]),
63 ui::kGdkBlack)); 62 ui::kGdkBlack));
(...skipping 94 matching lines...) Expand 10 before | Expand all | Expand 10 after
158 Browser* browser, 157 Browser* browser,
159 const base::WeakPtr<GlobalError>& error) { 158 const base::WeakPtr<GlobalError>& error) {
160 BrowserWindowGtk* browser_window = 159 BrowserWindowGtk* browser_window =
161 BrowserWindowGtk::GetBrowserWindowForNativeWindow( 160 BrowserWindowGtk::GetBrowserWindowForNativeWindow(
162 browser->window()->GetNativeWindow()); 161 browser->window()->GetNativeWindow());
163 GtkWidget* anchor = browser_window->GetToolbar()->GetAppMenuButton(); 162 GtkWidget* anchor = browser_window->GetToolbar()->GetAppMenuButton();
164 163
165 // The bubble will be automatically deleted when it's closed. 164 // The bubble will be automatically deleted when it's closed.
166 return new GlobalErrorBubble(browser, error, anchor); 165 return new GlobalErrorBubble(browser, error, anchor);
167 } 166 }
OLDNEW

Powered by Google App Engine
This is Rietveld 408576698