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

Side by Side Diff: content/browser/web_contents/web_contents_impl.cc

Issue 19805005: Refactored touch-events flag test, correcting "enabled" logic. (Closed) Base URL: http://git.chromium.org/chromium/src.git@master
Patch Set: Renamed IsTouchEnabled to AreTouchEventsEnabled. Created 7 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 "content/browser/web_contents/web_contents_impl.h" 5 #include "content/browser/web_contents/web_contents_impl.h"
6 6
7 #include <utility> 7 #include <utility>
8 8
9 #include "base/command_line.h" 9 #include "base/command_line.h"
10 #include "base/debug/trace_event.h" 10 #include "base/debug/trace_event.h"
11 #include "base/lazy_instance.h" 11 #include "base/lazy_instance.h"
12 #include "base/logging.h"
12 #include "base/metrics/histogram.h" 13 #include "base/metrics/histogram.h"
13 #include "base/metrics/stats_counters.h" 14 #include "base/metrics/stats_counters.h"
14 #include "base/strings/string16.h" 15 #include "base/strings/string16.h"
15 #include "base/strings/string_number_conversions.h" 16 #include "base/strings/string_number_conversions.h"
16 #include "base/strings/string_util.h" 17 #include "base/strings/string_util.h"
17 #include "base/strings/utf_string_conversions.h" 18 #include "base/strings/utf_string_conversions.h"
18 #include "base/sys_info.h" 19 #include "base/sys_info.h"
19 #include "base/time/time.h" 20 #include "base/time/time.h"
20 #include "cc/base/switches.h" 21 #include "cc/base/switches.h"
21 #include "content/browser/browser_plugin/browser_plugin_embedder.h" 22 #include "content/browser/browser_plugin/browser_plugin_embedder.h"
(...skipping 52 matching lines...) Expand 10 before | Expand all | Expand 10 after
74 #include "content/public/common/content_constants.h" 75 #include "content/public/common/content_constants.h"
75 #include "content/public/common/content_switches.h" 76 #include "content/public/common/content_switches.h"
76 #include "content/public/common/url_constants.h" 77 #include "content/public/common/url_constants.h"
77 #include "net/base/mime_util.h" 78 #include "net/base/mime_util.h"
78 #include "net/base/net_util.h" 79 #include "net/base/net_util.h"
79 #include "net/base/network_change_notifier.h" 80 #include "net/base/network_change_notifier.h"
80 #include "net/url_request/url_request_context_getter.h" 81 #include "net/url_request/url_request_context_getter.h"
81 #include "third_party/WebKit/public/web/WebView.h" 82 #include "third_party/WebKit/public/web/WebView.h"
82 #include "ui/base/layout.h" 83 #include "ui/base/layout.h"
83 #include "ui/base/touch/touch_device.h" 84 #include "ui/base/touch/touch_device.h"
85 #include "ui/base/touch/touch_enabled.h"
84 #include "ui/base/ui_base_switches.h" 86 #include "ui/base/ui_base_switches.h"
85 #include "ui/gfx/display.h" 87 #include "ui/gfx/display.h"
86 #include "ui/gfx/screen.h" 88 #include "ui/gfx/screen.h"
87 #include "ui/gl/gl_switches.h" 89 #include "ui/gl/gl_switches.h"
88 #include "webkit/common/webpreferences.h" 90 #include "webkit/common/webpreferences.h"
89 91
90 #if defined(OS_ANDROID) 92 #if defined(OS_ANDROID)
91 #include "content/browser/android/date_time_chooser_android.h" 93 #include "content/browser/android/date_time_chooser_android.h"
92 #include "content/public/browser/android/content_view_core.h" 94 #include "content/public/browser/android/content_view_core.h"
93 #endif 95 #endif
(...skipping 458 matching lines...) Expand 10 before | Expand all | Expand 10 after
552 if (command_line.HasSwitch(cc::switches::kEnablePinchVirtualViewport)) { 554 if (command_line.HasSwitch(cc::switches::kEnablePinchVirtualViewport)) {
553 prefs.pinch_virtual_viewport_enabled = true; 555 prefs.pinch_virtual_viewport_enabled = true;
554 prefs.pinch_overlay_scrollbar_thickness = 10; 556 prefs.pinch_overlay_scrollbar_thickness = 10;
555 } 557 }
556 558
557 #if defined(OS_ANDROID) 559 #if defined(OS_ANDROID)
558 prefs.user_gesture_required_for_media_playback = !command_line.HasSwitch( 560 prefs.user_gesture_required_for_media_playback = !command_line.HasSwitch(
559 switches::kDisableGestureRequirementForMediaPlayback); 561 switches::kDisableGestureRequirementForMediaPlayback);
560 #endif 562 #endif
561 563
562 bool touch_device_present = false; 564 prefs.touch_enabled = ui::AreTouchEventsEnabled();
563 touch_device_present = ui::IsTouchDevicePresent(); 565 prefs.device_supports_touch = prefs.touch_enabled &&
564 const std::string touch_enabled_switch = 566 ui::IsTouchDevicePresent();
565 command_line.HasSwitch(switches::kTouchEvents) ?
566 command_line.GetSwitchValueASCII(switches::kTouchEvents) :
567 switches::kTouchEventsAuto;
568
569 if (touch_enabled_switch.empty() ||
570 touch_enabled_switch == switches::kTouchEventsEnabled) {
571 prefs.touch_enabled = true;
572 } else if (touch_enabled_switch == switches::kTouchEventsAuto) {
573 prefs.touch_enabled = touch_device_present;
574 } else if (touch_enabled_switch != switches::kTouchEventsDisabled) {
575 LOG(ERROR) << "Invalid --touch-events option: " << touch_enabled_switch;
576 }
577
578 prefs.device_supports_touch = prefs.touch_enabled && touch_device_present;
579 #if defined(OS_ANDROID) 567 #if defined(OS_ANDROID)
580 prefs.device_supports_mouse = false; 568 prefs.device_supports_mouse = false;
581 #endif 569 #endif
582 570
583 prefs.touch_adjustment_enabled = 571 prefs.touch_adjustment_enabled =
584 !command_line.HasSwitch(switches::kDisableTouchAdjustment); 572 !command_line.HasSwitch(switches::kDisableTouchAdjustment);
585 573
586 #if defined(OS_MACOSX) || defined(OS_CHROMEOS) 574 #if defined(OS_MACOSX) || defined(OS_CHROMEOS)
587 bool default_enable_scroll_animator = true; 575 bool default_enable_scroll_animator = true;
588 #else 576 #else
(...skipping 3139 matching lines...) Expand 10 before | Expand all | Expand 10 after
3728 } 3716 }
3729 3717
3730 void WebContentsImpl::ClearAllPowerSaveBlockers() { 3718 void WebContentsImpl::ClearAllPowerSaveBlockers() {
3731 for (PowerSaveBlockerMap::iterator i(power_save_blockers_.begin()); 3719 for (PowerSaveBlockerMap::iterator i(power_save_blockers_.begin());
3732 i != power_save_blockers_.end(); ++i) 3720 i != power_save_blockers_.end(); ++i)
3733 STLDeleteValues(&power_save_blockers_[i->first]); 3721 STLDeleteValues(&power_save_blockers_[i->first]);
3734 power_save_blockers_.clear(); 3722 power_save_blockers_.clear();
3735 } 3723 }
3736 3724
3737 } // namespace content 3725 } // namespace content
OLDNEW
« no previous file with comments | « content/browser/renderer_host/render_widget_host_view_win.cc ('k') | ui/base/touch/touch_enabled.h » ('j') | no next file with comments »

Powered by Google App Engine
This is Rietveld 408576698