Chromium Code Reviews| 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/message_loop.h" | 14 #include "base/message_loop/message_loop.h" |
| 15 #include "base/strings/utf_string_conversions.h" | 15 #include "base/strings/utf_string_conversions.h" |
| 16 #include "chrome/browser/chrome_notification_types.h" | 16 #include "chrome/browser/chrome_notification_types.h" |
| 17 #include "chrome/browser/extensions/api/commands/command_service.h" | 17 #include "chrome/browser/extensions/api/commands/command_service.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/extensions/extension_system.h" |
| 24 #include "chrome/browser/profiles/profile.h" | 24 #include "chrome/browser/profiles/profile.h" |
| 25 #include "chrome/browser/sessions/session_tab_helper.h" | 25 #include "chrome/browser/sessions/session_tab_helper.h" |
| 26 #include "chrome/browser/ui/browser.h" | 26 #include "chrome/browser/ui/browser.h" |
| 27 #include "chrome/browser/ui/browser_list.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" |
| 33 #include "chrome/browser/ui/gtk/gtk_util.h" | 34 #include "chrome/browser/ui/gtk/gtk_util.h" |
| 34 #include "chrome/browser/ui/gtk/hover_controller_gtk.h" | 35 #include "chrome/browser/ui/gtk/hover_controller_gtk.h" |
| 35 #include "chrome/browser/ui/gtk/menu_gtk.h" | 36 #include "chrome/browser/ui/gtk/menu_gtk.h" |
| 36 #include "chrome/browser/ui/gtk/view_id_util.h" | 37 #include "chrome/browser/ui/gtk/view_id_util.h" |
| (...skipping 724 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... | |
| 761 NOTREACHED(); | 762 NOTREACHED(); |
| 762 return; | 763 return; |
| 763 } | 764 } |
| 764 | 765 |
| 765 if (profile_->IsOffTheRecord()) | 766 if (profile_->IsOffTheRecord()) |
| 766 index = model_->OriginalIndexToIncognito(index); | 767 index = model_->OriginalIndexToIncognito(index); |
| 767 | 768 |
| 768 gtk_box_reorder_child(GTK_BOX(button_hbox_.get()), button_widget, index); | 769 gtk_box_reorder_child(GTK_BOX(button_hbox_.get()), button_widget, index); |
| 769 } | 770 } |
| 770 | 771 |
| 772 void BrowserActionsToolbarGtk::BrowserActionShowPopup( | |
| 773 const Extension* extension) { | |
| 774 // Do not override other popups and only show in active window. | |
| 775 if (ExtensionPopupGtk::get_current_extension_popup() != NULL || | |
|
mark a. foltz
2013/10/11 20:25:30
Does the toolbar model know if there is an active
justinlin
2013/10/16 07:06:48
No, the model doesn't know anything about whether
| |
| 776 BrowserList::GetInstance(chrome::GetActiveDesktop())->GetLastActive() != | |
| 777 browser()) { | |
| 778 return; | |
| 779 } | |
| 780 | |
| 781 GURL popupUrl = model_->GetPopupUrl(extension, browser()); | |
| 782 if (!popupUrl.is_empty()) { | |
| 783 ExtensionPopupGtk::Show(popup_url, browser(), button->widget(), | |
| 784 ExtensionPopupGtk::SHOW); | |
| 785 } | |
| 786 } | |
| 787 | |
| 771 void BrowserActionsToolbarGtk::ModelLoaded() { | 788 void BrowserActionsToolbarGtk::ModelLoaded() { |
| 772 SetContainerWidth(); | 789 SetContainerWidth(); |
| 773 } | 790 } |
| 774 | 791 |
| 775 void BrowserActionsToolbarGtk::AnimationProgressed( | 792 void BrowserActionsToolbarGtk::AnimationProgressed( |
| 776 const gfx::Animation* animation) { | 793 const gfx::Animation* animation) { |
| 777 int width = start_width_ + (desired_width_ - start_width_) * | 794 int width = start_width_ + (desired_width_ - start_width_) * |
| 778 animation->GetCurrentValue(); | 795 animation->GetCurrentValue(); |
| 779 gtk_widget_set_size_request(button_hbox_.get(), width, -1); | 796 gtk_widget_set_size_request(button_hbox_.get(), width, -1); |
| 780 | 797 |
| (...skipping 308 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... | |
| 1089 | 1106 |
| 1090 menu->PopupAsContext(gfx::Point(event->x_root, event->y_root), | 1107 menu->PopupAsContext(gfx::Point(event->x_root, event->y_root), |
| 1091 event->time); | 1108 event->time); |
| 1092 return TRUE; | 1109 return TRUE; |
| 1093 } | 1110 } |
| 1094 | 1111 |
| 1095 void BrowserActionsToolbarGtk::OnButtonShowOrHide(GtkWidget* sender) { | 1112 void BrowserActionsToolbarGtk::OnButtonShowOrHide(GtkWidget* sender) { |
| 1096 if (!resize_animation_.is_animating()) | 1113 if (!resize_animation_.is_animating()) |
| 1097 UpdateChevronVisibility(); | 1114 UpdateChevronVisibility(); |
| 1098 } | 1115 } |
| OLD | NEW |