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 994 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
1005 UTF16ToUTF8(partial_name).c_str()); | 1005 UTF16ToUTF8(partial_name).c_str()); |
1006 | 1006 |
1007 if (last_keyword_ != keyword) { | 1007 if (last_keyword_ != keyword) { |
1008 last_keyword_ = keyword; | 1008 last_keyword_ = keyword; |
1009 | 1009 |
1010 if (is_extension_keyword) { | 1010 if (is_extension_keyword) { |
1011 const TemplateURL* template_url = | 1011 const TemplateURL* template_url = |
1012 template_url_service->GetTemplateURLForKeyword(keyword); | 1012 template_url_service->GetTemplateURLForKeyword(keyword); |
1013 const SkBitmap& bitmap = profile->GetExtensionService()-> | 1013 const SkBitmap& bitmap = profile->GetExtensionService()-> |
1014 GetOmniboxIcon(template_url->GetExtensionId()); | 1014 GetOmniboxIcon(template_url->GetExtensionId()); |
1015 GdkPixbuf* pixbuf = gfx::GdkPixbufFromSkBitmap(&bitmap); | 1015 GdkPixbuf* pixbuf = gfx::GdkPixbufFromSkBitmap(bitmap); |
1016 gtk_image_set_from_pixbuf(GTK_IMAGE(tab_to_search_magnifier_), pixbuf); | 1016 gtk_image_set_from_pixbuf(GTK_IMAGE(tab_to_search_magnifier_), pixbuf); |
1017 g_object_unref(pixbuf); | 1017 g_object_unref(pixbuf); |
1018 } else { | 1018 } else { |
1019 ui::ResourceBundle& rb = ui::ResourceBundle::GetSharedInstance(); | 1019 ui::ResourceBundle& rb = ui::ResourceBundle::GetSharedInstance(); |
1020 gtk_image_set_from_pixbuf(GTK_IMAGE(tab_to_search_magnifier_), | 1020 gtk_image_set_from_pixbuf(GTK_IMAGE(tab_to_search_magnifier_), |
1021 rb.GetNativeImageNamed(IDR_OMNIBOX_SEARCH).ToGdkPixbuf()); | 1021 rb.GetNativeImageNamed(IDR_OMNIBOX_SEARCH).ToGdkPixbuf()); |
1022 } | 1022 } |
1023 } | 1023 } |
1024 } | 1024 } |
1025 | 1025 |
(...skipping 92 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
1118 guint info, guint time) { | 1118 guint info, guint time) { |
1119 WebContents* tab = GetWebContents(); | 1119 WebContents* tab = GetWebContents(); |
1120 if (!tab) | 1120 if (!tab) |
1121 return; | 1121 return; |
1122 ui::WriteURLWithName(data, tab->GetURL(), tab->GetTitle(), info); | 1122 ui::WriteURLWithName(data, tab->GetURL(), tab->GetTitle(), info); |
1123 } | 1123 } |
1124 | 1124 |
1125 void LocationBarViewGtk::OnIconDragBegin(GtkWidget* sender, | 1125 void LocationBarViewGtk::OnIconDragBegin(GtkWidget* sender, |
1126 GdkDragContext* context) { | 1126 GdkDragContext* context) { |
1127 SkBitmap favicon = GetFavicon(); | 1127 SkBitmap favicon = GetFavicon(); |
1128 GdkPixbuf* pixbuf = gfx::GdkPixbufFromSkBitmap(&favicon); | 1128 GdkPixbuf* pixbuf = gfx::GdkPixbufFromSkBitmap(favicon); |
1129 if (!pixbuf) | 1129 if (!pixbuf) |
1130 return; | 1130 return; |
1131 drag_icon_ = bookmark_utils::GetDragRepresentation(pixbuf, | 1131 drag_icon_ = bookmark_utils::GetDragRepresentation(pixbuf, |
1132 GetTitle(), theme_service_); | 1132 GetTitle(), theme_service_); |
1133 g_object_unref(pixbuf); | 1133 g_object_unref(pixbuf); |
1134 gtk_drag_set_icon_widget(context, drag_icon_, 0, 0); | 1134 gtk_drag_set_icon_widget(context, drag_icon_, 0, 0); |
1135 } | 1135 } |
1136 | 1136 |
1137 void LocationBarViewGtk::OnIconDragEnd(GtkWidget* sender, | 1137 void LocationBarViewGtk::OnIconDragEnd(GtkWidget* sender, |
1138 GdkDragContext* context) { | 1138 GdkDragContext* context) { |
(...skipping 450 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
1589 // default_icon_path(). | 1589 // default_icon_path(). |
1590 | 1590 |
1591 // First look for a dynamically set bitmap. | 1591 // First look for a dynamically set bitmap. |
1592 SkBitmap icon = page_action_->GetIcon(current_tab_id_); | 1592 SkBitmap icon = page_action_->GetIcon(current_tab_id_); |
1593 GdkPixbuf* pixbuf = NULL; | 1593 GdkPixbuf* pixbuf = NULL; |
1594 if (!icon.isNull()) { | 1594 if (!icon.isNull()) { |
1595 if (icon.pixelRef() != last_icon_skbitmap_.pixelRef()) { | 1595 if (icon.pixelRef() != last_icon_skbitmap_.pixelRef()) { |
1596 if (last_icon_pixbuf_) | 1596 if (last_icon_pixbuf_) |
1597 g_object_unref(last_icon_pixbuf_); | 1597 g_object_unref(last_icon_pixbuf_); |
1598 last_icon_skbitmap_ = icon; | 1598 last_icon_skbitmap_ = icon; |
1599 last_icon_pixbuf_ = gfx::GdkPixbufFromSkBitmap(&icon); | 1599 last_icon_pixbuf_ = gfx::GdkPixbufFromSkBitmap(icon); |
1600 } | 1600 } |
1601 DCHECK(last_icon_pixbuf_); | 1601 DCHECK(last_icon_pixbuf_); |
1602 pixbuf = last_icon_pixbuf_; | 1602 pixbuf = last_icon_pixbuf_; |
1603 } else { | 1603 } else { |
1604 // Otherwise look for a dynamically set index, or fall back to the | 1604 // Otherwise look for a dynamically set index, or fall back to the |
1605 // default path. | 1605 // default path. |
1606 int icon_index = page_action_->GetIconIndex(current_tab_id_); | 1606 int icon_index = page_action_->GetIconIndex(current_tab_id_); |
1607 std::string icon_path = (icon_index < 0) ? | 1607 std::string icon_path = (icon_index < 0) ? |
1608 page_action_->default_icon_path() : | 1608 page_action_->default_icon_path() : |
1609 page_action_->icon_paths()->at(icon_index); | 1609 page_action_->icon_paths()->at(icon_index); |
(...skipping 195 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
1805 GdkModifierType modifier, | 1805 GdkModifierType modifier, |
1806 void* user_data) { | 1806 void* user_data) { |
1807 PageActionViewGtk* view = static_cast<PageActionViewGtk*>(user_data); | 1807 PageActionViewGtk* view = static_cast<PageActionViewGtk*>(user_data); |
1808 if (!gtk_widget_get_visible(view->widget())) | 1808 if (!gtk_widget_get_visible(view->widget())) |
1809 return FALSE; | 1809 return FALSE; |
1810 | 1810 |
1811 GdkEventButton event = {}; | 1811 GdkEventButton event = {}; |
1812 event.button = 1; | 1812 event.button = 1; |
1813 return view->OnButtonPressed(view->widget(), &event); | 1813 return view->OnButtonPressed(view->widget(), &event); |
1814 } | 1814 } |
OLD | NEW |