Chromium Code Reviews| 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 if (!browser_) return false; | |
| 368 content::WebContents* current_tab = chrome::GetActiveWebContents(browser_); | |
| 369 if (!current_tab) return false; | |
| 370 content::NavigationEntry *entry = | |
| 371 current_tab->GetController().GetActiveEntry(); | |
| 372 if (!entry) return false; | |
| 373 return entry->GetIsOverridingUserAgent(); | |
| 364 } | 374 } |
| 365 | 375 |
| 366 return false; | 376 return false; |
| 367 } | 377 } |
| 368 | 378 |
| 369 bool WrenchMenuModel::IsCommandIdEnabled(int command_id) const { | 379 bool WrenchMenuModel::IsCommandIdEnabled(int command_id) const { |
| 370 GlobalError* error = GlobalErrorServiceFactory::GetForProfile( | 380 GlobalError* error = GlobalErrorServiceFactory::GetForProfile( |
| 371 browser_->profile())->GetGlobalErrorByMenuItemCommandID(command_id); | 381 browser_->profile())->GetGlobalErrorByMenuItemCommandID(command_id); |
| 372 if (error) | 382 if (error) |
| 373 return true; | 383 return true; |
| (...skipping 124 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... | |
| 498 browser_->profile()->GetOriginalProfile()->IsSyncAccessible()) { | 508 browser_->profile()->GetOriginalProfile()->IsSyncAccessible()) { |
| 499 const string16 short_product_name = | 509 const string16 short_product_name = |
| 500 l10n_util::GetStringUTF16(IDS_SHORT_PRODUCT_NAME); | 510 l10n_util::GetStringUTF16(IDS_SHORT_PRODUCT_NAME); |
| 501 AddItem(IDC_SHOW_SYNC_SETUP, l10n_util::GetStringFUTF16( | 511 AddItem(IDC_SHOW_SYNC_SETUP, l10n_util::GetStringFUTF16( |
| 502 IDS_SYNC_MENU_PRE_SYNCED_LABEL, short_product_name)); | 512 IDS_SYNC_MENU_PRE_SYNCED_LABEL, short_product_name)); |
| 503 AddSeparator(); | 513 AddSeparator(); |
| 504 } | 514 } |
| 505 | 515 |
| 506 AddItemWithStringId(IDC_OPTIONS, IDS_SETTINGS); | 516 AddItemWithStringId(IDC_OPTIONS, IDS_SETTINGS); |
| 507 | 517 |
| 518 #if defined(OS_CHROMEOS) | |
| 519 // | |
|
gone
2012/08/03 00:08:26
Remove this blank line
sschmitz
2012/08/03 15:36:58
Done.
| |
| 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 // | |
| 527 if ((CommandLine::ForCurrentProcess()->HasSwitch( | |
| 528 switches::kEnableRequestTabletSite) && | |
| 529 ui::TouchFactory::GetInstance()->IsTouchDevicePresent()) | |
| 530 || | |
| 531 (CommandLine::ForCurrentProcess()->HasSwitch( | |
| 532 switches::kEnableRequestTabletSiteEvenIfNonTouchDevice))) | |
|
gone
2012/08/03 00:08:26
The indenting is kind of funky here. Consider sep
sschmitz
2012/08/03 15:36:58
Done.
| |
| 533 AddCheckItemWithStringId(IDC_TOGGLE_REQUEST_TABLET_SITE, | |
| 534 IDS_TOGGLE_REQUEST_TABLET_SITE); | |
| 535 #endif | |
| 536 | |
| 508 if (!is_touch_menu) { | 537 if (!is_touch_menu) { |
| 509 AddItem(IDC_ABOUT, l10n_util::GetStringUTF16(IDS_ABOUT)); | 538 AddItem(IDC_ABOUT, l10n_util::GetStringUTF16(IDS_ABOUT)); |
| 510 string16 num_background_pages = base::FormatNumber( | 539 string16 num_background_pages = base::FormatNumber( |
| 511 TaskManager::GetBackgroundPageCount()); | 540 TaskManager::GetBackgroundPageCount()); |
| 512 AddItem(IDC_VIEW_BACKGROUND_PAGES, l10n_util::GetStringFUTF16( | 541 AddItem(IDC_VIEW_BACKGROUND_PAGES, l10n_util::GetStringFUTF16( |
| 513 IDS_VIEW_BACKGROUND_PAGES, num_background_pages)); | 542 IDS_VIEW_BACKGROUND_PAGES, num_background_pages)); |
| 514 } | 543 } |
| 515 | 544 |
| 516 if (browser_defaults::kShowUpgradeMenuItem) | 545 if (browser_defaults::kShowUpgradeMenuItem) |
| 517 AddItem(IDC_UPGRADE_DIALOG, l10n_util::GetStringUTF16(IDS_UPDATE_NOW)); | 546 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( | 668 zoom_label_ = l10n_util::GetStringFUTF16( |
| 640 IDS_ZOOM_PERCENT, base::IntToString16(zoom_percent)); | 669 IDS_ZOOM_PERCENT, base::IntToString16(zoom_percent)); |
| 641 } | 670 } |
| 642 | 671 |
| 643 string16 WrenchMenuModel::GetSyncMenuLabel() const { | 672 string16 WrenchMenuModel::GetSyncMenuLabel() const { |
| 644 Profile* profile = browser_->profile()->GetOriginalProfile(); | 673 Profile* profile = browser_->profile()->GetOriginalProfile(); |
| 645 return sync_ui_util::GetSyncMenuLabel( | 674 return sync_ui_util::GetSyncMenuLabel( |
| 646 ProfileSyncServiceFactory::GetForProfile(profile), | 675 ProfileSyncServiceFactory::GetForProfile(profile), |
| 647 *SigninManagerFactory::GetForProfile(profile)); | 676 *SigninManagerFactory::GetForProfile(profile)); |
| 648 } | 677 } |
| OLD | NEW |