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

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

Issue 10905005: Change browser/page action default icon defined in manifest to support hidpi. (Closed) Base URL: svn://svn.chromium.org/chrome/trunk/src
Patch Set: review feedback Created 8 years, 3 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/location_bar_view_gtk.h" 5 #include "chrome/browser/ui/gtk/location_bar_view_gtk.h"
6 6
7 #include <algorithm> 7 #include <algorithm>
8 #include <string> 8 #include <string>
9 #include <vector> 9 #include <vector>
10 10
(...skipping 1768 matching lines...) Expand 10 before | Expand all | Expand 10 after
1779 } 1779 }
1780 1780
1781 //////////////////////////////////////////////////////////////////////////////// 1781 ////////////////////////////////////////////////////////////////////////////////
1782 // LocationBarViewGtk::PageActionViewGtk 1782 // LocationBarViewGtk::PageActionViewGtk
1783 1783
1784 LocationBarViewGtk::PageActionViewGtk::PageActionViewGtk( 1784 LocationBarViewGtk::PageActionViewGtk::PageActionViewGtk(
1785 LocationBarViewGtk* owner, 1785 LocationBarViewGtk* owner,
1786 ExtensionAction* page_action) 1786 ExtensionAction* page_action)
1787 : owner_(NULL), 1787 : owner_(NULL),
1788 page_action_(page_action), 1788 page_action_(page_action),
1789 tracker_(this),
1790 current_tab_id_(-1), 1789 current_tab_id_(-1),
1791 window_(NULL), 1790 window_(NULL),
1792 accel_group_(NULL), 1791 accel_group_(NULL),
1793 preview_enabled_(false), 1792 preview_enabled_(false),
1794 ALLOW_THIS_IN_INITIALIZER_LIST(scoped_icon_animation_observer_( 1793 ALLOW_THIS_IN_INITIALIZER_LIST(scoped_icon_animation_observer_(
1795 page_action->GetIconAnimation( 1794 page_action->GetIconAnimation(
1796 SessionID::IdForTab(owner->GetTabContents()->web_contents())), 1795 SessionID::IdForTab(owner->GetTabContents()->web_contents())),
1797 this)) { 1796 this)) {
1798 event_box_.Own(gtk_event_box_new()); 1797 event_box_.Own(gtk_event_box_new());
1799 gtk_widget_set_size_request(event_box_.get(), 1798 gtk_widget_set_size_request(event_box_.get(),
(...skipping 10 matching lines...) Expand all
1810 G_CALLBACK(OnRealizeThunk), this); 1809 G_CALLBACK(OnRealizeThunk), this);
1811 1810
1812 image_.Own(gtk_image_new()); 1811 image_.Own(gtk_image_new());
1813 gtk_container_add(GTK_CONTAINER(event_box_.get()), image_.get()); 1812 gtk_container_add(GTK_CONTAINER(event_box_.get()), image_.get());
1814 1813
1815 const Extension* extension = owner->browser()->profile()-> 1814 const Extension* extension = owner->browser()->profile()->
1816 GetExtensionService()->GetExtensionById(page_action->extension_id(), 1815 GetExtensionService()->GetExtensionById(page_action->extension_id(),
1817 false); 1816 false);
1818 DCHECK(extension); 1817 DCHECK(extension);
1819 1818
1820 std::string path = page_action_->default_icon_path(); 1819 icon_factory_.reset(
1821 if (!path.empty()) { 1820 new ExtensionActionIconFactory(extension, page_action, this));
1822 tracker_.LoadImage(extension, extension->GetResource(path),
1823 gfx::Size(Extension::kPageActionIconMaxSize,
1824 Extension::kPageActionIconMaxSize),
1825 ImageLoadingTracker::DONT_CACHE);
1826 }
1827 1821
1828 // We set the owner last of all so that we can determine whether we are in 1822 // We set the owner last of all so that we can determine whether we are in
1829 // the process of initializing this class or not. 1823 // the process of initializing this class or not.
1830 owner_ = owner; 1824 owner_ = owner;
1831 } 1825 }
1832 1826
1833 LocationBarViewGtk::PageActionViewGtk::~PageActionViewGtk() { 1827 LocationBarViewGtk::PageActionViewGtk::~PageActionViewGtk() {
1834 DisconnectPageActionAccelerator(); 1828 DisconnectPageActionAccelerator();
1835 1829
1836 image_.Destroy(); 1830 image_.Destroy();
(...skipping 12 matching lines...) Expand all
1849 current_url_ = url; 1843 current_url_ = url;
1850 1844
1851 bool visible = contents && 1845 bool visible = contents &&
1852 (preview_enabled_ || page_action_->GetIsVisible(current_tab_id_)); 1846 (preview_enabled_ || page_action_->GetIsVisible(current_tab_id_));
1853 if (visible) { 1847 if (visible) {
1854 // Set the tooltip. 1848 // Set the tooltip.
1855 gtk_widget_set_tooltip_text(event_box_.get(), 1849 gtk_widget_set_tooltip_text(event_box_.get(),
1856 page_action_->GetTitle(current_tab_id_).c_str()); 1850 page_action_->GetTitle(current_tab_id_).c_str());
1857 1851
1858 // Set the image. 1852 // Set the image.
1859 gfx::Image icon = page_action_->GetIcon(current_tab_id_); 1853 gfx::Image icon = icon_factory_->GetIcon(current_tab_id_);
1860 if (!icon.IsEmpty()) { 1854 if (!icon.IsEmpty()) {
1861 GdkPixbuf* pixbuf = icon.ToGdkPixbuf(); 1855 GdkPixbuf* pixbuf = icon.ToGdkPixbuf();
1862 DCHECK(pixbuf); 1856 DCHECK(pixbuf);
1863 gtk_image_set_from_pixbuf(GTK_IMAGE(image_.get()), pixbuf); 1857 gtk_image_set_from_pixbuf(GTK_IMAGE(image_.get()), pixbuf);
1864 } 1858 }
1865 } 1859 }
1866 1860
1867 bool old_visible = IsVisible(); 1861 bool old_visible = IsVisible();
1868 if (visible) 1862 if (visible)
1869 gtk_widget_show_all(event_box_.get()); 1863 gtk_widget_show_all(event_box_.get());
1870 else 1864 else
1871 gtk_widget_hide_all(event_box_.get()); 1865 gtk_widget_hide_all(event_box_.get());
1872 1866
1873 if (visible != old_visible) { 1867 if (visible != old_visible) {
1874 content::NotificationService::current()->Notify( 1868 content::NotificationService::current()->Notify(
1875 chrome::NOTIFICATION_EXTENSION_PAGE_ACTION_VISIBILITY_CHANGED, 1869 chrome::NOTIFICATION_EXTENSION_PAGE_ACTION_VISIBILITY_CHANGED,
1876 content::Source<ExtensionAction>(page_action_), 1870 content::Source<ExtensionAction>(page_action_),
1877 content::Details<WebContents>(contents)); 1871 content::Details<WebContents>(contents));
1878 } 1872 }
1879 } 1873 }
1880 1874
1881 void LocationBarViewGtk::PageActionViewGtk::OnImageLoaded( 1875 void LocationBarViewGtk::PageActionViewGtk::OnIconUpdated() {
1882 const gfx::Image& image,
1883 const std::string& extension_id,
1884 int index) {
1885 page_action_->CacheIcon(image);
1886
1887 // If we have no owner, that means this class is still being constructed. 1876 // If we have no owner, that means this class is still being constructed.
1888 TabContents* tab_contents = owner_ ? owner_->GetTabContents() : NULL; 1877 TabContents* tab_contents = owner_ ? owner_->GetTabContents() : NULL;
1889 if (tab_contents) 1878 if (tab_contents)
1890 UpdateVisibility(tab_contents->web_contents(), current_url_); 1879 UpdateVisibility(tab_contents->web_contents(), current_url_);
1891 } 1880 }
1892 1881
1893 void LocationBarViewGtk::PageActionViewGtk::TestActivatePageAction() { 1882 void LocationBarViewGtk::PageActionViewGtk::TestActivatePageAction() {
1894 GdkEventButton event = {}; 1883 GdkEventButton event = {};
1895 event.button = 1; 1884 event.button = 1;
1896 OnButtonPressed(widget(), &event); 1885 OnButtonPressed(widget(), &event);
(...skipping 200 matching lines...) Expand 10 before | Expand all | Expand 10 after
2097 } 2086 }
2098 2087
2099 void LocationBarViewGtk::PageActionViewGtk::InspectPopup( 2088 void LocationBarViewGtk::PageActionViewGtk::InspectPopup(
2100 ExtensionAction* action) { 2089 ExtensionAction* action) {
2101 ExtensionPopupGtk::Show( 2090 ExtensionPopupGtk::Show(
2102 action->GetPopupUrl(current_tab_id_), 2091 action->GetPopupUrl(current_tab_id_),
2103 owner_->browser_, 2092 owner_->browser_,
2104 event_box_.get(), 2093 event_box_.get(),
2105 ExtensionPopupGtk::SHOW_AND_INSPECT); 2094 ExtensionPopupGtk::SHOW_AND_INSPECT);
2106 } 2095 }
OLDNEW

Powered by Google App Engine
This is Rietveld 408576698