OLD | NEW |
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 24 matching lines...) Expand all Loading... |
35 #include "chrome/browser/ui/metro_pin_tab_helper.h" | 35 #include "chrome/browser/ui/metro_pin_tab_helper.h" |
36 #include "chrome/browser/ui/tab_contents/tab_contents.h" | 36 #include "chrome/browser/ui/tab_contents/tab_contents.h" |
37 #include "chrome/browser/ui/tabs/tab_strip_model.h" | 37 #include "chrome/browser/ui/tabs/tab_strip_model.h" |
38 #include "chrome/browser/ui/toolbar/encoding_menu_controller.h" | 38 #include "chrome/browser/ui/toolbar/encoding_menu_controller.h" |
39 #include "chrome/browser/upgrade_detector.h" | 39 #include "chrome/browser/upgrade_detector.h" |
40 #include "chrome/common/chrome_paths.h" | 40 #include "chrome/common/chrome_paths.h" |
41 #include "chrome/common/chrome_switches.h" | 41 #include "chrome/common/chrome_switches.h" |
42 #include "chrome/common/pref_names.h" | 42 #include "chrome/common/pref_names.h" |
43 #include "chrome/common/profiling.h" | 43 #include "chrome/common/profiling.h" |
44 #include "content/public/browser/host_zoom_map.h" | 44 #include "content/public/browser/host_zoom_map.h" |
| 45 #include "content/public/browser/navigation_entry.h" |
45 #include "content/public/browser/notification_service.h" | 46 #include "content/public/browser/notification_service.h" |
46 #include "content/public/browser/notification_source.h" | 47 #include "content/public/browser/notification_source.h" |
47 #include "content/public/browser/notification_types.h" | 48 #include "content/public/browser/notification_types.h" |
48 #include "content/public/browser/user_metrics.h" | 49 #include "content/public/browser/user_metrics.h" |
49 #include "content/public/browser/web_contents.h" | 50 #include "content/public/browser/web_contents.h" |
50 #include "grit/chromium_strings.h" | 51 #include "grit/chromium_strings.h" |
51 #include "grit/generated_resources.h" | 52 #include "grit/generated_resources.h" |
52 #include "grit/theme_resources.h" | 53 #include "grit/theme_resources.h" |
53 #include "ui/base/l10n/l10n_util.h" | 54 #include "ui/base/l10n/l10n_util.h" |
54 #include "ui/base/layout.h" | 55 #include "ui/base/layout.h" |
55 #include "ui/base/models/button_menu_item_model.h" | 56 #include "ui/base/models/button_menu_item_model.h" |
56 #include "ui/base/resource/resource_bundle.h" | 57 #include "ui/base/resource/resource_bundle.h" |
| 58 #include "ui/base/touch/touch_factory.h" |
57 #include "ui/gfx/image/image.h" | 59 #include "ui/gfx/image/image.h" |
58 #include "ui/gfx/image/image_skia.h" | 60 #include "ui/gfx/image/image_skia.h" |
59 | 61 |
60 #if defined(TOOLKIT_GTK) | 62 #if defined(TOOLKIT_GTK) |
61 #include <gtk/gtk.h> | 63 #include <gtk/gtk.h> |
62 #include "chrome/browser/ui/gtk/gtk_util.h" | 64 #include "chrome/browser/ui/gtk/gtk_util.h" |
63 #endif | 65 #endif |
64 | 66 |
65 #if defined(OS_WIN) | 67 #if defined(OS_WIN) |
66 #include "base/win/metro.h" | 68 #include "base/win/metro.h" |
(...skipping 287 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
354 content::RecordAction(UserMetricsAction("ShowHelpTabViaWrenchMenu")); | 356 content::RecordAction(UserMetricsAction("ShowHelpTabViaWrenchMenu")); |
355 | 357 |
356 chrome::ExecuteCommand(browser_, command_id); | 358 chrome::ExecuteCommand(browser_, command_id); |
357 } | 359 } |
358 | 360 |
359 bool WrenchMenuModel::IsCommandIdChecked(int command_id) const { | 361 bool WrenchMenuModel::IsCommandIdChecked(int command_id) const { |
360 if (command_id == IDC_SHOW_BOOKMARK_BAR) { | 362 if (command_id == IDC_SHOW_BOOKMARK_BAR) { |
361 return browser_->profile()->GetPrefs()->GetBoolean(prefs::kShowBookmarkBar); | 363 return browser_->profile()->GetPrefs()->GetBoolean(prefs::kShowBookmarkBar); |
362 } else if (command_id == IDC_PROFILING_ENABLED) { | 364 } else if (command_id == IDC_PROFILING_ENABLED) { |
363 return Profiling::BeingProfiled(); | 365 return Profiling::BeingProfiled(); |
| 366 } else if (command_id == IDC_TOGGLE_REQUEST_TABLET_SITE) { |
| 367 WebContents* current_tab = chrome::GetActiveWebContents(browser_); |
| 368 if (!current_tab) |
| 369 return false; |
| 370 content::NavigationEntry* entry = |
| 371 current_tab->GetController().GetActiveEntry(); |
| 372 if (!entry) |
| 373 return false; |
| 374 return entry->GetIsOverridingUserAgent(); |
364 } | 375 } |
365 | 376 |
366 return false; | 377 return false; |
367 } | 378 } |
368 | 379 |
369 bool WrenchMenuModel::IsCommandIdEnabled(int command_id) const { | 380 bool WrenchMenuModel::IsCommandIdEnabled(int command_id) const { |
370 GlobalError* error = GlobalErrorServiceFactory::GetForProfile( | 381 GlobalError* error = GlobalErrorServiceFactory::GetForProfile( |
371 browser_->profile())->GetGlobalErrorByMenuItemCommandID(command_id); | 382 browser_->profile())->GetGlobalErrorByMenuItemCommandID(command_id); |
372 if (error) | 383 if (error) |
373 return true; | 384 return true; |
(...skipping 124 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
498 browser_->profile()->GetOriginalProfile()->IsSyncAccessible()) { | 509 browser_->profile()->GetOriginalProfile()->IsSyncAccessible()) { |
499 const string16 short_product_name = | 510 const string16 short_product_name = |
500 l10n_util::GetStringUTF16(IDS_SHORT_PRODUCT_NAME); | 511 l10n_util::GetStringUTF16(IDS_SHORT_PRODUCT_NAME); |
501 AddItem(IDC_SHOW_SYNC_SETUP, l10n_util::GetStringFUTF16( | 512 AddItem(IDC_SHOW_SYNC_SETUP, l10n_util::GetStringFUTF16( |
502 IDS_SYNC_MENU_PRE_SYNCED_LABEL, short_product_name)); | 513 IDS_SYNC_MENU_PRE_SYNCED_LABEL, short_product_name)); |
503 AddSeparator(); | 514 AddSeparator(); |
504 } | 515 } |
505 | 516 |
506 AddItemWithStringId(IDC_OPTIONS, IDS_SETTINGS); | 517 AddItemWithStringId(IDC_OPTIONS, IDS_SETTINGS); |
507 | 518 |
| 519 #if defined(OS_CHROMEOS) |
| 520 // Note: on Chromebooks with default to "Desktop Site" even for |
| 521 // Chromebooks with a touch screen. |
| 522 // The following toggle lets the user switch to |
| 523 // "Tablet Site". This functionality is under two flags: |
| 524 // - to turn in on only for touch devices (intended use) |
| 525 // - to turn it on regardless of touch device (for testing) |
| 526 bool enable_flag = CommandLine::ForCurrentProcess()->HasSwitch( |
| 527 switches::kEnableRequestTabletSite); |
| 528 bool force_flag = CommandLine::ForCurrentProcess()->HasSwitch( |
| 529 switches::kEnableRequestTabletSiteEvenIfNonTouchDevice); |
| 530 if (force_flag || |
| 531 (enable_flag && ui::TouchFactory::GetInstance()->IsTouchDevicePresent())) |
| 532 AddCheckItemWithStringId(IDC_TOGGLE_REQUEST_TABLET_SITE, |
| 533 IDS_TOGGLE_REQUEST_TABLET_SITE); |
| 534 #endif |
| 535 |
508 if (!is_touch_menu) { | 536 if (!is_touch_menu) { |
509 AddItem(IDC_ABOUT, l10n_util::GetStringUTF16(IDS_ABOUT)); | 537 AddItem(IDC_ABOUT, l10n_util::GetStringUTF16(IDS_ABOUT)); |
510 string16 num_background_pages = base::FormatNumber( | 538 string16 num_background_pages = base::FormatNumber( |
511 TaskManager::GetBackgroundPageCount()); | 539 TaskManager::GetBackgroundPageCount()); |
512 AddItem(IDC_VIEW_BACKGROUND_PAGES, l10n_util::GetStringFUTF16( | 540 AddItem(IDC_VIEW_BACKGROUND_PAGES, l10n_util::GetStringFUTF16( |
513 IDS_VIEW_BACKGROUND_PAGES, num_background_pages)); | 541 IDS_VIEW_BACKGROUND_PAGES, num_background_pages)); |
514 } | 542 } |
515 | 543 |
516 if (browser_defaults::kShowUpgradeMenuItem) | 544 if (browser_defaults::kShowUpgradeMenuItem) |
517 AddItem(IDC_UPGRADE_DIALOG, l10n_util::GetStringUTF16(IDS_UPDATE_NOW)); | 545 AddItem(IDC_UPGRADE_DIALOG, l10n_util::GetStringUTF16(IDS_UPDATE_NOW)); |
(...skipping 121 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
639 zoom_label_ = l10n_util::GetStringFUTF16( | 667 zoom_label_ = l10n_util::GetStringFUTF16( |
640 IDS_ZOOM_PERCENT, base::IntToString16(zoom_percent)); | 668 IDS_ZOOM_PERCENT, base::IntToString16(zoom_percent)); |
641 } | 669 } |
642 | 670 |
643 string16 WrenchMenuModel::GetSyncMenuLabel() const { | 671 string16 WrenchMenuModel::GetSyncMenuLabel() const { |
644 Profile* profile = browser_->profile()->GetOriginalProfile(); | 672 Profile* profile = browser_->profile()->GetOriginalProfile(); |
645 return sync_ui_util::GetSyncMenuLabel( | 673 return sync_ui_util::GetSyncMenuLabel( |
646 ProfileSyncServiceFactory::GetForProfile(profile), | 674 ProfileSyncServiceFactory::GetForProfile(profile), |
647 *SigninManagerFactory::GetForProfile(profile)); | 675 *SigninManagerFactory::GetForProfile(profile)); |
648 } | 676 } |
OLD | NEW |