| 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
|
|
|