OLD | NEW |
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 1775 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
1786 current_url_ = url; | 1786 current_url_ = url; |
1787 | 1787 |
1788 bool visible = contents && | 1788 bool visible = contents && |
1789 (preview_enabled_ || page_action_->GetIsVisible(current_tab_id_)); | 1789 (preview_enabled_ || page_action_->GetIsVisible(current_tab_id_)); |
1790 if (visible) { | 1790 if (visible) { |
1791 // Set the tooltip. | 1791 // Set the tooltip. |
1792 gtk_widget_set_tooltip_text(event_box_.get(), | 1792 gtk_widget_set_tooltip_text(event_box_.get(), |
1793 page_action_->GetTitle(current_tab_id_).c_str()); | 1793 page_action_->GetTitle(current_tab_id_).c_str()); |
1794 | 1794 |
1795 // Set the image. | 1795 // Set the image. |
1796 gfx::Image icon = page_action_->GetIcon(current_tab_id_); | 1796 gfx::ImageSkia icon = page_action_->GetIcon(current_tab_id_); |
1797 if (!icon.IsEmpty()) { | 1797 if (!icon.empty()) { |
1798 GdkPixbuf* pixbuf = icon.ToGdkPixbuf(); | 1798 GdkPixbuf* pixbuf = gfx::GdkPixbufFromSkBitmap(*icon.bitmap()); |
1799 DCHECK(pixbuf); | 1799 DCHECK(pixbuf); |
1800 gtk_image_set_from_pixbuf(GTK_IMAGE(image_.get()), pixbuf); | 1800 gtk_image_set_from_pixbuf(GTK_IMAGE(image_.get()), pixbuf); |
1801 } | 1801 } |
1802 } | 1802 } |
1803 | 1803 |
1804 bool old_visible = IsVisible(); | 1804 bool old_visible = IsVisible(); |
1805 if (visible) | 1805 if (visible) |
1806 gtk_widget_show_all(event_box_.get()); | 1806 gtk_widget_show_all(event_box_.get()); |
1807 else | 1807 else |
1808 gtk_widget_hide_all(event_box_.get()); | 1808 gtk_widget_hide_all(event_box_.get()); |
(...skipping 12 matching lines...) Expand all Loading... |
1821 int index) { | 1821 int index) { |
1822 // We loaded icons()->size() icons, plus one extra if the page action had | 1822 // We loaded icons()->size() icons, plus one extra if the page action had |
1823 // a default icon. | 1823 // a default icon. |
1824 int total_icons = static_cast<int>(page_action_->icon_paths()->size()); | 1824 int total_icons = static_cast<int>(page_action_->icon_paths()->size()); |
1825 if (!page_action_->default_icon_path().empty()) | 1825 if (!page_action_->default_icon_path().empty()) |
1826 total_icons++; | 1826 total_icons++; |
1827 DCHECK(index < total_icons); | 1827 DCHECK(index < total_icons); |
1828 | 1828 |
1829 // Map the index of the loaded image back to its name. If we ever get an | 1829 // Map the index of the loaded image back to its name. If we ever get an |
1830 // index greater than the number of icons, it must be the default icon. | 1830 // index greater than the number of icons, it must be the default icon. |
1831 if (index < static_cast<int>(page_action_->icon_paths()->size())) | 1831 if (index < static_cast<int>(page_action_->icon_paths()->size())) { |
1832 page_action_->CacheIcon(page_action_->icon_paths()->at(index), image); | 1832 page_action_->CacheIcon(page_action_->icon_paths()->at(index), |
1833 else | 1833 *image.ToImageSkia()); |
1834 page_action_->CacheIcon(page_action_->default_icon_path(), image); | 1834 } else { |
| 1835 page_action_->CacheIcon(page_action_->default_icon_path(), |
| 1836 *image.ToImageSkia()); |
| 1837 } |
1835 | 1838 |
1836 // If we have no owner, that means this class is still being constructed. | 1839 // If we have no owner, that means this class is still being constructed. |
1837 TabContents* tab_contents = owner_ ? owner_->GetTabContents() : NULL; | 1840 TabContents* tab_contents = owner_ ? owner_->GetTabContents() : NULL; |
1838 if (tab_contents) | 1841 if (tab_contents) |
1839 UpdateVisibility(tab_contents->web_contents(), current_url_); | 1842 UpdateVisibility(tab_contents->web_contents(), current_url_); |
1840 } | 1843 } |
1841 | 1844 |
1842 void LocationBarViewGtk::PageActionViewGtk::TestActivatePageAction() { | 1845 void LocationBarViewGtk::PageActionViewGtk::TestActivatePageAction() { |
1843 GdkEventButton event = {}; | 1846 GdkEventButton event = {}; |
1844 event.button = 1; | 1847 event.button = 1; |
(...skipping 207 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
2052 } | 2055 } |
2053 | 2056 |
2054 void LocationBarViewGtk::PageActionViewGtk::InspectPopup( | 2057 void LocationBarViewGtk::PageActionViewGtk::InspectPopup( |
2055 ExtensionAction* action) { | 2058 ExtensionAction* action) { |
2056 ExtensionPopupGtk::Show( | 2059 ExtensionPopupGtk::Show( |
2057 action->GetPopupUrl(current_tab_id_), | 2060 action->GetPopupUrl(current_tab_id_), |
2058 owner_->browser_, | 2061 owner_->browser_, |
2059 event_box_.get(), | 2062 event_box_.get(), |
2060 ExtensionPopupGtk::SHOW_AND_INSPECT); | 2063 ExtensionPopupGtk::SHOW_AND_INSPECT); |
2061 } | 2064 } |
OLD | NEW |