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

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

Issue 10827146: crbug.com/127841 - Request Tablet Site on CB with touch screen. (Closed) Base URL: http://git.chromium.org/chromium/src.git@master
Patch Set: Disable RTS control when no tab or no nav. entry; impl. reviewer comments Created 8 years, 4 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
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 24 matching lines...) Expand all
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
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_)
368 return false; // The control is disabled (dim) in this case
369 content::WebContents* current_tab = chrome::GetActiveWebContents(browser_);
370 if (!current_tab)
371 return false; // The control is disabled (dim) in this case
372 content::NavigationEntry *entry =
373 current_tab->GetController().GetActiveEntry();
374 if (!entry)
375 return false; // The control is disabled (dim) in this case
gone 2012/08/03 20:13:26 Make a catch-all comment stating this instead of t
sschmitz 2012/08/03 21:20:51 Done.
376 return entry->GetIsOverridingUserAgent();
364 } 377 }
365 378
366 return false; 379 return false;
367 } 380 }
368 381
369 bool WrenchMenuModel::IsCommandIdEnabled(int command_id) const { 382 bool WrenchMenuModel::IsCommandIdEnabled(int command_id) const {
370 GlobalError* error = GlobalErrorServiceFactory::GetForProfile( 383 GlobalError* error = GlobalErrorServiceFactory::GetForProfile(
371 browser_->profile())->GetGlobalErrorByMenuItemCommandID(command_id); 384 browser_->profile())->GetGlobalErrorByMenuItemCommandID(command_id);
372 if (error) 385 if (error)
373 return true; 386 return true;
374 387
388 if (command_id == IDC_TOGGLE_REQUEST_TABLET_SITE) {
389 if (!browser_)
390 return false;
391 content::WebContents* current_tab = chrome::GetActiveWebContents(browser_);
392 if (!current_tab)
393 return false;
394 content::NavigationEntry *entry =
395 current_tab->GetController().GetActiveEntry();
396 if (!entry)
397 return false;
gone 2012/08/03 20:13:26 Re-factor this check out into its own function sin
sschmitz 2012/08/03 21:20:51 Done.
398 // Now fall through to normal behavior
399 }
400
375 return chrome::IsCommandEnabled(browser_, command_id); 401 return chrome::IsCommandEnabled(browser_, command_id);
376 } 402 }
377 403
378 bool WrenchMenuModel::IsCommandIdVisible(int command_id) const { 404 bool WrenchMenuModel::IsCommandIdVisible(int command_id) const {
379 #if defined(OS_WIN) 405 #if defined(OS_WIN)
380 if (command_id == IDC_VIEW_INCOMPATIBILITIES) { 406 if (command_id == IDC_VIEW_INCOMPATIBILITIES) {
381 EnumerateModulesModel* loaded_modules = 407 EnumerateModulesModel* loaded_modules =
382 EnumerateModulesModel::GetInstance(); 408 EnumerateModulesModel::GetInstance();
383 if (loaded_modules->confirmed_bad_modules_detected() <= 0) 409 if (loaded_modules->confirmed_bad_modules_detected() <= 0)
384 return false; 410 return false;
(...skipping 113 matching lines...) Expand 10 before | Expand all | Expand 10 after
498 browser_->profile()->GetOriginalProfile()->IsSyncAccessible()) { 524 browser_->profile()->GetOriginalProfile()->IsSyncAccessible()) {
499 const string16 short_product_name = 525 const string16 short_product_name =
500 l10n_util::GetStringUTF16(IDS_SHORT_PRODUCT_NAME); 526 l10n_util::GetStringUTF16(IDS_SHORT_PRODUCT_NAME);
501 AddItem(IDC_SHOW_SYNC_SETUP, l10n_util::GetStringFUTF16( 527 AddItem(IDC_SHOW_SYNC_SETUP, l10n_util::GetStringFUTF16(
502 IDS_SYNC_MENU_PRE_SYNCED_LABEL, short_product_name)); 528 IDS_SYNC_MENU_PRE_SYNCED_LABEL, short_product_name));
503 AddSeparator(); 529 AddSeparator();
504 } 530 }
505 531
506 AddItemWithStringId(IDC_OPTIONS, IDS_SETTINGS); 532 AddItemWithStringId(IDC_OPTIONS, IDS_SETTINGS);
507 533
534 #if defined(OS_CHROMEOS)
535 // Note: on Chromebooks with default to "Desktop Site" even for
536 // Chromebooks with a touch screen.
537 // The following toggle lets the user switch to
538 // "Tablet Site". This functionality is under two flags:
539 // - to turn in on only for touch devices (intended use)
540 // - to turn it on regardless of touch device (for testing)
541 bool enableFlag = CommandLine::ForCurrentProcess()->HasSwitch(
gone 2012/08/03 20:13:26 Style: don't use camel case
sschmitz 2012/08/03 21:20:51 Done.
542 switches::kEnableRequestTabletSite);
543 bool forceFlag = CommandLine::ForCurrentProcess()->HasSwitch(
544 switches::kEnableRequestTabletSiteEvenIfNonTouchDevice);
545 if (forceFlag ||
546 (enableFlag && ui::TouchFactory::GetInstance()->IsTouchDevicePresent()))
547 AddCheckItemWithStringId(IDC_TOGGLE_REQUEST_TABLET_SITE,
548 IDS_TOGGLE_REQUEST_TABLET_SITE);
549 #endif
550
508 if (!is_touch_menu) { 551 if (!is_touch_menu) {
509 AddItem(IDC_ABOUT, l10n_util::GetStringUTF16(IDS_ABOUT)); 552 AddItem(IDC_ABOUT, l10n_util::GetStringUTF16(IDS_ABOUT));
510 string16 num_background_pages = base::FormatNumber( 553 string16 num_background_pages = base::FormatNumber(
511 TaskManager::GetBackgroundPageCount()); 554 TaskManager::GetBackgroundPageCount());
512 AddItem(IDC_VIEW_BACKGROUND_PAGES, l10n_util::GetStringFUTF16( 555 AddItem(IDC_VIEW_BACKGROUND_PAGES, l10n_util::GetStringFUTF16(
513 IDS_VIEW_BACKGROUND_PAGES, num_background_pages)); 556 IDS_VIEW_BACKGROUND_PAGES, num_background_pages));
514 } 557 }
515 558
516 if (browser_defaults::kShowUpgradeMenuItem) 559 if (browser_defaults::kShowUpgradeMenuItem)
517 AddItem(IDC_UPGRADE_DIALOG, l10n_util::GetStringUTF16(IDS_UPDATE_NOW)); 560 AddItem(IDC_UPGRADE_DIALOG, l10n_util::GetStringUTF16(IDS_UPDATE_NOW));
(...skipping 121 matching lines...) Expand 10 before | Expand all | Expand 10 after
639 zoom_label_ = l10n_util::GetStringFUTF16( 682 zoom_label_ = l10n_util::GetStringFUTF16(
640 IDS_ZOOM_PERCENT, base::IntToString16(zoom_percent)); 683 IDS_ZOOM_PERCENT, base::IntToString16(zoom_percent));
641 } 684 }
642 685
643 string16 WrenchMenuModel::GetSyncMenuLabel() const { 686 string16 WrenchMenuModel::GetSyncMenuLabel() const {
644 Profile* profile = browser_->profile()->GetOriginalProfile(); 687 Profile* profile = browser_->profile()->GetOriginalProfile();
645 return sync_ui_util::GetSyncMenuLabel( 688 return sync_ui_util::GetSyncMenuLabel(
646 ProfileSyncServiceFactory::GetForProfile(profile), 689 ProfileSyncServiceFactory::GetForProfile(profile),
647 *SigninManagerFactory::GetForProfile(profile)); 690 *SigninManagerFactory::GetForProfile(profile));
648 } 691 }
OLDNEW

Powered by Google App Engine
This is Rietveld 408576698