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

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

Issue 16290004: Update chrome/ to use scoped_refptr<T>::get() rather than implicit "operator T*" (Closed) Base URL: svn://svn.chromium.org/chrome/trunk/src
Patch Set: Created 7 years, 6 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
« no previous file with comments | « chrome/browser/ui/browser.cc ('k') | chrome/browser/ui/gtk/infobars/extension_infobar_gtk.cc » ('j') | no next file with comments »
Toggle Intra-line Diffs ('i') | Expand Comments ('e') | Collapse Comments ('c') | Show Comments Hide Comments ('s')
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/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>
(...skipping 608 matching lines...) Expand 10 before | Expand all | Expand 10 after
619 G_CALLBACK(OnDragMotionThunk), this); 619 G_CALLBACK(OnDragMotionThunk), this);
620 } 620 }
621 621
622 void BrowserActionsToolbarGtk::CreateAllButtons() { 622 void BrowserActionsToolbarGtk::CreateAllButtons() {
623 extension_button_map_.clear(); 623 extension_button_map_.clear();
624 624
625 int i = 0; 625 int i = 0;
626 const extensions::ExtensionList& toolbar_items = model_->toolbar_items(); 626 const extensions::ExtensionList& toolbar_items = model_->toolbar_items();
627 for (extensions::ExtensionList::const_iterator iter = toolbar_items.begin(); 627 for (extensions::ExtensionList::const_iterator iter = toolbar_items.begin();
628 iter != toolbar_items.end(); ++iter) { 628 iter != toolbar_items.end(); ++iter) {
629 CreateButtonForExtension(*iter, i++); 629 CreateButtonForExtension(iter->get(), i++);
630 } 630 }
631 } 631 }
632 632
633 void BrowserActionsToolbarGtk::SetContainerWidth() { 633 void BrowserActionsToolbarGtk::SetContainerWidth() {
634 int showing_actions = model_->GetVisibleIconCount(); 634 int showing_actions = model_->GetVisibleIconCount();
635 if (showing_actions >= 0) 635 if (showing_actions >= 0)
636 SetButtonHBoxWidth(WidthForIconCount(showing_actions)); 636 SetButtonHBoxWidth(WidthForIconCount(showing_actions));
637 } 637 }
638 638
639 void BrowserActionsToolbarGtk::CreateButtonForExtension( 639 void BrowserActionsToolbarGtk::CreateButtonForExtension(
(...skipping 149 matching lines...) Expand 10 before | Expand all | Expand 10 after
789 void BrowserActionsToolbarGtk::AnimationEnded(const ui::Animation* animation) { 789 void BrowserActionsToolbarGtk::AnimationEnded(const ui::Animation* animation) {
790 gtk_widget_set_size_request(button_hbox_.get(), desired_width_, -1); 790 gtk_widget_set_size_request(button_hbox_.get(), desired_width_, -1);
791 UpdateChevronVisibility(); 791 UpdateChevronVisibility();
792 } 792 }
793 793
794 bool BrowserActionsToolbarGtk::IsCommandIdChecked(int command_id) const { 794 bool BrowserActionsToolbarGtk::IsCommandIdChecked(int command_id) const {
795 return false; 795 return false;
796 } 796 }
797 797
798 bool BrowserActionsToolbarGtk::IsCommandIdEnabled(int command_id) const { 798 bool BrowserActionsToolbarGtk::IsCommandIdEnabled(int command_id) const {
799 const Extension* extension = model_->toolbar_items()[command_id]; 799 const Extension* extension = model_->toolbar_items()[command_id].get();
800 return ExtensionActionManager::Get(profile_)-> 800 return ExtensionActionManager::Get(profile_)->GetBrowserAction(*extension)
801 GetBrowserAction(*extension)->GetIsVisible(GetCurrentTabId()); 801 ->GetIsVisible(GetCurrentTabId());
802 } 802 }
803 803
804 bool BrowserActionsToolbarGtk::GetAcceleratorForCommandId( 804 bool BrowserActionsToolbarGtk::GetAcceleratorForCommandId(
805 int command_id, 805 int command_id,
806 ui::Accelerator* accelerator) { 806 ui::Accelerator* accelerator) {
807 return false; 807 return false;
808 } 808 }
809 809
810 void BrowserActionsToolbarGtk::ExecuteCommand(int command_id, int event_flags) { 810 void BrowserActionsToolbarGtk::ExecuteCommand(int command_id, int event_flags) {
811 const Extension* extension = model_->toolbar_items()[command_id]; 811 const Extension* extension = model_->toolbar_items()[command_id].get();
812 GURL popup_url; 812 GURL popup_url;
813 813
814 switch (model_->ExecuteBrowserAction(extension, browser(), &popup_url)) { 814 switch (model_->ExecuteBrowserAction(extension, browser(), &popup_url)) {
815 case ExtensionToolbarModel::ACTION_NONE: 815 case ExtensionToolbarModel::ACTION_NONE:
816 break; 816 break;
817 case ExtensionToolbarModel::ACTION_SHOW_POPUP: 817 case ExtensionToolbarModel::ACTION_SHOW_POPUP:
818 ExtensionPopupGtk::Show(popup_url, browser(), chevron(), 818 ExtensionPopupGtk::Show(popup_url, browser(), chevron(),
819 ExtensionPopupGtk::SHOW); 819 ExtensionPopupGtk::SHOW);
820 break; 820 break;
821 } 821 }
(...skipping 211 matching lines...) Expand 10 before | Expand all | Expand 10 after
1033 overflow_menu_model_.reset(new SimpleMenuModel(this)); 1033 overflow_menu_model_.reset(new SimpleMenuModel(this));
1034 1034
1035 int visible_icon_count = 1035 int visible_icon_count =
1036 gtk_chrome_shrinkable_hbox_get_visible_child_count( 1036 gtk_chrome_shrinkable_hbox_get_visible_child_count(
1037 GTK_CHROME_SHRINKABLE_HBOX(button_hbox_.get())); 1037 GTK_CHROME_SHRINKABLE_HBOX(button_hbox_.get()));
1038 for (int i = visible_icon_count; i < button_count(); ++i) { 1038 for (int i = visible_icon_count; i < button_count(); ++i) {
1039 int model_index = i; 1039 int model_index = i;
1040 if (profile_->IsOffTheRecord()) 1040 if (profile_->IsOffTheRecord())
1041 model_index = model_->IncognitoIndexToOriginal(i); 1041 model_index = model_->IncognitoIndexToOriginal(i);
1042 1042
1043 const Extension* extension = model_->toolbar_items()[model_index]; 1043 const Extension* extension = model_->toolbar_items()[model_index].get();
1044 BrowserActionButton* button = extension_button_map_[extension->id()].get(); 1044 BrowserActionButton* button = extension_button_map_[extension->id()].get();
1045 1045
1046 overflow_menu_model_->AddItem(model_index, UTF8ToUTF16(extension->name())); 1046 overflow_menu_model_->AddItem(model_index, UTF8ToUTF16(extension->name()));
1047 overflow_menu_model_->SetIcon(overflow_menu_model_->GetItemCount() - 1, 1047 overflow_menu_model_->SetIcon(overflow_menu_model_->GetItemCount() - 1,
1048 button->GetIcon()); 1048 button->GetIcon());
1049 1049
1050 // TODO(estade): set the menu item's tooltip. 1050 // TODO(estade): set the menu item's tooltip.
1051 } 1051 }
1052 1052
1053 overflow_menu_.reset(new MenuGtk(this, overflow_menu_model_.get())); 1053 overflow_menu_.reset(new MenuGtk(this, overflow_menu_model_.get()));
(...skipping 19 matching lines...) Expand all
1073 if (item_index == -1) { 1073 if (item_index == -1) {
1074 NOTREACHED(); 1074 NOTREACHED();
1075 return FALSE; 1075 return FALSE;
1076 } 1076 }
1077 1077
1078 item_index += gtk_chrome_shrinkable_hbox_get_visible_child_count( 1078 item_index += gtk_chrome_shrinkable_hbox_get_visible_child_count(
1079 GTK_CHROME_SHRINKABLE_HBOX(button_hbox_.get())); 1079 GTK_CHROME_SHRINKABLE_HBOX(button_hbox_.get()));
1080 if (profile_->IsOffTheRecord()) 1080 if (profile_->IsOffTheRecord())
1081 item_index = model_->IncognitoIndexToOriginal(item_index); 1081 item_index = model_->IncognitoIndexToOriginal(item_index);
1082 1082
1083 const Extension* extension = model_->toolbar_items()[item_index]; 1083 const Extension* extension = model_->toolbar_items()[item_index].get();
1084 ExtensionButtonMap::iterator it = extension_button_map_.find( 1084 ExtensionButtonMap::iterator it = extension_button_map_.find(extension->id());
1085 extension->id());
1086 if (it == extension_button_map_.end()) { 1085 if (it == extension_button_map_.end()) {
1087 NOTREACHED(); 1086 NOTREACHED();
1088 return FALSE; 1087 return FALSE;
1089 } 1088 }
1090 1089
1091 MenuGtk* menu = it->second.get()->GetContextMenu(); 1090 MenuGtk* menu = it->second.get()->GetContextMenu();
1092 if (!menu) 1091 if (!menu)
1093 return FALSE; 1092 return FALSE;
1094 1093
1095 menu->PopupAsContext(gfx::Point(event->x_root, event->y_root), 1094 menu->PopupAsContext(gfx::Point(event->x_root, event->y_root),
1096 event->time); 1095 event->time);
1097 return TRUE; 1096 return TRUE;
1098 } 1097 }
1099 1098
1100 void BrowserActionsToolbarGtk::OnButtonShowOrHide(GtkWidget* sender) { 1099 void BrowserActionsToolbarGtk::OnButtonShowOrHide(GtkWidget* sender) {
1101 if (!resize_animation_.is_animating()) 1100 if (!resize_animation_.is_animating())
1102 UpdateChevronVisibility(); 1101 UpdateChevronVisibility();
1103 } 1102 }
OLDNEW
« no previous file with comments | « chrome/browser/ui/browser.cc ('k') | chrome/browser/ui/gtk/infobars/extension_infobar_gtk.cc » ('j') | no next file with comments »

Powered by Google App Engine
This is Rietveld 408576698