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

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: set UA override for all entries; 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_) return false;
Rick Byers 2012/08/03 15:53:06 newline after if, here and elsewhere
sschmitz 2012/08/03 18:11:43 Done.
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();
Rick Byers 2012/08/03 15:53:06 Again, I think you want some independent state som
sschmitz 2012/08/03 18:11:43 Similar to browser_commands.cc, the control is dis
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
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 // Note: on Chromebooks with default to "Desktop Site" even for
520 // Chromebooks with a touch screen.
521 // The following toggle lets the user switch to
522 // "Tablet Site". This functionality is under two flags:
523 // - to turn in on only for touch devices (intended use)
524 // - to turn it on regardless of touch device (for testing)
525 bool enableFlag = CommandLine::ForCurrentProcess()->HasSwitch(
526 switches::kEnableRequestTabletSite);
527 bool forceFlag = CommandLine::ForCurrentProcess()->HasSwitch(
528 switches::kEnableRequestTabletSiteEvenIfNonTouchDevice);
529 if (forceFlag ||
530 (enableFlag && ui::TouchFactory::GetInstance()->IsTouchDevicePresent()))
Rick Byers 2012/08/03 15:53:06 IsTouchDevicePresent is itself behind a flag (--en
sschmitz 2012/08/03 18:11:43 Question: Don't we want the added control to turn
531 AddCheckItemWithStringId(IDC_TOGGLE_REQUEST_TABLET_SITE,
532 IDS_TOGGLE_REQUEST_TABLET_SITE);
533 #endif
534
508 if (!is_touch_menu) { 535 if (!is_touch_menu) {
509 AddItem(IDC_ABOUT, l10n_util::GetStringUTF16(IDS_ABOUT)); 536 AddItem(IDC_ABOUT, l10n_util::GetStringUTF16(IDS_ABOUT));
510 string16 num_background_pages = base::FormatNumber( 537 string16 num_background_pages = base::FormatNumber(
511 TaskManager::GetBackgroundPageCount()); 538 TaskManager::GetBackgroundPageCount());
512 AddItem(IDC_VIEW_BACKGROUND_PAGES, l10n_util::GetStringFUTF16( 539 AddItem(IDC_VIEW_BACKGROUND_PAGES, l10n_util::GetStringFUTF16(
513 IDS_VIEW_BACKGROUND_PAGES, num_background_pages)); 540 IDS_VIEW_BACKGROUND_PAGES, num_background_pages));
514 } 541 }
515 542
516 if (browser_defaults::kShowUpgradeMenuItem) 543 if (browser_defaults::kShowUpgradeMenuItem)
517 AddItem(IDC_UPGRADE_DIALOG, l10n_util::GetStringUTF16(IDS_UPDATE_NOW)); 544 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( 666 zoom_label_ = l10n_util::GetStringFUTF16(
640 IDS_ZOOM_PERCENT, base::IntToString16(zoom_percent)); 667 IDS_ZOOM_PERCENT, base::IntToString16(zoom_percent));
641 } 668 }
642 669
643 string16 WrenchMenuModel::GetSyncMenuLabel() const { 670 string16 WrenchMenuModel::GetSyncMenuLabel() const {
644 Profile* profile = browser_->profile()->GetOriginalProfile(); 671 Profile* profile = browser_->profile()->GetOriginalProfile();
645 return sync_ui_util::GetSyncMenuLabel( 672 return sync_ui_util::GetSyncMenuLabel(
646 ProfileSyncServiceFactory::GetForProfile(profile), 673 ProfileSyncServiceFactory::GetForProfile(profile),
647 *SigninManagerFactory::GetForProfile(profile)); 674 *SigninManagerFactory::GetForProfile(profile));
648 } 675 }
OLDNEW

Powered by Google App Engine
This is Rietveld 408576698