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

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

Issue 2688513005: cros: Open play store app for md-settings stylus "Find more apps" link (Closed)
Patch Set: 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 unified diff | Download patch
« no previous file with comments | « chrome/browser/ui/webui/settings/chromeos/device_stylus_handler.h ('k') | no next file » | no next file with comments »
Toggle Intra-line Diffs ('i') | Expand Comments ('e') | Collapse Comments ('c') | Show Comments Hide Comments ('s')
OLDNEW
1 // Copyright 2017 The Chromium Authors. All rights reserved. 1 // Copyright 2017 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/webui/settings/chromeos/device_stylus_handler.h" 5 #include "chrome/browser/ui/webui/settings/chromeos/device_stylus_handler.h"
6 6
7 #include "ash/common/system/chromeos/palette/palette_utils.h" 7 #include "ash/common/system/chromeos/palette/palette_utils.h"
8 #include "base/bind.h" 8 #include "base/bind.h"
9 #include "chrome/browser/chromeos/arc/arc_util.h"
9 #include "chrome/browser/profiles/profile.h" 10 #include "chrome/browser/profiles/profile.h"
11 #include "chrome/browser/ui/app_list/arc/arc_app_utils.h"
10 #include "ui/events/devices/input_device_manager.h" 12 #include "ui/events/devices/input_device_manager.h"
11 13
12 namespace chromeos { 14 namespace chromeos {
13 namespace settings { 15 namespace settings {
14 16
15 namespace { 17 namespace {
16 18
17 // Keys in objects passed to onNoteTakingAppsUpdated. 19 // Keys in objects passed to onNoteTakingAppsUpdated.
18 constexpr char kAppNameKey[] = "name"; 20 constexpr char kAppNameKey[] = "name";
19 constexpr char kAppIdKey[] = "value"; 21 constexpr char kAppIdKey[] = "value";
(...skipping 17 matching lines...) Expand all
37 web_ui()->RegisterMessageCallback( 39 web_ui()->RegisterMessageCallback(
38 "initializeStylusSettings", 40 "initializeStylusSettings",
39 base::Bind(&StylusHandler::HandleInitialize, base::Unretained(this))); 41 base::Bind(&StylusHandler::HandleInitialize, base::Unretained(this)));
40 web_ui()->RegisterMessageCallback( 42 web_ui()->RegisterMessageCallback(
41 "requestNoteTakingApps", 43 "requestNoteTakingApps",
42 base::Bind(&StylusHandler::RequestApps, base::Unretained(this))); 44 base::Bind(&StylusHandler::RequestApps, base::Unretained(this)));
43 web_ui()->RegisterMessageCallback( 45 web_ui()->RegisterMessageCallback(
44 "setPreferredNoteTakingApp", 46 "setPreferredNoteTakingApp",
45 base::Bind(&StylusHandler::SetPreferredNoteTakingApp, 47 base::Bind(&StylusHandler::SetPreferredNoteTakingApp,
46 base::Unretained(this))); 48 base::Unretained(this)));
49 web_ui()->RegisterMessageCallback(
50 "showPlayStoreApps",
51 base::Bind(&StylusHandler::ShowPlayStoreApps, base::Unretained(this)));
47 } 52 }
48 53
49 void StylusHandler::OnAvailableNoteTakingAppsUpdated() { 54 void StylusHandler::OnAvailableNoteTakingAppsUpdated() {
50 UpdateNoteTakingApps(); 55 UpdateNoteTakingApps();
51 } 56 }
52 57
53 void StylusHandler::OnDeviceListsComplete() { 58 void StylusHandler::OnDeviceListsComplete() {
54 SendHasStylus(); 59 SendHasStylus();
55 } 60 }
56 61
(...skipping 52 matching lines...) Expand 10 before | Expand all | Expand 10 after
109 } 114 }
110 115
111 void StylusHandler::SendHasStylus() { 116 void StylusHandler::SendHasStylus() {
112 DCHECK(ui::InputDeviceManager::GetInstance()->AreDeviceListsComplete()); 117 DCHECK(ui::InputDeviceManager::GetInstance()->AreDeviceListsComplete());
113 AllowJavascript(); 118 AllowJavascript();
114 CallJavascriptFunction( 119 CallJavascriptFunction(
115 "cr.webUIListenerCallback", base::StringValue("has-stylus-changed"), 120 "cr.webUIListenerCallback", base::StringValue("has-stylus-changed"),
116 base::FundamentalValue(ash::palette_utils::HasStylusInput())); 121 base::FundamentalValue(ash::palette_utils::HasStylusInput()));
117 } 122 }
118 123
124 void StylusHandler::ShowPlayStoreApps(const base::ListValue* args) {
125 std::string apps_url;
126 args->GetString(0, &apps_url);
127 Profile* profile = Profile::FromWebUI(web_ui());
128 if (!arc::IsArcAllowedForProfile(profile)) {
129 VLOG(1) << "ARC is not enabled for this profile";
130 return;
131 }
132
133 arc::LaunchPlayStoreWithUrl(apps_url);
134 }
135
119 } // namespace settings 136 } // namespace settings
120 } // namespace chromeos 137 } // namespace chromeos
OLDNEW
« no previous file with comments | « chrome/browser/ui/webui/settings/chromeos/device_stylus_handler.h ('k') | no next file » | no next file with comments »

Powered by Google App Engine
This is Rietveld 408576698