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

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

Issue 246037: Integrate browser actions with the wrench menu. Browser actions (Closed)
Patch Set: alphabetize 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 1024 matching lines...) Expand 10 before | Expand all | Expand 10 after
1035 if (g_browser_process->have_inspector_files()) { 1035 if (g_browser_process->have_inspector_files()) {
1036 devtools_menu_contents_->AddItem(IDC_DEV_TOOLS, 1036 devtools_menu_contents_->AddItem(IDC_DEV_TOOLS,
1037 l10n_util::GetString(IDS_DEV_TOOLS)); 1037 l10n_util::GetString(IDS_DEV_TOOLS));
1038 } 1038 }
1039 devtools_menu_contents_->AddItem(IDC_TASK_MANAGER, 1039 devtools_menu_contents_->AddItem(IDC_TASK_MANAGER,
1040 l10n_util::GetString(IDS_TASK_MANAGER)); 1040 l10n_util::GetString(IDS_TASK_MANAGER));
1041 } 1041 }
1042 #endif 1042 #endif
1043 1043
1044 void ToolbarView::CreateAppMenu() { 1044 void ToolbarView::CreateAppMenu() {
1045 if (app_menu_contents_.get()) 1045 // We always rebuild the app menu so that we can get the current state of the
1046 return; 1046 // extension system.
1047 1047
1048 app_menu_contents_.reset(new views::SimpleMenuModel(this)); 1048 app_menu_contents_.reset(new views::SimpleMenuModel(this));
1049 app_menu_contents_->AddItemWithStringId(IDC_NEW_TAB, IDS_NEW_TAB); 1049 app_menu_contents_->AddItemWithStringId(IDC_NEW_TAB, IDS_NEW_TAB);
1050 app_menu_contents_->AddItemWithStringId(IDC_NEW_WINDOW, IDS_NEW_WINDOW); 1050 app_menu_contents_->AddItemWithStringId(IDC_NEW_WINDOW, IDS_NEW_WINDOW);
1051 app_menu_contents_->AddItemWithStringId(IDC_NEW_INCOGNITO_WINDOW, 1051 app_menu_contents_->AddItemWithStringId(IDC_NEW_INCOGNITO_WINDOW,
1052 IDS_NEW_INCOGNITO_WINDOW); 1052 IDS_NEW_INCOGNITO_WINDOW);
1053 // Enumerate profiles asynchronously and then create the parent menu item. 1053 // Enumerate profiles asynchronously and then create the parent menu item.
1054 // We will create the child menu items for this once the asynchronous call is 1054 // We will create the child menu items for this once the asynchronous call is
1055 // done. See OnGetProfilesDone(). 1055 // done. See OnGetProfilesDone().
1056 const CommandLine& command_line = *CommandLine::ForCurrentProcess(); 1056 const CommandLine& command_line = *CommandLine::ForCurrentProcess();
1057 if (command_line.HasSwitch(switches::kEnableUserDataDirProfiles)) { 1057 if (command_line.HasSwitch(switches::kEnableUserDataDirProfiles) &&
1058 !profiles_menu_contents_.get()) {
1058 profiles_helper_->GetProfiles(NULL); 1059 profiles_helper_->GetProfiles(NULL);
1059 profiles_menu_contents_.reset(new views::SimpleMenuModel(this)); 1060 profiles_menu_contents_.reset(new views::SimpleMenuModel(this));
1060 app_menu_contents_->AddSubMenuWithStringId(IDS_PROFILE_MENU, 1061 app_menu_contents_->AddSubMenuWithStringId(IDS_PROFILE_MENU,
1061 profiles_menu_contents_.get()); 1062 profiles_menu_contents_.get());
1062 } 1063 }
1063 1064
1064 app_menu_contents_->AddSeparator(); 1065 app_menu_contents_->AddSeparator();
1065 app_menu_contents_->AddCheckItemWithStringId(IDC_SHOW_BOOKMARK_BAR, 1066 app_menu_contents_->AddCheckItemWithStringId(IDC_SHOW_BOOKMARK_BAR,
1066 IDS_SHOW_BOOKMARK_BAR); 1067 IDS_SHOW_BOOKMARK_BAR);
1067 app_menu_contents_->AddItemWithStringId(IDC_FULLSCREEN, IDS_FULLSCREEN); 1068 app_menu_contents_->AddItemWithStringId(IDC_FULLSCREEN, IDS_FULLSCREEN);
1068 app_menu_contents_->AddSeparator(); 1069 app_menu_contents_->AddSeparator();
1069 app_menu_contents_->AddItemWithStringId(IDC_SHOW_HISTORY, IDS_SHOW_HISTORY); 1070 app_menu_contents_->AddItemWithStringId(IDC_SHOW_HISTORY, IDS_SHOW_HISTORY);
1070 app_menu_contents_->AddItemWithStringId(IDC_SHOW_BOOKMARK_MANAGER, 1071 app_menu_contents_->AddItemWithStringId(IDC_SHOW_BOOKMARK_MANAGER,
1071 IDS_BOOKMARK_MANAGER); 1072 IDS_BOOKMARK_MANAGER);
1072 app_menu_contents_->AddItemWithStringId(IDC_SHOW_DOWNLOADS, 1073 app_menu_contents_->AddItemWithStringId(IDC_SHOW_DOWNLOADS,
1073 IDS_SHOW_DOWNLOADS); 1074 IDS_SHOW_DOWNLOADS);
1075
1076 // Create the extensions item or submenu.
1077 // If there are any browser actions, we create an "Extensions" submenu, of
1078 // which "Manage extensions" is the first entry. If there are no browser
1079 // actions, we just create an "Extensions" menu item which does the same thing
1080 // as "Manage extensions".
1081 ExtensionsService* extensions_service =
1082 browser_->profile()->GetExtensionsService();
1083 if (extensions_service && extensions_service->extensions_enabled()) {
1084 std::vector<ContextualAction*> browser_actions =
1085 browser_->profile()->GetExtensionsService()->GetBrowserActions();
1086 if (browser_actions.size() == 0) {
1087 app_menu_contents_->AddItemWithStringId(IDC_MANAGE_EXTENSIONS,
1088 IDS_SHOW_EXTENSIONS);
1089 } else {
1090 extension_menu_contents_.reset(new views::SimpleMenuModel(this));
1091 app_menu_contents_->AddSubMenuWithStringId(
1092 IDS_SHOW_EXTENSIONS, extension_menu_contents_.get());
1093
1094 extension_menu_contents_->AddItemWithStringId(IDC_MANAGE_EXTENSIONS,
1095 IDS_MANAGE_EXTENSIONS);
1096 for (size_t i = 0; i < browser_actions.size(); ++i) {
1097 if (browser_actions[i]->command_id() > IDC_BROWSER_ACTION_LAST) {
1098 NOTREACHED() << "Too many browser actions.";
1099 } else {
1100 extension_menu_contents_->AddItem(
1101 browser_actions[i]->command_id(),
1102 UTF8ToUTF16(browser_actions[i]->name()));
1103 }
1104 }
1105 }
1106 }
1107
1074 app_menu_contents_->AddSeparator(); 1108 app_menu_contents_->AddSeparator();
1075 #ifdef CHROME_PERSONALIZATION 1109 #ifdef CHROME_PERSONALIZATION
1076 if (CommandLine::ForCurrentProcess()->HasSwitch(switches::kEnableSync)) { 1110 if (CommandLine::ForCurrentProcess()->HasSwitch(switches::kEnableSync)) {
1077 app_menu_contents_->AddItem(IDC_SYNC_BOOKMARKS, 1111 app_menu_contents_->AddItem(IDC_SYNC_BOOKMARKS,
1078 l10n_util::GetString(IDS_SYNC_MENU_LABEL)); 1112 l10n_util::GetString(IDS_SYNC_MENU_LABEL));
1079 app_menu_contents_->AddSeparator(); 1113 app_menu_contents_->AddSeparator();
1080 } 1114 }
1081 #endif 1115 #endif
1082 app_menu_contents_->AddItem(IDC_OPTIONS, 1116 app_menu_contents_->AddItem(IDC_OPTIONS,
1083 l10n_util::GetStringFUTF16( 1117 l10n_util::GetStringFUTF16(
1084 IDS_OPTIONS, 1118 IDS_OPTIONS,
1085 l10n_util::GetStringUTF16(IDS_PRODUCT_NAME))); 1119 l10n_util::GetStringUTF16(IDS_PRODUCT_NAME)));
1086 app_menu_contents_->AddItem(IDC_ABOUT, 1120 app_menu_contents_->AddItem(IDC_ABOUT,
1087 l10n_util::GetStringFUTF16( 1121 l10n_util::GetStringFUTF16(
1088 IDS_ABOUT, 1122 IDS_ABOUT,
1089 l10n_util::GetStringUTF16(IDS_PRODUCT_NAME))); 1123 l10n_util::GetStringUTF16(IDS_PRODUCT_NAME)));
1090 app_menu_contents_->AddItemWithStringId(IDC_HELP_PAGE, IDS_HELP_PAGE); 1124 app_menu_contents_->AddItemWithStringId(IDC_HELP_PAGE, IDS_HELP_PAGE);
1091 app_menu_contents_->AddSeparator(); 1125 app_menu_contents_->AddSeparator();
1092 app_menu_contents_->AddItemWithStringId(IDC_EXIT, IDS_EXIT); 1126 app_menu_contents_->AddItemWithStringId(IDC_EXIT, IDS_EXIT);
1093 1127
1094 app_menu_menu_.reset(new views::Menu2(app_menu_contents_.get())); 1128 app_menu_menu_.reset(new views::Menu2(app_menu_contents_.get()));
1095 } 1129 }
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