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

Side by Side Diff: chrome/browser/views/toolbar_view.cc

Issue 276010: Remove the implicit wrench menu items for browser actions. (Closed)
Patch Set: Rebase Created 11 years, 2 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
« no previous file with comments | « chrome/browser/views/toolbar_view.h ('k') | chrome/chrome.gyp » ('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) 2009 The Chromium Authors. All rights reserved. 1 // Copyright (c) 2009 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/views/toolbar_view.h" 5 #include "chrome/browser/views/toolbar_view.h"
6 6
7 #include <string> 7 #include <string>
8 8
9 #include "app/drag_drop_types.h" 9 #include "app/drag_drop_types.h"
10 #include "app/gfx/canvas.h" 10 #include "app/gfx/canvas.h"
(...skipping 1063 matching lines...) Expand 10 before | Expand all | Expand 10 after
1074 if (g_browser_process->have_inspector_files()) { 1074 if (g_browser_process->have_inspector_files()) {
1075 devtools_menu_contents_->AddItem(IDC_DEV_TOOLS, 1075 devtools_menu_contents_->AddItem(IDC_DEV_TOOLS,
1076 l10n_util::GetString(IDS_DEV_TOOLS)); 1076 l10n_util::GetString(IDS_DEV_TOOLS));
1077 } 1077 }
1078 devtools_menu_contents_->AddItem(IDC_TASK_MANAGER, 1078 devtools_menu_contents_->AddItem(IDC_TASK_MANAGER,
1079 l10n_util::GetString(IDS_TASK_MANAGER)); 1079 l10n_util::GetString(IDS_TASK_MANAGER));
1080 } 1080 }
1081 #endif 1081 #endif
1082 1082
1083 void ToolbarView::CreateAppMenu() { 1083 void ToolbarView::CreateAppMenu() {
1084 // We always rebuild the app menu so that we can get the current state of the 1084 if (app_menu_contents_.get())
1085 // extension system. 1085 return;
1086 1086
1087 app_menu_contents_.reset(new views::SimpleMenuModel(this)); 1087 app_menu_contents_.reset(new views::SimpleMenuModel(this));
1088 app_menu_contents_->AddItemWithStringId(IDC_NEW_TAB, IDS_NEW_TAB); 1088 app_menu_contents_->AddItemWithStringId(IDC_NEW_TAB, IDS_NEW_TAB);
1089 app_menu_contents_->AddItemWithStringId(IDC_NEW_WINDOW, IDS_NEW_WINDOW); 1089 app_menu_contents_->AddItemWithStringId(IDC_NEW_WINDOW, IDS_NEW_WINDOW);
1090 app_menu_contents_->AddItemWithStringId(IDC_NEW_INCOGNITO_WINDOW, 1090 app_menu_contents_->AddItemWithStringId(IDC_NEW_INCOGNITO_WINDOW,
1091 IDS_NEW_INCOGNITO_WINDOW); 1091 IDS_NEW_INCOGNITO_WINDOW);
1092 // Enumerate profiles asynchronously and then create the parent menu item. 1092 // Enumerate profiles asynchronously and then create the parent menu item.
1093 // We will create the child menu items for this once the asynchronous call is 1093 // We will create the child menu items for this once the asynchronous call is
1094 // done. See OnGetProfilesDone(). 1094 // done. See OnGetProfilesDone().
1095 const CommandLine& command_line = *CommandLine::ForCurrentProcess(); 1095 const CommandLine& command_line = *CommandLine::ForCurrentProcess();
1096 if (command_line.HasSwitch(switches::kEnableUserDataDirProfiles) && 1096 if (command_line.HasSwitch(switches::kEnableUserDataDirProfiles) &&
1097 !profiles_menu_contents_.get()) { 1097 !profiles_menu_contents_.get()) {
1098 profiles_helper_->GetProfiles(NULL); 1098 profiles_helper_->GetProfiles(NULL);
1099 profiles_menu_contents_.reset(new views::SimpleMenuModel(this)); 1099 profiles_menu_contents_.reset(new views::SimpleMenuModel(this));
1100 app_menu_contents_->AddSubMenuWithStringId(IDS_PROFILE_MENU, 1100 app_menu_contents_->AddSubMenuWithStringId(IDS_PROFILE_MENU,
1101 profiles_menu_contents_.get()); 1101 profiles_menu_contents_.get());
1102 } 1102 }
1103 1103
1104 app_menu_contents_->AddSeparator(); 1104 app_menu_contents_->AddSeparator();
1105 app_menu_contents_->AddCheckItemWithStringId(IDC_SHOW_BOOKMARK_BAR, 1105 app_menu_contents_->AddCheckItemWithStringId(IDC_SHOW_BOOKMARK_BAR,
1106 IDS_SHOW_BOOKMARK_BAR); 1106 IDS_SHOW_BOOKMARK_BAR);
1107 app_menu_contents_->AddItemWithStringId(IDC_FULLSCREEN, IDS_FULLSCREEN); 1107 app_menu_contents_->AddItemWithStringId(IDC_FULLSCREEN, IDS_FULLSCREEN);
1108 app_menu_contents_->AddSeparator(); 1108 app_menu_contents_->AddSeparator();
1109 app_menu_contents_->AddItemWithStringId(IDC_SHOW_HISTORY, IDS_SHOW_HISTORY); 1109 app_menu_contents_->AddItemWithStringId(IDC_SHOW_HISTORY, IDS_SHOW_HISTORY);
1110 app_menu_contents_->AddItemWithStringId(IDC_SHOW_BOOKMARK_MANAGER, 1110 app_menu_contents_->AddItemWithStringId(IDC_SHOW_BOOKMARK_MANAGER,
1111 IDS_BOOKMARK_MANAGER); 1111 IDS_BOOKMARK_MANAGER);
1112 app_menu_contents_->AddItemWithStringId(IDC_SHOW_DOWNLOADS, 1112 app_menu_contents_->AddItemWithStringId(IDC_SHOW_DOWNLOADS,
1113 IDS_SHOW_DOWNLOADS); 1113 IDS_SHOW_DOWNLOADS);
1114 1114
1115 // Create the extensions item or submenu. 1115 // Create the manage extensions menu item.
1116 // If there are any browser actions, we create an "Extensions" submenu, of
1117 // which "Manage extensions" is the first entry. If there are no browser
1118 // actions, we just create an "Extensions" menu item which does the same thing
1119 // as "Manage extensions".
1120 ExtensionsService* extensions_service = 1116 ExtensionsService* extensions_service =
1121 browser_->profile()->GetExtensionsService(); 1117 browser_->profile()->GetExtensionsService();
1122 if (extensions_service && extensions_service->extensions_enabled()) { 1118 if (extensions_service && extensions_service->extensions_enabled()) {
1123 // Get a count of all non-popup browser actions to decide how to layout 1119 app_menu_contents_->AddItemWithStringId(IDC_MANAGE_EXTENSIONS,
1124 // the Extensions menu. 1120 IDS_SHOW_EXTENSIONS);
1125 std::vector<ExtensionAction*> browser_actions =
1126 browser_->profile()->GetExtensionsService()->GetBrowserActions(false);
1127 if (browser_actions.size() == 0) {
1128 app_menu_contents_->AddItemWithStringId(IDC_MANAGE_EXTENSIONS,
1129 IDS_SHOW_EXTENSIONS);
1130 } else {
1131 extension_menu_contents_.reset(new views::SimpleMenuModel(this));
1132 app_menu_contents_->AddSubMenuWithStringId(
1133 IDS_SHOW_EXTENSIONS, extension_menu_contents_.get());
1134
1135 extension_menu_contents_->AddItemWithStringId(IDC_MANAGE_EXTENSIONS,
1136 IDS_MANAGE_EXTENSIONS);
1137
1138 // TODO(erikkay) Even though we just got the list of all browser actions,
1139 // we have to enumerate the list of extensions in order to get the action
1140 // state. It seems like we should find a way to combine these.
1141 const ExtensionList* extensions = extensions_service->extensions();
1142 for (size_t i = 0; i < extensions->size(); ++i) {
1143 Extension* extension = extensions->at(i);
1144 if (!extension->browser_action()) {
1145 continue;
1146 } else if (extension->browser_action()->command_id() >
1147 IDC_BROWSER_ACTION_LAST) {
1148 NOTREACHED() << "Too many browser actions.";
1149 } else if (!extension->browser_action()->is_popup()) {
1150 extension_menu_contents_->AddItem(
1151 extension->browser_action()->command_id(),
1152 UTF8ToUTF16(extension->browser_action_state()->title()));
1153 }
1154 }
1155 }
1156 } 1121 }
1157 1122
1158 app_menu_contents_->AddSeparator(); 1123 app_menu_contents_->AddSeparator();
1159 #ifdef CHROME_PERSONALIZATION 1124 #ifdef CHROME_PERSONALIZATION
1160 if (!CommandLine::ForCurrentProcess()->HasSwitch(switches::kDisableSync)) { 1125 if (!CommandLine::ForCurrentProcess()->HasSwitch(switches::kDisableSync)) {
1161 app_menu_contents_->AddItem(IDC_SYNC_BOOKMARKS, 1126 app_menu_contents_->AddItem(IDC_SYNC_BOOKMARKS,
1162 l10n_util::GetString(IDS_SYNC_MY_BOOKMARKS_LABEL) + L"..."); 1127 l10n_util::GetString(IDS_SYNC_MY_BOOKMARKS_LABEL) + L"...");
1163 app_menu_contents_->AddSeparator(); 1128 app_menu_contents_->AddSeparator();
1164 } 1129 }
1165 #endif 1130 #endif
1166 app_menu_contents_->AddItem(IDC_OPTIONS, 1131 app_menu_contents_->AddItem(IDC_OPTIONS,
1167 l10n_util::GetStringFUTF16( 1132 l10n_util::GetStringFUTF16(
1168 IDS_OPTIONS, 1133 IDS_OPTIONS,
1169 l10n_util::GetStringUTF16(IDS_PRODUCT_NAME))); 1134 l10n_util::GetStringUTF16(IDS_PRODUCT_NAME)));
1170 app_menu_contents_->AddItem(IDC_ABOUT, 1135 app_menu_contents_->AddItem(IDC_ABOUT,
1171 l10n_util::GetStringFUTF16( 1136 l10n_util::GetStringFUTF16(
1172 IDS_ABOUT, 1137 IDS_ABOUT,
1173 l10n_util::GetStringUTF16(IDS_PRODUCT_NAME))); 1138 l10n_util::GetStringUTF16(IDS_PRODUCT_NAME)));
1174 app_menu_contents_->AddItemWithStringId(IDC_HELP_PAGE, IDS_HELP_PAGE); 1139 app_menu_contents_->AddItemWithStringId(IDC_HELP_PAGE, IDS_HELP_PAGE);
1175 app_menu_contents_->AddSeparator(); 1140 app_menu_contents_->AddSeparator();
1176 app_menu_contents_->AddItemWithStringId(IDC_EXIT, IDS_EXIT); 1141 app_menu_contents_->AddItemWithStringId(IDC_EXIT, IDS_EXIT);
1177 1142
1178 app_menu_menu_.reset(new views::Menu2(app_menu_contents_.get())); 1143 app_menu_menu_.reset(new views::Menu2(app_menu_contents_.get()));
1179 } 1144 }
OLDNEW
« no previous file with comments | « chrome/browser/views/toolbar_view.h ('k') | chrome/chrome.gyp » ('j') | no next file with comments »

Powered by Google App Engine
This is Rietveld 408576698