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

Side by Side Diff: chrome/browser/extensions/browser_action_test_util_gtk.cc

Issue 10855154: Update browserAction.setIcon and pageAction.setIcon for hidpi (Closed) Base URL: svn://svn.chromium.org/chrome/trunk/src
Patch Set: nits Created 8 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) 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/extensions/browser_action_test_util.h" 5 #include "chrome/browser/extensions/browser_action_test_util.h"
6 6
7 #include <gtk/gtk.h> 7 #include <gtk/gtk.h>
8 8
9 #include "chrome/browser/ui/browser.h" 9 #include "chrome/browser/ui/browser.h"
10 #include "chrome/browser/ui/browser_window.h" 10 #include "chrome/browser/ui/browser_window.h"
11 #include "chrome/browser/ui/gtk/extensions/extension_popup_gtk.h" 11 #include "chrome/browser/ui/gtk/extensions/extension_popup_gtk.h"
12 #include "chrome/browser/ui/gtk/extensions/extension_view_gtk.h" 12 #include "chrome/browser/ui/gtk/extensions/extension_view_gtk.h"
13 #include "chrome/browser/ui/gtk/view_id_util.h" 13 #include "chrome/browser/ui/gtk/view_id_util.h"
14 #include "ui/gfx/image/image.h"
14 15
15 namespace { 16 namespace {
16 17
17 GtkWidget* GetButton(Browser* browser, int index) { 18 GtkWidget* GetButton(Browser* browser, int index) {
18 GtkWidget* toolbar = 19 GtkWidget* toolbar =
19 ViewIDUtil::GetWidget(GTK_WIDGET(browser->window()->GetNativeWindow()), 20 ViewIDUtil::GetWidget(GTK_WIDGET(browser->window()->GetNativeWindow()),
20 VIEW_ID_BROWSER_ACTION_TOOLBAR); 21 VIEW_ID_BROWSER_ACTION_TOOLBAR);
21 GtkWidget* button = NULL; 22 GtkWidget* button = NULL;
22 if (toolbar) { 23 if (toolbar) {
23 GList* children = gtk_container_get_children(GTK_CONTAINER(toolbar)); 24 GList* children = gtk_container_get_children(GTK_CONTAINER(toolbar));
(...skipping 18 matching lines...) Expand all
42 g_list_free(children); 43 g_list_free(children);
43 } 44 }
44 return count; 45 return count;
45 } 46 }
46 47
47 bool BrowserActionTestUtil::HasIcon(int index) { 48 bool BrowserActionTestUtil::HasIcon(int index) {
48 GtkWidget* button = GetButton(browser_, index); 49 GtkWidget* button = GetButton(browser_, index);
49 return gtk_button_get_image(GTK_BUTTON(button)) != NULL; 50 return gtk_button_get_image(GTK_BUTTON(button)) != NULL;
50 } 51 }
51 52
53 gfx::Image BrowserActionTestUtil::GetIcon(int index) {
54 GtkWidget* button = GetButton(browser_, index);
55 GtkWidget* image = gtk_button_get_image(GTK_BUTTON(button));
56 GdkPixbuf* pixbuf = gtk_image_get_pixbuf(GTK_IMAGE(image));
57 // gfx::Image takes ownership of the |pixbuf| reference. We have to increase
58 // the ref count so |pixbuf| stays around when the image object is destroyed.
59 g_object_ref(pixbuf);
60 return gfx::Image(pixbuf);
61 }
62
52 void BrowserActionTestUtil::Press(int index) { 63 void BrowserActionTestUtil::Press(int index) {
53 GtkWidget* button = GetButton(browser_, index); 64 GtkWidget* button = GetButton(browser_, index);
54 gtk_button_clicked(GTK_BUTTON(button)); 65 gtk_button_clicked(GTK_BUTTON(button));
55 } 66 }
56 67
57 std::string BrowserActionTestUtil::GetTooltip(int index) { 68 std::string BrowserActionTestUtil::GetTooltip(int index) {
58 GtkWidget* button = GetButton(browser_, index); 69 GtkWidget* button = GetButton(browser_, index);
59 gchar* text = gtk_widget_get_tooltip_text(button); 70 gchar* text = gtk_widget_get_tooltip_text(button);
60 std::string tooltip(text); 71 std::string tooltip(text);
61 g_free(text); 72 g_free(text);
(...skipping 21 matching lines...) Expand all
83 // static 94 // static
84 gfx::Size BrowserActionTestUtil::GetMinPopupSize() { 95 gfx::Size BrowserActionTestUtil::GetMinPopupSize() {
85 // On Linux we actually just limit the size of the extension view. 96 // On Linux we actually just limit the size of the extension view.
86 return gfx::Size(ExtensionPopupGtk::kMinWidth, ExtensionPopupGtk::kMinHeight); 97 return gfx::Size(ExtensionPopupGtk::kMinWidth, ExtensionPopupGtk::kMinHeight);
87 } 98 }
88 99
89 // static 100 // static
90 gfx::Size BrowserActionTestUtil::GetMaxPopupSize() { 101 gfx::Size BrowserActionTestUtil::GetMaxPopupSize() {
91 return gfx::Size(ExtensionPopupGtk::kMaxWidth, ExtensionPopupGtk::kMaxHeight); 102 return gfx::Size(ExtensionPopupGtk::kMaxWidth, ExtensionPopupGtk::kMaxHeight);
92 } 103 }
OLDNEW

Powered by Google App Engine
This is Rietveld 408576698