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

Side by Side Diff: chrome/browser/chromeos/arc/arc_support_host.cc

Issue 2179803002: arc: Use location service consent. (Closed) Base URL: https://chromium.googlesource.com/chromium/src.git@master
Patch Set: discard unwanted change Created 4 years, 5 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 2016 The Chromium Authors. All rights reserved. 1 // Copyright 2016 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/chromeos/arc/arc_support_host.h" 5 #include "chrome/browser/chromeos/arc/arc_support_host.h"
6 6
7 #include <string> 7 #include <string>
8 8
9 #include "ash/common/system/chromeos/devicetype_utils.h" 9 #include "ash/common/system/chromeos/devicetype_utils.h"
10 #include "base/i18n/timezone.h" 10 #include "base/i18n/timezone.h"
(...skipping 13 matching lines...) Expand all
24 #include "components/metrics/metrics_pref_names.h" 24 #include "components/metrics/metrics_pref_names.h"
25 #include "components/prefs/pref_service.h" 25 #include "components/prefs/pref_service.h"
26 #include "components/user_manager/known_user.h" 26 #include "components/user_manager/known_user.h"
27 #include "ui/base/l10n/l10n_util.h" 27 #include "ui/base/l10n/l10n_util.h"
28 #include "ui/base/webui/web_ui_util.h" 28 #include "ui/base/webui/web_ui_util.h"
29 #include "ui/display/screen.h" 29 #include "ui/display/screen.h"
30 30
31 namespace { 31 namespace {
32 const char kAction[] = "action"; 32 const char kAction[] = "action";
33 const char kBackupRestoreEnabled[] = "backupRestoreEnabled"; 33 const char kBackupRestoreEnabled[] = "backupRestoreEnabled";
34 const char kLocationServiceEnabled[] = "locationServiceEnabled";
34 const char kCanEnable[] = "canEnable"; 35 const char kCanEnable[] = "canEnable";
35 const char kCode[] = "code"; 36 const char kCode[] = "code";
36 const char kData[] = "data"; 37 const char kData[] = "data";
37 const char kDeviceId[] = "deviceId"; 38 const char kDeviceId[] = "deviceId";
38 const char kEnabled[] = "enabled"; 39 const char kEnabled[] = "enabled";
39 const char kOn[] = "on"; 40 const char kOn[] = "on";
40 const char kPage[] = "page"; 41 const char kPage[] = "page";
41 const char kStatus[] = "status"; 42 const char kStatus[] = "status";
42 const char kText[] = "text"; 43 const char kText[] = "text";
43 const char kActionInitialize[] = "initialize"; 44 const char kActionInitialize[] = "initialize";
44 const char kActionSetMetricsMode[] = "setMetricsMode"; 45 const char kActionSetMetricsMode[] = "setMetricsMode";
45 const char kActionSetWindowBounds[] = "setWindowBounds"; 46 const char kActionSetWindowBounds[] = "setWindowBounds";
46 const char kActionStartLso[] = "startLso"; 47 const char kActionStartLso[] = "startLso";
47 const char kActionCancelAuthCode[] = "cancelAuthCode"; 48 const char kActionCancelAuthCode[] = "cancelAuthCode";
48 const char kActionSetAuthCode[] = "setAuthCode"; 49 const char kActionSetAuthCode[] = "setAuthCode";
49 const char kActionEnableMetrics[] = "enableMetrics"; 50 const char kActionEnableMetrics[] = "enableMetrics";
50 const char kActionSendFeedback[] = "sendFeedback"; 51 const char kActionSendFeedback[] = "sendFeedback";
51 const char kActionSetBackupRestore[] = "setBackupRestore"; 52 const char kActionSetBackupRestore[] = "setBackupRestore";
53 const char kActionSetLocationService[] = "setLocationService";
52 const char kActionCloseUI[] = "closeUI"; 54 const char kActionCloseUI[] = "closeUI";
53 const char kActionShowPage[] = "showPage"; 55 const char kActionShowPage[] = "showPage";
54 } // namespace 56 } // namespace
55 57
56 // static 58 // static
57 const char ArcSupportHost::kHostName[] = "com.google.arc_support"; 59 const char ArcSupportHost::kHostName[] = "com.google.arc_support";
58 60
59 // static 61 // static
60 const char ArcSupportHost::kHostAppId[] = "cnbgggchhmkkdmeppjobngjoejnihlei"; 62 const char ArcSupportHost::kHostAppId[] = "cnbgggchhmkkdmeppjobngjoejnihlei";
61 63
(...skipping 86 matching lines...) Expand 10 before | Expand all | Expand 10 after
148 loadtime_data->SetString( 150 loadtime_data->SetString(
149 "authorizationFailed", 151 "authorizationFailed",
150 l10n_util::GetStringUTF16(IDS_ARC_OPT_IN_DIALOG_AUTHORIZATION_FAILED)); 152 l10n_util::GetStringUTF16(IDS_ARC_OPT_IN_DIALOG_AUTHORIZATION_FAILED));
151 loadtime_data->SetString( 153 loadtime_data->SetString(
152 "termsOfService", 154 "termsOfService",
153 l10n_util::GetStringUTF16(IDS_ARC_OPT_IN_DIALOG_TERMS_OF_SERVICE)); 155 l10n_util::GetStringUTF16(IDS_ARC_OPT_IN_DIALOG_TERMS_OF_SERVICE));
154 loadtime_data->SetString( 156 loadtime_data->SetString(
155 "textBackupRestore", 157 "textBackupRestore",
156 l10n_util::GetStringUTF16(IDS_ARC_OPT_IN_DIALOG_BACKUP_RESTORE)); 158 l10n_util::GetStringUTF16(IDS_ARC_OPT_IN_DIALOG_BACKUP_RESTORE));
157 loadtime_data->SetString( 159 loadtime_data->SetString(
160 "textLocationService",
161 l10n_util::GetStringUTF16(IDS_ARC_OPT_IN_LOCATION_SETTING));
162 loadtime_data->SetString(
158 "serverError", 163 "serverError",
159 l10n_util::GetStringUTF16(IDS_ARC_SERVER_COMMUNICATION_ERROR)); 164 l10n_util::GetStringUTF16(IDS_ARC_SERVER_COMMUNICATION_ERROR));
160 165
161 const std::string& app_locale = g_browser_process->GetApplicationLocale(); 166 const std::string& app_locale = g_browser_process->GetApplicationLocale();
162 const std::string& country_code = base::CountryCodeForCurrentTimezone(); 167 const std::string& country_code = base::CountryCodeForCurrentTimezone();
163 loadtime_data->SetString("countryCode", country_code); 168 loadtime_data->SetString("countryCode", country_code);
164 169
165 loadtime_data->SetBoolean(kBackupRestoreEnabled, 170 loadtime_data->SetBoolean(kBackupRestoreEnabled,
166 arc_auth_service->profile()->GetPrefs()->GetBoolean( 171 arc_auth_service->profile()->GetPrefs()->GetBoolean(
167 prefs::kArcBackupRestoreEnabled)); 172 prefs::kArcBackupRestoreEnabled));
173 loadtime_data->SetBoolean(kLocationServiceEnabled,
174 arc_auth_service->profile()->GetPrefs()->GetBoolean(
175 prefs::kArcLocationServiceEnabled));
168 176
169 webui::SetLoadTimeDataDefaults(app_locale, loadtime_data.get()); 177 webui::SetLoadTimeDataDefaults(app_locale, loadtime_data.get());
170 DCHECK(arc_auth_service); 178 DCHECK(arc_auth_service);
171 const std::string device_id = user_manager::known_user::GetDeviceId( 179 const std::string device_id = user_manager::known_user::GetDeviceId(
172 multi_user_util::GetAccountIdFromProfile(arc_auth_service->profile())); 180 multi_user_util::GetAccountIdFromProfile(arc_auth_service->profile()));
173 DCHECK(!device_id.empty()); 181 DCHECK(!device_id.empty());
174 182
175 base::DictionaryValue request; 183 base::DictionaryValue request;
176 std::string request_string; 184 std::string request_string;
177 request.SetString(kAction, kActionInitialize); 185 request.SetString(kAction, kActionInitialize);
(...skipping 82 matching lines...) Expand 10 before | Expand all | Expand 10 after
260 InitiateMetricsReportingChange(is_enabled, OnMetricsReportingCallbackType()); 268 InitiateMetricsReportingChange(is_enabled, OnMetricsReportingCallbackType());
261 } 269 }
262 270
263 void ArcSupportHost::EnableBackupRestore(bool is_enabled) { 271 void ArcSupportHost::EnableBackupRestore(bool is_enabled) {
264 arc::ArcAuthService* arc_auth_service = arc::ArcAuthService::Get(); 272 arc::ArcAuthService* arc_auth_service = arc::ArcAuthService::Get();
265 DCHECK(arc_auth_service && arc_auth_service->IsAllowed()); 273 DCHECK(arc_auth_service && arc_auth_service->IsAllowed());
266 PrefService* pref_service = arc_auth_service->profile()->GetPrefs(); 274 PrefService* pref_service = arc_auth_service->profile()->GetPrefs();
267 pref_service->SetBoolean(prefs::kArcBackupRestoreEnabled, is_enabled); 275 pref_service->SetBoolean(prefs::kArcBackupRestoreEnabled, is_enabled);
268 } 276 }
269 277
278 void ArcSupportHost::EnableLocationService(bool is_enabled) {
279 arc::ArcAuthService* arc_auth_service = arc::ArcAuthService::Get();
280 DCHECK(arc_auth_service && arc_auth_service->IsAllowed());
281 PrefService* pref_service = arc_auth_service->profile()->GetPrefs();
282 pref_service->SetBoolean(prefs::kArcLocationServiceEnabled, is_enabled);
283 }
284
270 void ArcSupportHost::OnMessage(const std::string& request_string) { 285 void ArcSupportHost::OnMessage(const std::string& request_string) {
271 std::unique_ptr<base::Value> request_value = 286 std::unique_ptr<base::Value> request_value =
272 base::JSONReader::Read(request_string); 287 base::JSONReader::Read(request_string);
273 base::DictionaryValue* request; 288 base::DictionaryValue* request;
274 if (!request_value || !request_value->GetAsDictionary(&request)) { 289 if (!request_value || !request_value->GetAsDictionary(&request)) {
275 NOTREACHED(); 290 NOTREACHED();
276 return; 291 return;
277 } 292 }
278 293
279 std::string action; 294 std::string action;
(...skipping 25 matching lines...) Expand all
305 EnableMetrics(is_enabled); 320 EnableMetrics(is_enabled);
306 } else if (action == kActionSendFeedback) { 321 } else if (action == kActionSendFeedback) {
307 chrome::OpenFeedbackDialog(nullptr); 322 chrome::OpenFeedbackDialog(nullptr);
308 } else if (action == kActionSetBackupRestore) { 323 } else if (action == kActionSetBackupRestore) {
309 bool is_enabled; 324 bool is_enabled;
310 if (!request->GetBoolean(kEnabled, &is_enabled)) { 325 if (!request->GetBoolean(kEnabled, &is_enabled)) {
311 NOTREACHED(); 326 NOTREACHED();
312 return; 327 return;
313 } 328 }
314 EnableBackupRestore(is_enabled); 329 EnableBackupRestore(is_enabled);
330 } else if (action == kActionSetLocationService) {
331 bool is_enabled;
332 if (!request->GetBoolean(kEnabled, &is_enabled)) {
333 NOTREACHED();
334 return;
335 }
336 EnableLocationService(is_enabled);
315 } else { 337 } else {
316 NOTREACHED(); 338 NOTREACHED();
317 } 339 }
318 } 340 }
319 341
320 scoped_refptr<base::SingleThreadTaskRunner> ArcSupportHost::task_runner() 342 scoped_refptr<base::SingleThreadTaskRunner> ArcSupportHost::task_runner()
321 const { 343 const {
322 return base::ThreadTaskRunnerHandle::Get(); 344 return base::ThreadTaskRunnerHandle::Get();
323 } 345 }
OLDNEW

Powered by Google App Engine
This is Rietveld 408576698