| OLD | NEW |
| 1 // Copyright (c) 2010 The Chromium Authors. All rights reserved. | 1 // Copyright (c) 2010 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/gtk/browser_actions_toolbar_gtk.h" | 5 #include "chrome/browser/gtk/browser_actions_toolbar_gtk.h" |
| 6 | 6 |
| 7 #include <vector> | 7 #include <vector> |
| 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/extensions/extension_browser_event_router.h" | 11 #include "chrome/browser/extensions/extension_browser_event_router.h" |
| 12 #include "chrome/browser/extensions/extension_context_menu_model.h" | 12 #include "chrome/browser/extensions/extension_context_menu_model.h" |
| 13 #include "chrome/browser/extensions/extensions_service.h" | 13 #include "chrome/browser/extensions/extension_service.h" |
| 14 #include "chrome/browser/extensions/image_loading_tracker.h" | 14 #include "chrome/browser/extensions/image_loading_tracker.h" |
| 15 #include "chrome/browser/gtk/cairo_cached_surface.h" | 15 #include "chrome/browser/gtk/cairo_cached_surface.h" |
| 16 #include "chrome/browser/gtk/extension_popup_gtk.h" | 16 #include "chrome/browser/gtk/extension_popup_gtk.h" |
| 17 #include "chrome/browser/gtk/gtk_chrome_button.h" | 17 #include "chrome/browser/gtk/gtk_chrome_button.h" |
| 18 #include "chrome/browser/gtk/gtk_chrome_shrinkable_hbox.h" | 18 #include "chrome/browser/gtk/gtk_chrome_shrinkable_hbox.h" |
| 19 #include "chrome/browser/gtk/gtk_theme_provider.h" | 19 #include "chrome/browser/gtk/gtk_theme_provider.h" |
| 20 #include "chrome/browser/gtk/gtk_util.h" | 20 #include "chrome/browser/gtk/gtk_util.h" |
| 21 #include "chrome/browser/gtk/hover_controller_gtk.h" | 21 #include "chrome/browser/gtk/hover_controller_gtk.h" |
| 22 #include "chrome/browser/gtk/menu_gtk.h" | 22 #include "chrome/browser/gtk/menu_gtk.h" |
| 23 #include "chrome/browser/gtk/view_id_util.h" | 23 #include "chrome/browser/gtk/view_id_util.h" |
| (...skipping 332 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 356 theme_provider_(GtkThemeProvider::GetFrom(browser->profile())), | 356 theme_provider_(GtkThemeProvider::GetFrom(browser->profile())), |
| 357 model_(NULL), | 357 model_(NULL), |
| 358 hbox_(gtk_hbox_new(FALSE, 0)), | 358 hbox_(gtk_hbox_new(FALSE, 0)), |
| 359 button_hbox_(gtk_chrome_shrinkable_hbox_new(TRUE, FALSE, kButtonPadding)), | 359 button_hbox_(gtk_chrome_shrinkable_hbox_new(TRUE, FALSE, kButtonPadding)), |
| 360 drag_button_(NULL), | 360 drag_button_(NULL), |
| 361 drop_index_(-1), | 361 drop_index_(-1), |
| 362 resize_animation_(this), | 362 resize_animation_(this), |
| 363 desired_width_(0), | 363 desired_width_(0), |
| 364 start_width_(0), | 364 start_width_(0), |
| 365 method_factory_(this) { | 365 method_factory_(this) { |
| 366 ExtensionsService* extension_service = profile_->GetExtensionsService(); | 366 ExtensionService* extension_service = profile_->GetExtensionService(); |
| 367 // The |extension_service| can be NULL in Incognito. | 367 // The |extension_service| can be NULL in Incognito. |
| 368 if (!extension_service) | 368 if (!extension_service) |
| 369 return; | 369 return; |
| 370 | 370 |
| 371 overflow_button_.reset(new CustomDrawButton( | 371 overflow_button_.reset(new CustomDrawButton( |
| 372 theme_provider_, | 372 theme_provider_, |
| 373 IDR_BROWSER_ACTIONS_OVERFLOW, | 373 IDR_BROWSER_ACTIONS_OVERFLOW, |
| 374 IDR_BROWSER_ACTIONS_OVERFLOW_P, | 374 IDR_BROWSER_ACTIONS_OVERFLOW_P, |
| 375 IDR_BROWSER_ACTIONS_OVERFLOW_H, | 375 IDR_BROWSER_ACTIONS_OVERFLOW_H, |
| 376 0, | 376 0, |
| (...skipping 178 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 555 if (button_count() == 0) | 555 if (button_count() == 0) |
| 556 gtk_widget_hide(widget()); | 556 gtk_widget_hide(widget()); |
| 557 else | 557 else |
| 558 gtk_widget_show(widget()); | 558 gtk_widget_show(widget()); |
| 559 } | 559 } |
| 560 | 560 |
| 561 bool BrowserActionsToolbarGtk::ShouldDisplayBrowserAction( | 561 bool BrowserActionsToolbarGtk::ShouldDisplayBrowserAction( |
| 562 const Extension* extension) { | 562 const Extension* extension) { |
| 563 // Only display incognito-enabled extensions while in incognito mode. | 563 // Only display incognito-enabled extensions while in incognito mode. |
| 564 return (!profile_->IsOffTheRecord() || | 564 return (!profile_->IsOffTheRecord() || |
| 565 profile_->GetExtensionsService()->IsIncognitoEnabled(extension)); | 565 profile_->GetExtensionService()->IsIncognitoEnabled(extension)); |
| 566 } | 566 } |
| 567 | 567 |
| 568 void BrowserActionsToolbarGtk::HidePopup() { | 568 void BrowserActionsToolbarGtk::HidePopup() { |
| 569 ExtensionPopupGtk* popup = ExtensionPopupGtk::get_current_extension_popup(); | 569 ExtensionPopupGtk* popup = ExtensionPopupGtk::get_current_extension_popup(); |
| 570 if (popup) | 570 if (popup) |
| 571 popup->DestroyPopup(); | 571 popup->DestroyPopup(); |
| 572 } | 572 } |
| 573 | 573 |
| 574 void BrowserActionsToolbarGtk::AnimateToShowNIcons(int count) { | 574 void BrowserActionsToolbarGtk::AnimateToShowNIcons(int count) { |
| 575 desired_width_ = WidthForIconCount(count); | 575 desired_width_ = WidthForIconCount(count); |
| (...skipping 359 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 935 } | 935 } |
| 936 | 936 |
| 937 it->second.get()->GetContextMenu()->PopupAsContext(event->time); | 937 it->second.get()->GetContextMenu()->PopupAsContext(event->time); |
| 938 return TRUE; | 938 return TRUE; |
| 939 } | 939 } |
| 940 | 940 |
| 941 void BrowserActionsToolbarGtk::OnButtonShowOrHide(GtkWidget* sender) { | 941 void BrowserActionsToolbarGtk::OnButtonShowOrHide(GtkWidget* sender) { |
| 942 if (!resize_animation_.is_animating()) | 942 if (!resize_animation_.is_animating()) |
| 943 UpdateChevronVisibility(); | 943 UpdateChevronVisibility(); |
| 944 } | 944 } |
| OLD | NEW |