OLD | NEW |
1 // Copyright 2013 The Chromium Authors. All rights reserved. | 1 // Copyright 2013 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/views/toolbar/app_menu.h" | 5 #include "chrome/browser/ui/views/toolbar/app_menu.h" |
6 | 6 |
7 #include <stdint.h> | 7 #include <stdint.h> |
8 | 8 |
9 #include <algorithm> | 9 #include <algorithm> |
10 #include <cmath> | 10 #include <cmath> |
(...skipping 784 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
795 observer.AppMenuDestroyed(); | 795 observer.AppMenuDestroyed(); |
796 } | 796 } |
797 | 797 |
798 void AppMenu::Init(ui::MenuModel* model) { | 798 void AppMenu::Init(ui::MenuModel* model) { |
799 DCHECK(!root_); | 799 DCHECK(!root_); |
800 root_ = new MenuItemView(this); | 800 root_ = new MenuItemView(this); |
801 root_->set_has_icons(true); // We have checks, radios and icons, set this | 801 root_->set_has_icons(true); // We have checks, radios and icons, set this |
802 // so we get the taller menu style. | 802 // so we get the taller menu style. |
803 PopulateMenu(root_, model); | 803 PopulateMenu(root_, model); |
804 | 804 |
805 int32_t types = views::MenuRunner::HAS_MNEMONICS | views::MenuRunner::ASYNC; | 805 int32_t types = views::MenuRunner::HAS_MNEMONICS; |
806 if (for_drop()) { | 806 if (for_drop()) { |
807 // We add NESTED_DRAG since currently the only operation to open the app | 807 // We add NESTED_DRAG since currently the only operation to open the app |
808 // menu for is an extension action drag, which is controlled by the child | 808 // menu for is an extension action drag, which is controlled by the child |
809 // BrowserActionsContainer view. | 809 // BrowserActionsContainer view. |
810 types |= views::MenuRunner::FOR_DROP | views::MenuRunner::NESTED_DRAG; | 810 types |= views::MenuRunner::FOR_DROP | views::MenuRunner::NESTED_DRAG; |
811 } | 811 } |
812 menu_runner_.reset(new views::MenuRunner(root_, types)); | 812 menu_runner_.reset(new views::MenuRunner(root_, types)); |
813 } | 813 } |
814 | 814 |
815 void AppMenu::RunMenu(views::MenuButton* host) { | 815 void AppMenu::RunMenu(views::MenuButton* host) { |
(...skipping 212 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
1028 // ToolbarView::RunMenu() and Init() of this class. | 1028 // ToolbarView::RunMenu() and Init() of this class. |
1029 menu->GetSubmenu()->GetWidget()-> | 1029 menu->GetSubmenu()->GetWidget()-> |
1030 SetVisibilityChangedAnimationsEnabled(false); | 1030 SetVisibilityChangedAnimationsEnabled(false); |
1031 } | 1031 } |
1032 } | 1032 } |
1033 | 1033 |
1034 bool AppMenu::ShouldCloseOnDragComplete() { | 1034 bool AppMenu::ShouldCloseOnDragComplete() { |
1035 return false; | 1035 return false; |
1036 } | 1036 } |
1037 | 1037 |
1038 void AppMenu::OnMenuClosed(views::MenuItemView* menu, | 1038 void AppMenu::OnMenuClosed(views::MenuItemView* menu) { |
1039 views::MenuRunner::RunResult result) { | |
1040 if (bookmark_menu_delegate_.get()) { | 1039 if (bookmark_menu_delegate_.get()) { |
1041 BookmarkModel* model = | 1040 BookmarkModel* model = |
1042 BookmarkModelFactory::GetForBrowserContext(browser_->profile()); | 1041 BookmarkModelFactory::GetForBrowserContext(browser_->profile()); |
1043 if (model) | 1042 if (model) |
1044 model->RemoveObserver(this); | 1043 model->RemoveObserver(this); |
1045 } | 1044 } |
1046 if (selected_menu_model_) | 1045 if (selected_menu_model_) |
1047 selected_menu_model_->ActivatedAt(selected_index_); | 1046 selected_menu_model_->ActivatedAt(selected_index_); |
1048 } | 1047 } |
1049 | 1048 |
(...skipping 186 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
1236 0, | 1235 0, |
1237 BookmarkMenuDelegate::SHOW_PERMANENT_FOLDERS, | 1236 BookmarkMenuDelegate::SHOW_PERMANENT_FOLDERS, |
1238 BOOKMARK_LAUNCH_LOCATION_APP_MENU); | 1237 BOOKMARK_LAUNCH_LOCATION_APP_MENU); |
1239 } | 1238 } |
1240 | 1239 |
1241 int AppMenu::ModelIndexFromCommandId(int command_id) const { | 1240 int AppMenu::ModelIndexFromCommandId(int command_id) const { |
1242 CommandIDToEntry::const_iterator ix = command_id_to_entry_.find(command_id); | 1241 CommandIDToEntry::const_iterator ix = command_id_to_entry_.find(command_id); |
1243 DCHECK(ix != command_id_to_entry_.end()); | 1242 DCHECK(ix != command_id_to_entry_.end()); |
1244 return ix->second.second; | 1243 return ix->second.second; |
1245 } | 1244 } |
OLD | NEW |