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

Unified Diff: chrome/browser/ui/webui/settings/chromeos/device_stylus_handler.cc

Issue 2644713002: cros: Use runtime stylus detection for ash palette. (Closed)
Patch Set: Fix test Created 3 years, 10 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 side-by-side diff with in-line comments
Download patch
Index: chrome/browser/ui/webui/settings/chromeos/device_stylus_handler.cc
diff --git a/chrome/browser/ui/webui/settings/chromeos/device_stylus_handler.cc b/chrome/browser/ui/webui/settings/chromeos/device_stylus_handler.cc
index f2db088bb2b4365123f4e6b3dafb71a49450ce5c..bbd8910d81fb2423a3b2928169839b741882bc87 100644
--- a/chrome/browser/ui/webui/settings/chromeos/device_stylus_handler.cc
+++ b/chrome/browser/ui/webui/settings/chromeos/device_stylus_handler.cc
@@ -4,7 +4,10 @@
#include "chrome/browser/ui/webui/settings/chromeos/device_stylus_handler.h"
+#include "ash/common/system/chromeos/palette/palette_utils.h"
+#include "base/bind.h"
#include "chrome/browser/profiles/profile.h"
+#include "ui/events/devices/input_device_manager.h"
namespace chromeos {
namespace settings {
@@ -20,9 +23,11 @@ constexpr char kAppPreferredKey[] = "preferred";
StylusHandler::StylusHandler() {
NoteTakingHelper::Get()->AddObserver(this);
+ ui::InputDeviceManager::GetInstance()->AddObserver(this);
}
StylusHandler::~StylusHandler() {
+ ui::InputDeviceManager::GetInstance()->RemoveObserver(this);
NoteTakingHelper::Get()->RemoveObserver(this);
}
@@ -30,6 +35,9 @@ void StylusHandler::RegisterMessages() {
DCHECK(web_ui());
web_ui()->RegisterMessageCallback(
+ "initializeStylusSettings",
+ base::Bind(&StylusHandler::HandleInitialize, base::Unretained(this)));
+ web_ui()->RegisterMessageCallback(
"requestNoteTakingApps",
base::Bind(&StylusHandler::RequestApps, base::Unretained(this)));
web_ui()->RegisterMessageCallback(
@@ -42,6 +50,10 @@ void StylusHandler::OnAvailableNoteTakingAppsUpdated() {
UpdateNoteTakingApps();
}
+void StylusHandler::OnDeviceListsComplete() {
+ SendHasStylus();
+}
+
void StylusHandler::UpdateNoteTakingApps() {
bool waiting_for_android = false;
note_taking_app_ids_.clear();
@@ -91,5 +103,18 @@ void StylusHandler::SetPreferredNoteTakingApp(const base::ListValue* args) {
app_id);
}
+void StylusHandler::HandleInitialize(const base::ListValue* args) {
+ AllowJavascript();
+ if (ui::InputDeviceManager::GetInstance()->AreDeviceListsComplete())
+ SendHasStylus();
+}
+
+void StylusHandler::SendHasStylus() {
+ DCHECK(ui::InputDeviceManager::GetInstance()->AreDeviceListsComplete());
+ CallJavascriptFunction(
+ "cr.webUIListenerCallback", base::StringValue("has-stylus-changed"),
+ base::FundamentalValue(ash::palette_utils::HasStylusInput()));
+}
+
} // namespace settings
} // namespace chromeos
« no previous file with comments | « chrome/browser/ui/webui/settings/chromeos/device_stylus_handler.h ('k') | chrome/browser/ui/webui/settings/md_settings_ui.cc » ('j') | no next file with comments »

Powered by Google App Engine
This is Rietveld 408576698