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

Side by Side Diff: ios/chrome/browser/physical_web/start_physical_web_discovery.mm

Issue 2317183002: Start the Physical Web scanner on Chrome start (Closed)
Patch Set: swap conditional Created 4 years, 3 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 | « ios/chrome/browser/physical_web/start_physical_web_discovery.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
(Empty)
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
3 // found in the LICENSE file.
4
5 #include "ios/chrome/browser/physical_web/start_physical_web_discovery.h"
6
7 #import <CoreLocation/CoreLocation.h>
8
9 #include "components/physical_web/data_source/physical_web_data_source.h"
10 #include "ios/chrome/browser/application_context.h"
11 #include "ios/chrome/browser/experimental_flags.h"
12 #include "ios/chrome/browser/physical_web/physical_web_constants.h"
13 #include "ios/chrome/browser/pref_names.h"
14
15 void StartPhysicalWebDiscovery(PrefService* pref_service) {
16 // Do not scan if the Physical Web feature is disabled by a command line flag
17 // or Chrome Variations experiment.
18 if (!experimental_flags::IsPhysicalWebEnabled()) {
19 return;
20 }
21
22 // Do not scan for nearby devices if the user has explicitly disabled the
23 // Physical Web feature.
24 int preference_state =
25 pref_service->GetInteger(prefs::kIosPhysicalWebEnabled);
26 if (preference_state == physical_web::kPhysicalWebOff) {
27 return;
28 }
29
30 // In the default (onboarding) state, enable Physical Web scanning if the user
31 // has granted the Location app permission.
32 if (preference_state == physical_web::kPhysicalWebOnboarding) {
33 CLAuthorizationStatus auth_status = [CLLocationManager authorizationStatus];
34 if (auth_status != kCLAuthorizationStatusAuthorizedWhenInUse &&
35 auth_status != kCLAuthorizationStatusAuthorizedAlways) {
36 return;
37 }
38 pref_service->SetInteger(prefs::kIosPhysicalWebEnabled, true);
39 }
40
41 GetApplicationContext()->GetPhysicalWebDataSource()->StartDiscovery(true);
42 }
OLDNEW
« no previous file with comments | « ios/chrome/browser/physical_web/start_physical_web_discovery.h ('k') | no next file » | no next file with comments »

Powered by Google App Engine
This is Rietveld 408576698