| 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/web_intent_picker_gtk.h" | 5 #include "chrome/browser/ui/gtk/web_intent_picker_gtk.h" |
| 6 | 6 |
| 7 #include <algorithm> | 7 #include <algorithm> |
| 8 | 8 |
| 9 #include "base/bind.h" | 9 #include "base/bind.h" |
| 10 #include "base/callback.h" | 10 #include "base/callback.h" |
| 11 #include "base/i18n/rtl.h" | 11 #include "base/i18n/rtl.h" |
| 12 #include "base/utf_string_conversions.h" | 12 #include "base/utf_string_conversions.h" |
| 13 #include "chrome/browser/favicon/favicon_service.h" | 13 #include "chrome/browser/favicon/favicon_service.h" |
| 14 #include "chrome/browser/profiles/profile.h" | 14 #include "chrome/browser/profiles/profile.h" |
| 15 #include "chrome/browser/ui/browser.h" | 15 #include "chrome/browser/ui/browser.h" |
| 16 #include "chrome/browser/ui/browser_window.h" | 16 #include "chrome/browser/ui/browser_window.h" |
| 17 #include "chrome/browser/ui/gtk/browser_toolbar_gtk.h" | 17 #include "chrome/browser/ui/gtk/browser_toolbar_gtk.h" |
| 18 #include "chrome/browser/ui/gtk/browser_window_gtk.h" | 18 #include "chrome/browser/ui/gtk/browser_window_gtk.h" |
| 19 #include "chrome/browser/ui/gtk/custom_button.h" | 19 #include "chrome/browser/ui/gtk/custom_button.h" |
| 20 #include "chrome/browser/ui/gtk/gtk_theme_service.h" | |
| 21 #include "chrome/browser/ui/gtk/gtk_util.h" | 20 #include "chrome/browser/ui/gtk/gtk_util.h" |
| 22 #include "chrome/browser/ui/gtk/location_bar_view_gtk.h" | 21 #include "chrome/browser/ui/gtk/location_bar_view_gtk.h" |
| 23 #include "chrome/browser/ui/gtk/tab_contents_container_gtk.h" | 22 #include "chrome/browser/ui/gtk/tab_contents_container_gtk.h" |
| 23 #include "chrome/browser/ui/gtk/theme_service_gtk.h" |
| 24 #include "chrome/browser/ui/intents/web_intent_picker_controller.h" | 24 #include "chrome/browser/ui/intents/web_intent_picker_controller.h" |
| 25 #include "chrome/browser/ui/intents/web_intent_picker_delegate.h" | 25 #include "chrome/browser/ui/intents/web_intent_picker_delegate.h" |
| 26 #include "chrome/browser/ui/intents/web_intent_picker_model.h" | 26 #include "chrome/browser/ui/intents/web_intent_picker_model.h" |
| 27 #include "chrome/browser/ui/tab_contents/tab_contents_wrapper.h" | 27 #include "chrome/browser/ui/tab_contents/tab_contents_wrapper.h" |
| 28 #include "content/browser/renderer_host/render_view_host.h" | 28 #include "content/browser/renderer_host/render_view_host.h" |
| 29 #include "content/public/browser/notification_registrar.h" | 29 #include "content/public/browser/notification_registrar.h" |
| 30 #include "content/public/browser/notification_source.h" | 30 #include "content/public/browser/notification_source.h" |
| 31 #include "content/public/browser/notification_types.h" | 31 #include "content/public/browser/notification_types.h" |
| 32 #include "content/public/browser/render_widget_host_view.h" | 32 #include "content/public/browser/render_widget_host_view.h" |
| 33 #include "content/public/browser/web_contents.h" | 33 #include "content/public/browser/web_contents.h" |
| (...skipping 13 matching lines...) Expand all Loading... |
| 47 // button on the right. | 47 // button on the right. |
| 48 const int kMainContentWidth = 300; | 48 const int kMainContentWidth = 300; |
| 49 | 49 |
| 50 // The length in pixels of the label at the bottom of the picker. Text longer | 50 // The length in pixels of the label at the bottom of the picker. Text longer |
| 51 // than this width will wrap. | 51 // than this width will wrap. |
| 52 const int kWebStoreLabelLength = 300; | 52 const int kWebStoreLabelLength = 300; |
| 53 | 53 |
| 54 // The pixel size of the label at the bottom of the picker. | 54 // The pixel size of the label at the bottom of the picker. |
| 55 const int kWebStoreLabelPixelSize = 11; | 55 const int kWebStoreLabelPixelSize = 11; |
| 56 | 56 |
| 57 GtkThemeService *GetThemeService(TabContentsWrapper* wrapper) { | 57 ThemeServiceGtk *GetThemeService(TabContentsWrapper* wrapper) { |
| 58 return GtkThemeService::GetFrom(wrapper->profile()); | 58 return ThemeServiceGtk::GetFrom(wrapper->profile()); |
| 59 } | 59 } |
| 60 | 60 |
| 61 // Set the image of |button| to |pixbuf|. | 61 // Set the image of |button| to |pixbuf|. |
| 62 void SetServiceButtonImage(GtkWidget* button, GdkPixbuf* pixbuf) { | 62 void SetServiceButtonImage(GtkWidget* button, GdkPixbuf* pixbuf) { |
| 63 gtk_button_set_image(GTK_BUTTON(button), gtk_image_new_from_pixbuf(pixbuf)); | 63 gtk_button_set_image(GTK_BUTTON(button), gtk_image_new_from_pixbuf(pixbuf)); |
| 64 gtk_button_set_image_position(GTK_BUTTON(button), GTK_POS_LEFT); | 64 gtk_button_set_image_position(GTK_BUTTON(button), GTK_POS_LEFT); |
| 65 } | 65 } |
| 66 | 66 |
| 67 } // namespace | 67 } // namespace |
| 68 | 68 |
| (...skipping 156 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 225 DCHECK(index != -1); | 225 DCHECK(index != -1); |
| 226 | 226 |
| 227 const WebIntentPickerModel::InstalledService& installed_service = | 227 const WebIntentPickerModel::InstalledService& installed_service = |
| 228 model_->GetInstalledServiceAt(index); | 228 model_->GetInstalledServiceAt(index); |
| 229 | 229 |
| 230 delegate_->OnServiceChosen(static_cast<size_t>(index), | 230 delegate_->OnServiceChosen(static_cast<size_t>(index), |
| 231 installed_service.disposition); | 231 installed_service.disposition); |
| 232 } | 232 } |
| 233 | 233 |
| 234 void WebIntentPickerGtk::InitContents() { | 234 void WebIntentPickerGtk::InitContents() { |
| 235 GtkThemeService* theme_service = GetThemeService(wrapper_); | 235 ThemeServiceGtk* theme_service = GetThemeService(wrapper_); |
| 236 | 236 |
| 237 // Main contents vbox. | 237 // Main contents vbox. |
| 238 contents_ = gtk_vbox_new(FALSE, ui::kContentAreaSpacing); | 238 contents_ = gtk_vbox_new(FALSE, ui::kContentAreaSpacing); |
| 239 gtk_container_set_border_width(GTK_CONTAINER(contents_), | 239 gtk_container_set_border_width(GTK_CONTAINER(contents_), |
| 240 ui::kContentAreaBorder); | 240 ui::kContentAreaBorder); |
| 241 gtk_widget_set_size_request(contents_, kMainContentWidth, -1); | 241 gtk_widget_set_size_request(contents_, kMainContentWidth, -1); |
| 242 | 242 |
| 243 // Hbox containing label and close button. | 243 // Hbox containing label and close button. |
| 244 GtkWidget* header_hbox = gtk_hbox_new(FALSE, ui::kControlSpacing); | 244 GtkWidget* header_hbox = gtk_hbox_new(FALSE, ui::kControlSpacing); |
| 245 gtk_box_pack_start(GTK_BOX(contents_), header_hbox, TRUE, TRUE, 0); | 245 gtk_box_pack_start(GTK_BOX(contents_), header_hbox, TRUE, TRUE, 0); |
| (...skipping 30 matching lines...) Expand all Loading... |
| 276 g_signal_connect(contents_, "destroy", G_CALLBACK(&OnDestroyThunk), this); | 276 g_signal_connect(contents_, "destroy", G_CALLBACK(&OnDestroyThunk), this); |
| 277 } | 277 } |
| 278 | 278 |
| 279 GtkWidget* WebIntentPickerGtk::GetServiceButton(size_t index) { | 279 GtkWidget* WebIntentPickerGtk::GetServiceButton(size_t index) { |
| 280 GList* button_list = gtk_container_get_children(GTK_CONTAINER(button_vbox_)); | 280 GList* button_list = gtk_container_get_children(GTK_CONTAINER(button_vbox_)); |
| 281 GtkWidget* button = GTK_WIDGET(g_list_nth_data(button_list, index)); | 281 GtkWidget* button = GTK_WIDGET(g_list_nth_data(button_list, index)); |
| 282 DCHECK(button != NULL); | 282 DCHECK(button != NULL); |
| 283 | 283 |
| 284 return button; | 284 return button; |
| 285 } | 285 } |
| OLD | NEW |