summaryrefslogtreecommitdiff
path: root/chromium/ui/base/pointer
diff options
context:
space:
mode:
Diffstat (limited to 'chromium/ui/base/pointer')
-rw-r--r--chromium/ui/base/pointer/pointer_device.h22
-rw-r--r--chromium/ui/base/pointer/touch_editing_controller.h15
-rw-r--r--chromium/ui/base/pointer/touch_ui_controller.cc48
-rw-r--r--chromium/ui/base/pointer/touch_ui_controller.h14
4 files changed, 67 insertions, 32 deletions
diff --git a/chromium/ui/base/pointer/pointer_device.h b/chromium/ui/base/pointer/pointer_device.h
index 19765542fb3..c50fdde7fe7 100644
--- a/chromium/ui/base/pointer/pointer_device.h
+++ b/chromium/ui/base/pointer/pointer_device.h
@@ -7,8 +7,8 @@
#include <tuple>
+#include "base/component_export.h"
#include "build/build_config.h"
-#include "ui/base/ui_base_export.h"
#if defined(OS_ANDROID)
#include <jni.h>
@@ -22,7 +22,8 @@ enum class TouchScreensAvailability {
DISABLED, // Touch screens are present and disabled.
};
-UI_BASE_EXPORT TouchScreensAvailability GetTouchScreensAvailability();
+COMPONENT_EXPORT(UI_BASE)
+TouchScreensAvailability GetTouchScreensAvailability();
// Returns the maximum number of simultaneous touch contacts supported
// by the device. In the case of devices with multiple digitizers (e.g.
@@ -31,7 +32,7 @@ UI_BASE_EXPORT TouchScreensAvailability GetTouchScreensAvailability();
// For example, suppose a device has 3 touchscreens, which support 2, 5,
// and 10 simultaneous touch contacts, respectively. This returns 10.
// http://www.w3.org/TR/pointerevents/#widl-Navigator-maxTouchPoints
-UI_BASE_EXPORT int MaxTouchPoints();
+COMPONENT_EXPORT(UI_BASE) int MaxTouchPoints();
// Bit field values indicating available pointer types. Identical to
// blink::PointerType enums, enforced by compile-time assertions in
@@ -60,12 +61,15 @@ enum HoverType {
int GetAvailablePointerTypes();
int GetAvailableHoverTypes();
-UI_BASE_EXPORT std::pair<int, int> GetAvailablePointerAndHoverTypes();
-UI_BASE_EXPORT void SetAvailablePointerAndHoverTypesForTesting(
- int available_pointer_types,
- int available_hover_types);
-UI_BASE_EXPORT PointerType GetPrimaryPointerType(int available_pointer_types);
-UI_BASE_EXPORT HoverType GetPrimaryHoverType(int available_hover_types);
+COMPONENT_EXPORT(UI_BASE)
+std::pair<int, int> GetAvailablePointerAndHoverTypes();
+COMPONENT_EXPORT(UI_BASE)
+void SetAvailablePointerAndHoverTypesForTesting(int available_pointer_types,
+ int available_hover_types);
+COMPONENT_EXPORT(UI_BASE)
+PointerType GetPrimaryPointerType(int available_pointer_types);
+COMPONENT_EXPORT(UI_BASE)
+HoverType GetPrimaryHoverType(int available_hover_types);
} // namespace ui
diff --git a/chromium/ui/base/pointer/touch_editing_controller.h b/chromium/ui/base/pointer/touch_editing_controller.h
index e55fb3c9be1..0797a4017af 100644
--- a/chromium/ui/base/pointer/touch_editing_controller.h
+++ b/chromium/ui/base/pointer/touch_editing_controller.h
@@ -5,6 +5,7 @@
#ifndef UI_BASE_POINTER_TOUCH_EDITING_CONTROLLER_H_
#define UI_BASE_POINTER_TOUCH_EDITING_CONTROLLER_H_
+#include "base/component_export.h"
#include "ui/base/models/simple_menu_model.h"
namespace gfx {
@@ -17,7 +18,8 @@ namespace ui {
// An interface implemented by widget that has text that can be selected/edited
// using touch.
-class UI_BASE_EXPORT TouchEditable : public ui::SimpleMenuModel::Delegate {
+class COMPONENT_EXPORT(UI_BASE) TouchEditable
+ : public ui::SimpleMenuModel::Delegate {
public:
// Commands that all TouchEditables support:
enum MenuCommands {
@@ -79,7 +81,7 @@ class UI_BASE_EXPORT TouchEditable : public ui::SimpleMenuModel::Delegate {
// This defines the callback interface for other code to be notified of changes
// in the state of a TouchEditable.
-class UI_BASE_EXPORT TouchEditingControllerDeprecated {
+class COMPONENT_EXPORT(UI_BASE) TouchEditingControllerDeprecated {
public:
virtual ~TouchEditingControllerDeprecated() {}
@@ -89,16 +91,9 @@ class UI_BASE_EXPORT TouchEditingControllerDeprecated {
// Notifies the controller that the selection has changed.
virtual void SelectionChanged() = 0;
-
- // Returns true if the user is currently dragging one of the handles.
- virtual bool IsHandleDragInProgress() = 0;
-
- // Hides visible handles. According to the value of |quick|, handles might
- // fade out quickly or slowly.
- virtual void HideHandles(bool quick) = 0;
};
-class UI_BASE_EXPORT TouchEditingControllerFactory {
+class COMPONENT_EXPORT(UI_BASE) TouchEditingControllerFactory {
public:
virtual ~TouchEditingControllerFactory() {}
diff --git a/chromium/ui/base/pointer/touch_ui_controller.cc b/chromium/ui/base/pointer/touch_ui_controller.cc
index f594a6db23c..326da1df5d9 100644
--- a/chromium/ui/base/pointer/touch_ui_controller.cc
+++ b/chromium/ui/base/pointer/touch_ui_controller.cc
@@ -4,11 +4,13 @@
#include "ui/base/pointer/touch_ui_controller.h"
+#include <memory>
#include <string>
#include "base/bind.h"
#include "base/command_line.h"
#include "base/message_loop/message_loop_current.h"
+#include "base/metrics/user_metrics.h"
#include "base/no_destructor.h"
#include "base/trace_event/trace_event.h"
#include "ui/base/ui_base_switches.h"
@@ -22,17 +24,27 @@
namespace ui {
-#if defined(OS_WIN)
namespace {
+#if defined(OS_WIN)
+
bool IsTabletMode() {
return base::win::IsWindows10TabletMode(
gfx::SingletonHwnd::GetInstance()->hwnd());
}
-} // namespace
#endif // defined(OS_WIN)
+void RecordEnteredTouchMode() {
+ base::RecordAction(base::UserMetricsAction("TouchMode.EnteredTouchMode"));
+}
+
+void RecordEnteredNonTouchMode() {
+ base::RecordAction(base::UserMetricsAction("TouchMode.EnteredNonTouchMode"));
+}
+
+} // namespace
+
TouchUiController::TouchUiScoperForTesting::TouchUiScoperForTesting(
bool enabled,
TouchUiController* controller)
@@ -44,6 +56,11 @@ TouchUiController::TouchUiScoperForTesting::~TouchUiScoperForTesting() {
controller_->SetTouchUiState(old_state_);
}
+void TouchUiController::TouchUiScoperForTesting::UpdateState(bool enabled) {
+ controller_->SetTouchUiState(enabled ? TouchUiState::kEnabled
+ : TouchUiState::kDisabled);
+}
+
// static
TouchUiController* TouchUiController::Get() {
static base::NoDestructor<TouchUiController> instance([] {
@@ -72,6 +89,11 @@ TouchUiController::TouchUiController(TouchUiState touch_ui_state)
tablet_mode_ = IsTabletMode();
}
#endif
+
+ if (touch_ui())
+ RecordEnteredTouchMode();
+ else
+ RecordEnteredNonTouchMode();
}
TouchUiController::~TouchUiController() = default;
@@ -79,10 +101,8 @@ TouchUiController::~TouchUiController() = default;
void TouchUiController::OnTabletModeToggled(bool enabled) {
const bool was_touch_ui = touch_ui();
tablet_mode_ = enabled;
- if (touch_ui() != was_touch_ui) {
- TRACE_EVENT0("ui", "TouchUiController.NotifyListeners");
- callback_list_.Notify();
- }
+ if (touch_ui() != was_touch_ui)
+ TouchUiChanged();
}
std::unique_ptr<TouchUiController::Subscription>
@@ -94,11 +114,19 @@ TouchUiController::TouchUiState TouchUiController::SetTouchUiState(
TouchUiState touch_ui_state) {
const bool was_touch_ui = touch_ui();
const TouchUiState old_state = std::exchange(touch_ui_state_, touch_ui_state);
- if (touch_ui() != was_touch_ui) {
- TRACE_EVENT0("ui", "TouchUiController.NotifyListeners");
- callback_list_.Notify();
- }
+ if (touch_ui() != was_touch_ui)
+ TouchUiChanged();
return old_state;
}
+void TouchUiController::TouchUiChanged() {
+ if (touch_ui())
+ RecordEnteredTouchMode();
+ else
+ RecordEnteredNonTouchMode();
+
+ TRACE_EVENT0("ui", "TouchUiController.NotifyListeners");
+ callback_list_.Notify();
+}
+
} // namespace ui
diff --git a/chromium/ui/base/pointer/touch_ui_controller.h b/chromium/ui/base/pointer/touch_ui_controller.h
index cecd4ddcc69..0240f4eaef3 100644
--- a/chromium/ui/base/pointer/touch_ui_controller.h
+++ b/chromium/ui/base/pointer/touch_ui_controller.h
@@ -5,11 +5,12 @@
#ifndef UI_BASE_POINTER_TOUCH_UI_CONTROLLER_H_
#define UI_BASE_POINTER_TOUCH_UI_CONTROLLER_H_
+#include <memory>
#include <string>
#include "base/callback_list.h"
+#include "base/component_export.h"
#include "build/build_config.h"
-#include "ui/base/ui_base_export.h"
#if defined(OS_WIN)
namespace gfx {
@@ -20,7 +21,7 @@ class SingletonHwndObserver;
namespace ui {
// Central controller to handle touch UI modes.
-class UI_BASE_EXPORT TouchUiController {
+class COMPONENT_EXPORT(UI_BASE) TouchUiController {
public:
using CallbackList = base::CallbackList<void()>;
using Subscription = CallbackList::Subscription;
@@ -31,7 +32,7 @@ class UI_BASE_EXPORT TouchUiController {
kEnabled,
};
- class UI_BASE_EXPORT TouchUiScoperForTesting {
+ class COMPONENT_EXPORT(UI_BASE) TouchUiScoperForTesting {
public:
explicit TouchUiScoperForTesting(bool enabled,
TouchUiController* controller = Get());
@@ -39,6 +40,11 @@ class UI_BASE_EXPORT TouchUiController {
TouchUiScoperForTesting& operator=(const TouchUiScoperForTesting&) = delete;
~TouchUiScoperForTesting();
+ // Update the current touch mode state but still roll back to the
+ // original state at destruction. Allows a test to change the mode
+ // multiple times without creating multiple instances.
+ void UpdateState(bool enabled);
+
private:
TouchUiController* const controller_;
const TouchUiState old_state_;
@@ -64,6 +70,8 @@ class UI_BASE_EXPORT TouchUiController {
private:
TouchUiState SetTouchUiState(TouchUiState touch_ui_state);
+ void TouchUiChanged();
+
bool tablet_mode_ = false;
TouchUiState touch_ui_state_;