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/browser_actions_toolbar_gtk.h" | 5 #include "chrome/browser/ui/gtk/browser_actions_toolbar_gtk.h" |
6 | 6 |
7 #include <gtk/gtk.h> | 7 #include <gtk/gtk.h> |
8 | 8 |
9 #include <algorithm> | 9 #include <algorithm> |
10 #include <vector> | 10 #include <vector> |
11 | 11 |
12 #include "base/bind.h" | 12 #include "base/bind.h" |
13 #include "base/i18n/rtl.h" | 13 #include "base/i18n/rtl.h" |
14 #include "base/message_loop.h" | 14 #include "base/message_loop.h" |
15 #include "base/utf_string_conversions.h" | 15 #include "base/utf_string_conversions.h" |
16 #include "chrome/browser/extensions/api/commands/command_service.h" | 16 #include "chrome/browser/extensions/api/commands/command_service.h" |
17 #include "chrome/browser/extensions/api/commands/command_service_factory.h" | 17 #include "chrome/browser/extensions/api/commands/command_service_factory.h" |
18 #include "chrome/browser/extensions/extension_action.h" | 18 #include "chrome/browser/extensions/extension_action.h" |
19 #include "chrome/browser/extensions/extension_action_icon_factory.h" | 19 #include "chrome/browser/extensions/extension_action_icon_factory.h" |
20 #include "chrome/browser/extensions/extension_action_manager.h" | 20 #include "chrome/browser/extensions/extension_action_manager.h" |
21 #include "chrome/browser/extensions/extension_context_menu_model.h" | 21 #include "chrome/browser/extensions/extension_context_menu_model.h" |
22 #include "chrome/browser/extensions/extension_service.h" | 22 #include "chrome/browser/extensions/extension_service.h" |
23 #include "chrome/browser/extensions/extension_system.h" | |
23 #include "chrome/browser/profiles/profile.h" | 24 #include "chrome/browser/profiles/profile.h" |
24 #include "chrome/browser/sessions/session_tab_helper.h" | 25 #include "chrome/browser/sessions/session_tab_helper.h" |
25 #include "chrome/browser/ui/browser.h" | 26 #include "chrome/browser/ui/browser.h" |
26 #include "chrome/browser/ui/browser_tabstrip.h" | 27 #include "chrome/browser/ui/browser_tabstrip.h" |
27 #include "chrome/browser/ui/gtk/browser_window_gtk.h" | 28 #include "chrome/browser/ui/gtk/browser_window_gtk.h" |
28 #include "chrome/browser/ui/gtk/custom_button.h" | 29 #include "chrome/browser/ui/gtk/custom_button.h" |
29 #include "chrome/browser/ui/gtk/extensions/extension_popup_gtk.h" | 30 #include "chrome/browser/ui/gtk/extensions/extension_popup_gtk.h" |
30 #include "chrome/browser/ui/gtk/gtk_chrome_button.h" | 31 #include "chrome/browser/ui/gtk/gtk_chrome_button.h" |
31 #include "chrome/browser/ui/gtk/gtk_chrome_shrinkable_hbox.h" | 32 #include "chrome/browser/ui/gtk/gtk_chrome_shrinkable_hbox.h" |
32 #include "chrome/browser/ui/gtk/gtk_theme_service.h" | 33 #include "chrome/browser/ui/gtk/gtk_theme_service.h" |
(...skipping 466 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... | |
499 theme_service_(GtkThemeService::GetFrom(browser->profile())), | 500 theme_service_(GtkThemeService::GetFrom(browser->profile())), |
500 model_(NULL), | 501 model_(NULL), |
501 hbox_(gtk_hbox_new(FALSE, 0)), | 502 hbox_(gtk_hbox_new(FALSE, 0)), |
502 button_hbox_(gtk_chrome_shrinkable_hbox_new(TRUE, FALSE, kButtonPadding)), | 503 button_hbox_(gtk_chrome_shrinkable_hbox_new(TRUE, FALSE, kButtonPadding)), |
503 drag_button_(NULL), | 504 drag_button_(NULL), |
504 drop_index_(-1), | 505 drop_index_(-1), |
505 resize_animation_(this), | 506 resize_animation_(this), |
506 desired_width_(0), | 507 desired_width_(0), |
507 start_width_(0), | 508 start_width_(0), |
508 weak_factory_(this) { | 509 weak_factory_(this) { |
509 ExtensionService* extension_service = profile_->GetExtensionService(); | 510 ExtensionService* extension_service = |
511 extensions::ExtensionSystem::Get(profile_)->extension_service(); | |
510 // The |extension_service| can be NULL in Incognito. | 512 // The |extension_service| can be NULL in Incognito. |
Yoyo Zhou
2012/11/21 00:27:13
This comment is wrong. (However, I would not delet
Miranda Callahan
2012/11/26 22:14:24
Done.
| |
511 if (!extension_service) | 513 if (!extension_service) |
512 return; | 514 return; |
513 | 515 |
514 overflow_button_.reset(new CustomDrawButton( | 516 overflow_button_.reset(new CustomDrawButton( |
515 theme_service_, | 517 theme_service_, |
516 IDR_BROWSER_ACTIONS_OVERFLOW, | 518 IDR_BROWSER_ACTIONS_OVERFLOW, |
517 IDR_BROWSER_ACTIONS_OVERFLOW_P, | 519 IDR_BROWSER_ACTIONS_OVERFLOW_P, |
518 IDR_BROWSER_ACTIONS_OVERFLOW_H, | 520 IDR_BROWSER_ACTIONS_OVERFLOW_H, |
519 0, | 521 0, |
520 gtk_arrow_new(GTK_ARROW_DOWN, GTK_SHADOW_NONE))); | 522 gtk_arrow_new(GTK_ARROW_DOWN, GTK_SHADOW_NONE))); |
(...skipping 174 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... | |
695 } | 697 } |
696 | 698 |
697 void BrowserActionsToolbarGtk::UpdateVisibility() { | 699 void BrowserActionsToolbarGtk::UpdateVisibility() { |
698 gtk_widget_set_visible(widget(), button_count() != 0); | 700 gtk_widget_set_visible(widget(), button_count() != 0); |
699 } | 701 } |
700 | 702 |
701 bool BrowserActionsToolbarGtk::ShouldDisplayBrowserAction( | 703 bool BrowserActionsToolbarGtk::ShouldDisplayBrowserAction( |
702 const Extension* extension) { | 704 const Extension* extension) { |
703 // Only display incognito-enabled extensions while in incognito mode. | 705 // Only display incognito-enabled extensions while in incognito mode. |
704 return (!profile_->IsOffTheRecord() || | 706 return (!profile_->IsOffTheRecord() || |
705 profile_->GetExtensionService()->IsIncognitoEnabled(extension->id())); | 707 extensions::ExtensionSystem::Get(profile_)->extension_service()-> |
708 IsIncognitoEnabled(extension->id())); | |
706 } | 709 } |
707 | 710 |
708 void BrowserActionsToolbarGtk::HidePopup() { | 711 void BrowserActionsToolbarGtk::HidePopup() { |
709 ExtensionPopupGtk* popup = ExtensionPopupGtk::get_current_extension_popup(); | 712 ExtensionPopupGtk* popup = ExtensionPopupGtk::get_current_extension_popup(); |
710 if (popup) | 713 if (popup) |
711 popup->DestroyPopup(); | 714 popup->DestroyPopup(); |
712 } | 715 } |
713 | 716 |
714 void BrowserActionsToolbarGtk::AnimateToShowNIcons(int count) { | 717 void BrowserActionsToolbarGtk::AnimateToShowNIcons(int count) { |
715 desired_width_ = WidthForIconCount(count); | 718 desired_width_ = WidthForIconCount(count); |
(...skipping 380 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... | |
1096 | 1099 |
1097 menu->PopupAsContext(gfx::Point(event->x_root, event->y_root), | 1100 menu->PopupAsContext(gfx::Point(event->x_root, event->y_root), |
1098 event->time); | 1101 event->time); |
1099 return TRUE; | 1102 return TRUE; |
1100 } | 1103 } |
1101 | 1104 |
1102 void BrowserActionsToolbarGtk::OnButtonShowOrHide(GtkWidget* sender) { | 1105 void BrowserActionsToolbarGtk::OnButtonShowOrHide(GtkWidget* sender) { |
1103 if (!resize_animation_.is_animating()) | 1106 if (!resize_animation_.is_animating()) |
1104 UpdateChevronVisibility(); | 1107 UpdateChevronVisibility(); |
1105 } | 1108 } |
OLD | NEW |