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

Side by Side Diff: chrome/browser/ui/toolbar/wrench_menu_model.cc

Issue 11198025: Site specific secondary tiles for Windows 8. (Closed) Base URL: svn://svn.chromium.org/chrome/trunk/src
Patch Set: Feedback Created 8 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 | Annotate | Revision Log
« no previous file with comments | « chrome/browser/ui/tab_contents/tab_contents.cc ('k') | chrome/chrome_browser_ui.gypi » ('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/toolbar/wrench_menu_model.h" 5 #include "chrome/browser/ui/toolbar/wrench_menu_model.h"
6 6
7 #include <algorithm> 7 #include <algorithm>
8 #include <cmath> 8 #include <cmath>
9 9
10 #include "base/command_line.h" 10 #include "base/command_line.h"
(...skipping 15 matching lines...) Expand all
26 #include "chrome/browser/sync/sync_ui_util.h" 26 #include "chrome/browser/sync/sync_ui_util.h"
27 #include "chrome/browser/task_manager/task_manager.h" 27 #include "chrome/browser/task_manager/task_manager.h"
28 #include "chrome/browser/ui/browser.h" 28 #include "chrome/browser/ui/browser.h"
29 #include "chrome/browser/ui/browser_commands.h" 29 #include "chrome/browser/ui/browser_commands.h"
30 #include "chrome/browser/ui/browser_finder.h" 30 #include "chrome/browser/ui/browser_finder.h"
31 #include "chrome/browser/ui/browser_tabstrip.h" 31 #include "chrome/browser/ui/browser_tabstrip.h"
32 #include "chrome/browser/ui/browser_window.h" 32 #include "chrome/browser/ui/browser_window.h"
33 #include "chrome/browser/ui/global_error/global_error.h" 33 #include "chrome/browser/ui/global_error/global_error.h"
34 #include "chrome/browser/ui/global_error/global_error_service.h" 34 #include "chrome/browser/ui/global_error/global_error_service.h"
35 #include "chrome/browser/ui/global_error/global_error_service_factory.h" 35 #include "chrome/browser/ui/global_error/global_error_service_factory.h"
36 #include "chrome/browser/ui/metro_pin_tab_helper.h"
37 #include "chrome/browser/ui/tab_contents/tab_contents.h" 36 #include "chrome/browser/ui/tab_contents/tab_contents.h"
38 #include "chrome/browser/ui/tabs/tab_strip_model.h" 37 #include "chrome/browser/ui/tabs/tab_strip_model.h"
39 #include "chrome/browser/ui/toolbar/encoding_menu_controller.h" 38 #include "chrome/browser/ui/toolbar/encoding_menu_controller.h"
40 #include "chrome/browser/upgrade_detector.h" 39 #include "chrome/browser/upgrade_detector.h"
41 #include "chrome/common/chrome_paths.h" 40 #include "chrome/common/chrome_paths.h"
42 #include "chrome/common/chrome_switches.h" 41 #include "chrome/common/chrome_switches.h"
43 #include "chrome/common/pref_names.h" 42 #include "chrome/common/pref_names.h"
44 #include "chrome/common/profiling.h" 43 #include "chrome/common/profiling.h"
45 #include "content/public/browser/host_zoom_map.h" 44 #include "content/public/browser/host_zoom_map.h"
46 #include "content/public/browser/navigation_entry.h" 45 #include "content/public/browser/navigation_entry.h"
(...skipping 14 matching lines...) Expand all
61 60
62 #if defined(TOOLKIT_GTK) 61 #if defined(TOOLKIT_GTK)
63 #include <gtk/gtk.h> 62 #include <gtk/gtk.h>
64 #include "chrome/browser/ui/gtk/gtk_util.h" 63 #include "chrome/browser/ui/gtk/gtk_util.h"
65 #endif 64 #endif
66 65
67 #if defined(OS_WIN) 66 #if defined(OS_WIN)
68 #include "base/win/metro.h" 67 #include "base/win/metro.h"
69 #include "base/win/windows_version.h" 68 #include "base/win/windows_version.h"
70 #include "chrome/browser/enumerate_modules_model_win.h" 69 #include "chrome/browser/enumerate_modules_model_win.h"
70 #include "chrome/browser/ui/metro_pin_tab_helper_win.h"
71 #endif 71 #endif
72 72
73 #if defined(USE_ASH) 73 #if defined(USE_ASH)
74 #include "ash/shell.h" 74 #include "ash/shell.h"
75 #endif 75 #endif
76 76
77 using content::HostZoomMap; 77 using content::HostZoomMap;
78 using content::UserMetricsAction; 78 using content::UserMetricsAction;
79 using content::WebContents; 79 using content::WebContents;
80 80
(...skipping 156 matching lines...) Expand 10 before | Expand all | Expand 10 after
237 } 237 }
238 238
239 bool WrenchMenuModel::DoesCommandIdDismissMenu(int command_id) const { 239 bool WrenchMenuModel::DoesCommandIdDismissMenu(int command_id) const {
240 return command_id != IDC_ZOOM_MINUS && command_id != IDC_ZOOM_PLUS; 240 return command_id != IDC_ZOOM_MINUS && command_id != IDC_ZOOM_PLUS;
241 } 241 }
242 242
243 bool WrenchMenuModel::IsItemForCommandIdDynamic(int command_id) const { 243 bool WrenchMenuModel::IsItemForCommandIdDynamic(int command_id) const {
244 return command_id == IDC_ZOOM_PERCENT_DISPLAY || 244 return command_id == IDC_ZOOM_PERCENT_DISPLAY ||
245 #if defined(OS_MACOSX) 245 #if defined(OS_MACOSX)
246 command_id == IDC_FULLSCREEN || 246 command_id == IDC_FULLSCREEN ||
247 #elif defined(OS_WIN)
248 command_id == IDC_PIN_TO_START_SCREEN ||
247 #endif 249 #endif
248 command_id == IDC_VIEW_BACKGROUND_PAGES || 250 command_id == IDC_VIEW_BACKGROUND_PAGES ||
249 command_id == IDC_UPGRADE_DIALOG || 251 command_id == IDC_UPGRADE_DIALOG ||
250 command_id == IDC_SHOW_SYNC_SETUP || 252 command_id == IDC_SHOW_SYNC_SETUP;
251 command_id == IDC_PIN_TO_START_SCREEN;
252 } 253 }
253 254
254 string16 WrenchMenuModel::GetLabelForCommandId(int command_id) const { 255 string16 WrenchMenuModel::GetLabelForCommandId(int command_id) const {
255 switch (command_id) { 256 switch (command_id) {
256 case IDC_ZOOM_PERCENT_DISPLAY: 257 case IDC_ZOOM_PERCENT_DISPLAY:
257 return zoom_label_; 258 return zoom_label_;
258 #if defined(OS_MACOSX) 259 #if defined(OS_MACOSX)
259 case IDC_FULLSCREEN: { 260 case IDC_FULLSCREEN: {
260 int string_id = IDS_ENTER_FULLSCREEN_MAC; // Default to Enter. 261 int string_id = IDS_ENTER_FULLSCREEN_MAC; // Default to Enter.
261 // Note: On startup, |window()| may be NULL. 262 // Note: On startup, |window()| may be NULL.
262 if (browser_->window() && browser_->window()->IsFullscreen()) 263 if (browser_->window() && browser_->window()->IsFullscreen())
263 string_id = IDS_EXIT_FULLSCREEN_MAC; 264 string_id = IDS_EXIT_FULLSCREEN_MAC;
264 return l10n_util::GetStringUTF16(string_id); 265 return l10n_util::GetStringUTF16(string_id);
265 } 266 }
267 #elif defined(OS_WIN)
268 case IDC_PIN_TO_START_SCREEN: {
269 int string_id = IDS_PIN_TO_START_SCREEN;
270 WebContents* web_contents = chrome::GetActiveWebContents(browser_);
271 MetroPinTabHelper* tab_helper =
272 web_contents ? MetroPinTabHelper::FromWebContents(web_contents)
273 : NULL;
274 if (tab_helper && tab_helper->is_pinned())
275 string_id = IDS_UNPIN_FROM_START_SCREEN;
276 return l10n_util::GetStringUTF16(string_id);
277 }
266 #endif 278 #endif
267 case IDC_VIEW_BACKGROUND_PAGES: { 279 case IDC_VIEW_BACKGROUND_PAGES: {
268 string16 num_background_pages = base::FormatNumber( 280 string16 num_background_pages = base::FormatNumber(
269 TaskManager::GetBackgroundPageCount()); 281 TaskManager::GetBackgroundPageCount());
270 return l10n_util::GetStringFUTF16(IDS_VIEW_BACKGROUND_PAGES, 282 return l10n_util::GetStringFUTF16(IDS_VIEW_BACKGROUND_PAGES,
271 num_background_pages); 283 num_background_pages);
272 } 284 }
273 case IDC_UPGRADE_DIALOG: 285 case IDC_UPGRADE_DIALOG:
274 return l10n_util::GetStringUTF16(IDS_UPDATE_NOW); 286 return l10n_util::GetStringUTF16(IDS_UPDATE_NOW);
275 case IDC_SHOW_SYNC_SETUP: { 287 case IDC_SHOW_SYNC_SETUP: {
276 ProfileSyncService* service = 288 ProfileSyncService* service =
277 ProfileSyncServiceFactory::GetInstance()->GetForProfile( 289 ProfileSyncServiceFactory::GetInstance()->GetForProfile(
278 browser_->profile()->GetOriginalProfile()); 290 browser_->profile()->GetOriginalProfile());
279 SyncGlobalError* error = service->sync_global_error(); 291 SyncGlobalError* error = service->sync_global_error();
280 if (error && error->HasCustomizedSyncMenuItem()) 292 if (error && error->HasCustomizedSyncMenuItem())
281 return error->MenuItemLabel(); 293 return error->MenuItemLabel();
282 if (service->HasSyncSetupCompleted()) { 294 if (service->HasSyncSetupCompleted()) {
283 std::string username = browser_->profile()->GetPrefs()->GetString( 295 std::string username = browser_->profile()->GetPrefs()->GetString(
284 prefs::kGoogleServicesUsername); 296 prefs::kGoogleServicesUsername);
285 if (!username.empty()) { 297 if (!username.empty()) {
286 return l10n_util::GetStringFUTF16(IDS_SYNC_MENU_SYNCED_LABEL, 298 return l10n_util::GetStringFUTF16(IDS_SYNC_MENU_SYNCED_LABEL,
287 UTF8ToUTF16(username)); 299 UTF8ToUTF16(username));
288 } 300 }
289 } 301 }
290 return l10n_util::GetStringFUTF16(IDS_SYNC_MENU_PRE_SYNCED_LABEL, 302 return l10n_util::GetStringFUTF16(IDS_SYNC_MENU_PRE_SYNCED_LABEL,
291 l10n_util::GetStringUTF16(IDS_SHORT_PRODUCT_NAME)); 303 l10n_util::GetStringUTF16(IDS_SHORT_PRODUCT_NAME));
292 } 304 }
293 case IDC_PIN_TO_START_SCREEN: {
294 int string_id = IDS_PIN_TO_START_SCREEN;
295 WebContents* web_contents = chrome::GetActiveWebContents(browser_);
296 MetroPinTabHelper* tab_helper =
297 web_contents ? MetroPinTabHelper::FromWebContents(web_contents)
298 : NULL;
299 if (tab_helper && tab_helper->is_pinned())
300 string_id = IDS_UNPIN_FROM_START_SCREEN;
301 return l10n_util::GetStringUTF16(string_id);
302 }
303 default: 305 default:
304 NOTREACHED(); 306 NOTREACHED();
305 return string16(); 307 return string16();
306 } 308 }
307 } 309 }
308 310
309 bool WrenchMenuModel::GetIconForCommandId(int command_id, 311 bool WrenchMenuModel::GetIconForCommandId(int command_id,
310 gfx::Image* icon) const { 312 gfx::Image* icon) const {
311 ui::ResourceBundle& rb = ui::ResourceBundle::GetSharedInstance(); 313 ui::ResourceBundle& rb = ui::ResourceBundle::GetSharedInstance();
312 switch (command_id) { 314 switch (command_id) {
(...skipping 402 matching lines...) Expand 10 before | Expand all | Expand 10 after
715 zoom_label_ = l10n_util::GetStringFUTF16( 717 zoom_label_ = l10n_util::GetStringFUTF16(
716 IDS_ZOOM_PERCENT, base::IntToString16(zoom_percent)); 718 IDS_ZOOM_PERCENT, base::IntToString16(zoom_percent));
717 } 719 }
718 720
719 string16 WrenchMenuModel::GetSyncMenuLabel() const { 721 string16 WrenchMenuModel::GetSyncMenuLabel() const {
720 Profile* profile = browser_->profile()->GetOriginalProfile(); 722 Profile* profile = browser_->profile()->GetOriginalProfile();
721 return sync_ui_util::GetSyncMenuLabel( 723 return sync_ui_util::GetSyncMenuLabel(
722 ProfileSyncServiceFactory::GetForProfile(profile), 724 ProfileSyncServiceFactory::GetForProfile(profile),
723 *SigninManagerFactory::GetForProfile(profile)); 725 *SigninManagerFactory::GetForProfile(profile));
724 } 726 }
OLDNEW
« no previous file with comments | « chrome/browser/ui/tab_contents/tab_contents.cc ('k') | chrome/chrome_browser_ui.gypi » ('j') | no next file with comments »

Powered by Google App Engine
This is Rietveld 408576698