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

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

Issue 10337010: Revert r123782. (Closed) Base URL: svn://svn.chromium.org/chrome/trunk/src
Patch Set: . Created 8 years, 7 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/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/i18n/rtl.h" 9 #include "base/i18n/rtl.h"
10 #include "base/utf_string_conversions.h" 10 #include "base/utf_string_conversions.h"
11 #include "chrome/browser/favicon/favicon_service.h" 11 #include "chrome/browser/favicon/favicon_service.h"
12 #include "chrome/browser/profiles/profile.h" 12 #include "chrome/browser/profiles/profile.h"
13 #include "chrome/browser/tab_contents/tab_util.h" 13 #include "chrome/browser/tab_contents/tab_util.h"
14 #include "chrome/browser/ui/browser_window.h" 14 #include "chrome/browser/ui/browser_window.h"
15 #include "chrome/browser/ui/gtk/browser_toolbar_gtk.h" 15 #include "chrome/browser/ui/gtk/browser_toolbar_gtk.h"
16 #include "chrome/browser/ui/gtk/browser_window_gtk.h" 16 #include "chrome/browser/ui/gtk/browser_window_gtk.h"
17 #include "chrome/browser/ui/gtk/custom_button.h" 17 #include "chrome/browser/ui/gtk/custom_button.h"
18 #include "chrome/browser/ui/gtk/gtk_chrome_link_button.h" 18 #include "chrome/browser/ui/gtk/gtk_chrome_link_button.h"
19 #include "chrome/browser/ui/gtk/gtk_theme_service.h"
19 #include "chrome/browser/ui/gtk/gtk_util.h" 20 #include "chrome/browser/ui/gtk/gtk_util.h"
20 #include "chrome/browser/ui/gtk/location_bar_view_gtk.h" 21 #include "chrome/browser/ui/gtk/location_bar_view_gtk.h"
21 #include "chrome/browser/ui/gtk/tab_contents_container_gtk.h" 22 #include "chrome/browser/ui/gtk/tab_contents_container_gtk.h"
22 #include "chrome/browser/ui/gtk/theme_service_gtk.h"
23 #include "chrome/browser/ui/gtk/throbber_gtk.h" 23 #include "chrome/browser/ui/gtk/throbber_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 "chrome/common/chrome_notification_types.h" 28 #include "chrome/common/chrome_notification_types.h"
29 #include "content/public/browser/notification_source.h" 29 #include "content/public/browser/notification_source.h"
30 #include "content/public/browser/notification_types.h" 30 #include "content/public/browser/notification_types.h"
31 #include "content/public/browser/render_view_host.h" 31 #include "content/public/browser/render_view_host.h"
32 #include "content/public/browser/render_widget_host_view.h" 32 #include "content/public/browser/render_widget_host_view.h"
(...skipping 28 matching lines...) Expand all
61 const int kTitleLinkMaxWidth = 130; 61 const int kTitleLinkMaxWidth = 130;
62 62
63 // Indices of the extension row widgets. 63 // Indices of the extension row widgets.
64 enum { 64 enum {
65 kIconIndex, 65 kIconIndex,
66 kTitleLinkIndex, 66 kTitleLinkIndex,
67 kStarsIndex, 67 kStarsIndex,
68 kInstallButtonIndex, 68 kInstallButtonIndex,
69 }; 69 };
70 70
71 ThemeServiceGtk *GetThemeService(TabContentsWrapper* wrapper) { 71 GtkThemeService *GetThemeService(TabContentsWrapper* wrapper) {
72 return ThemeServiceGtk::GetFrom(wrapper->profile()); 72 return GtkThemeService::GetFrom(wrapper->profile());
73 } 73 }
74 74
75 // Set the image of |button| to |pixbuf|. 75 // Set the image of |button| to |pixbuf|.
76 void SetServiceButtonImage(GtkWidget* button, GdkPixbuf* pixbuf) { 76 void SetServiceButtonImage(GtkWidget* button, GdkPixbuf* pixbuf) {
77 gtk_button_set_image(GTK_BUTTON(button), gtk_image_new_from_pixbuf(pixbuf)); 77 gtk_button_set_image(GTK_BUTTON(button), gtk_image_new_from_pixbuf(pixbuf));
78 gtk_button_set_image_position(GTK_BUTTON(button), GTK_POS_LEFT); 78 gtk_button_set_image_position(GTK_BUTTON(button), GTK_POS_LEFT);
79 } 79 }
80 80
81 void SetWidgetFontSizeCallback(GtkWidget* widget, gpointer data) { 81 void SetWidgetFontSizeCallback(GtkWidget* widget, gpointer data) {
82 if (GTK_IS_LABEL(widget)) { 82 if (GTK_IS_LABEL(widget)) {
(...skipping 73 matching lines...) Expand 10 before | Expand all | Expand 10 after
156 extensions_vbox_(NULL), 156 extensions_vbox_(NULL),
157 window_(NULL) { 157 window_(NULL) {
158 DCHECK(delegate_ != NULL); 158 DCHECK(delegate_ != NULL);
159 159
160 model_->set_observer(this); 160 model_->set_observer(this);
161 InitContents(); 161 InitContents();
162 UpdateInstalledServices(); 162 UpdateInstalledServices();
163 UpdateCWSLabel(); 163 UpdateCWSLabel();
164 UpdateSuggestedExtensions(); 164 UpdateSuggestedExtensions();
165 165
166 ThemeServiceGtk* theme_service = GetThemeService(wrapper); 166 GtkThemeService* theme_service = GetThemeService(wrapper);
167 registrar_.Add(this, chrome::NOTIFICATION_BROWSER_THEME_CHANGED, 167 registrar_.Add(this, chrome::NOTIFICATION_BROWSER_THEME_CHANGED,
168 content::Source<ThemeService>(theme_service)); 168 content::Source<ThemeService>(theme_service));
169 theme_service->InitThemesFor(this); 169 theme_service->InitThemesFor(this);
170 170
171 window_ = new ConstrainedWindowGtk(wrapper, this); 171 window_ = new ConstrainedWindowGtk(wrapper, this);
172 } 172 }
173 173
174 WebIntentPickerGtk::~WebIntentPickerGtk() { 174 WebIntentPickerGtk::~WebIntentPickerGtk() {
175 } 175 }
176 176
(...skipping 115 matching lines...) Expand 10 before | Expand all | Expand 10 after
292 } 292 }
293 293
294 bool WebIntentPickerGtk::ShouldHaveBorderPadding() const { 294 bool WebIntentPickerGtk::ShouldHaveBorderPadding() const {
295 return false; 295 return false;
296 } 296 }
297 297
298 void WebIntentPickerGtk::Observe(int type, 298 void WebIntentPickerGtk::Observe(int type,
299 const content::NotificationSource& source, 299 const content::NotificationSource& source,
300 const content::NotificationDetails& details) { 300 const content::NotificationDetails& details) {
301 DCHECK_EQ(type, chrome::NOTIFICATION_BROWSER_THEME_CHANGED); 301 DCHECK_EQ(type, chrome::NOTIFICATION_BROWSER_THEME_CHANGED);
302 ThemeServiceGtk* theme_service = GetThemeService(wrapper_); 302 GtkThemeService* theme_service = GetThemeService(wrapper_);
303 if (theme_service->UsingNativeTheme()) 303 if (theme_service->UsingNativeTheme())
304 gtk_util::UndoForceFontSize(header_label_); 304 gtk_util::UndoForceFontSize(header_label_);
305 else 305 else
306 gtk_util::ForceFontSizePixels(header_label_, kHeaderLabelPixelSize); 306 gtk_util::ForceFontSizePixels(header_label_, kHeaderLabelPixelSize);
307 307
308 UpdateInstalledServices(); 308 UpdateInstalledServices();
309 UpdateSuggestedExtensions(); 309 UpdateSuggestedExtensions();
310 } 310 }
311 311
312 void WebIntentPickerGtk::OnDestroy(GtkWidget* button) { 312 void WebIntentPickerGtk::OnDestroy(GtkWidget* button) {
(...skipping 58 matching lines...) Expand 10 before | Expand all | Expand 10 after
371 g_list_free(button_list); 371 g_list_free(button_list);
372 372
373 const WebIntentPickerModel::InstalledService& installed_service = 373 const WebIntentPickerModel::InstalledService& installed_service =
374 model_->GetInstalledServiceAt(index); 374 model_->GetInstalledServiceAt(index);
375 375
376 delegate_->OnServiceChosen(installed_service.url, 376 delegate_->OnServiceChosen(installed_service.url,
377 installed_service.disposition); 377 installed_service.disposition);
378 } 378 }
379 379
380 void WebIntentPickerGtk::InitContents() { 380 void WebIntentPickerGtk::InitContents() {
381 ThemeServiceGtk* theme_service = GetThemeService(wrapper_); 381 GtkThemeService* theme_service = GetThemeService(wrapper_);
382 382
383 // Main contents vbox. 383 // Main contents vbox.
384 contents_ = gtk_vbox_new(FALSE, 0); 384 contents_ = gtk_vbox_new(FALSE, 0);
385 gtk_widget_set_size_request(contents_, kMainContentWidth, -1); 385 gtk_widget_set_size_request(contents_, kMainContentWidth, -1);
386 386
387 // Hbox containing the close button. 387 // Hbox containing the close button.
388 GtkWidget* close_hbox = gtk_hbox_new(FALSE, 0); 388 GtkWidget* close_hbox = gtk_hbox_new(FALSE, 0);
389 gtk_box_pack_start(GTK_BOX(contents_), close_hbox, TRUE, TRUE, 0); 389 gtk_box_pack_start(GTK_BOX(contents_), close_hbox, TRUE, TRUE, 0);
390 390
391 close_button_.reset( 391 close_button_.reset(
(...skipping 123 matching lines...) Expand 10 before | Expand all | Expand 10 after
515 gtk_widget_show(gtk_widget_get_parent(button_vbox_)); 515 gtk_widget_show(gtk_widget_get_parent(button_vbox_));
516 } 516 }
517 517
518 if (model_->GetSuggestedExtensionCount() == 0) 518 if (model_->GetSuggestedExtensionCount() == 0)
519 gtk_widget_hide(cws_label_); 519 gtk_widget_hide(cws_label_);
520 else 520 else
521 gtk_widget_show(cws_label_); 521 gtk_widget_show(cws_label_);
522 } 522 }
523 523
524 void WebIntentPickerGtk::UpdateSuggestedExtensions() { 524 void WebIntentPickerGtk::UpdateSuggestedExtensions() {
525 ThemeServiceGtk* theme_service = GetThemeService(wrapper_); 525 GtkThemeService* theme_service = GetThemeService(wrapper_);
526 526
527 gtk_util::RemoveAllChildren(extensions_vbox_); 527 gtk_util::RemoveAllChildren(extensions_vbox_);
528 528
529 if (model_->GetSuggestedExtensionCount() == 0) { 529 if (model_->GetSuggestedExtensionCount() == 0) {
530 gtk_widget_hide(gtk_widget_get_parent(extensions_vbox_)); 530 gtk_widget_hide(gtk_widget_get_parent(extensions_vbox_));
531 return; 531 return;
532 } 532 }
533 533
534 gtk_widget_show(gtk_widget_get_parent(extensions_vbox_)); 534 gtk_widget_show(gtk_widget_get_parent(extensions_vbox_));
535 535
(...skipping 63 matching lines...) Expand 10 before | Expand all | Expand 10 after
599 return alignment; 599 return alignment;
600 } 600 }
601 601
602 void WebIntentPickerGtk::RemoveThrobber() { 602 void WebIntentPickerGtk::RemoveThrobber() {
603 GtkWidget* alignment = gtk_widget_get_parent(throbber_->widget()); 603 GtkWidget* alignment = gtk_widget_get_parent(throbber_->widget());
604 DCHECK(alignment); 604 DCHECK(alignment);
605 gtk_container_remove(GTK_CONTAINER(alignment), throbber_->widget()); 605 gtk_container_remove(GTK_CONTAINER(alignment), throbber_->widget());
606 gtk_widget_destroy(alignment); 606 gtk_widget_destroy(alignment);
607 throbber_->Stop(); 607 throbber_->Stop();
608 } 608 }
OLDNEW
« no previous file with comments | « chrome/browser/ui/gtk/throbber_gtk.cc ('k') | chrome/browser/ui/gtk/website_settings_popup_gtk.h » ('j') | no next file with comments »

Powered by Google App Engine
This is Rietveld 408576698