Index: ios/chrome/browser/physical_web/start_physical_web_discovery.mm |
diff --git a/ios/chrome/browser/physical_web/start_physical_web_discovery.mm b/ios/chrome/browser/physical_web/start_physical_web_discovery.mm |
index f1b492e337f08485a902588ac4f1b08299e5097c..196b78c9538660550500952e82bb51721e830852 100644 |
--- a/ios/chrome/browser/physical_web/start_physical_web_discovery.mm |
+++ b/ios/chrome/browser/physical_web/start_physical_web_discovery.mm |
@@ -11,6 +11,7 @@ |
#import "ios/chrome/browser/experimental_flags.h" |
#import "ios/chrome/browser/geolocation/omnibox_geolocation_config.h" |
#include "ios/chrome/browser/physical_web/physical_web_constants.h" |
+#import "ios/chrome/browser/physical_web/physical_web_initial_state_recorder.h" |
#include "ios/chrome/browser/pref_names.h" |
#include "url/gurl.h" |
@@ -26,17 +27,27 @@ void StartPhysicalWebDiscovery(PrefService* pref_service, bool is_incognito) { |
// send the X-Geo geolocation header in search queries to www.google.com. |
int preference_state = |
pref_service->GetInteger(prefs::kIosPhysicalWebEnabled); |
- if (preference_state == physical_web::kPhysicalWebOnboarding) { |
- // Check that Location Services is enabled. |
- bool location_services_enabled = |
- [CLLocationManager locationServicesEnabled]; |
- // Check that the user has authorized Chrome to use location. |
- CLAuthorizationStatus auth_status = [CLLocationManager authorizationStatus]; |
- bool location_authorized = |
- auth_status == kCLAuthorizationStatusAuthorizedWhenInUse || |
- auth_status == kCLAuthorizationStatusAuthorizedAlways; |
+ // Check that Location Services is enabled. |
+ bool location_services_enabled = [CLLocationManager locationServicesEnabled]; |
+ |
+ // Check that the user has authorized Chrome to use location. |
+ CLAuthorizationStatus auth_status = [CLLocationManager authorizationStatus]; |
+ bool location_authorized = |
+ auth_status == kCLAuthorizationStatusAuthorizedWhenInUse || |
+ auth_status == kCLAuthorizationStatusAuthorizedAlways; |
+ // Record the initial state of Bluetooth, location, and the Physical Web |
+ // preference the first time discovery is started. |
+ static dispatch_once_t once_token; |
+ dispatch_once(&once_token, ^{ |
+ [[[PhysicalWebInitialStateRecorder alloc] |
+ initWithPreferenceState:preference_state |
+ locationServicesEnabled:location_services_enabled |
+ locationAuthorized:location_authorized] autorelease]; |
mattreynolds
2016/10/27 23:56:04
Not sure if this is kosher. The idea is to let the
rohitrao (ping after 24h)
2016/10/31 19:41:08
I think this works, but I don't really like it. T
mattreynolds
2016/11/01 17:17:17
Agreed, I'd rather not leave it like this. The rea
|
+ }); |
+ |
+ if (preference_state == physical_web::kPhysicalWebOnboarding) { |
// Check that the user has not revoked the geolocation permission for |
// Google. |
bool geolocation_eligible = [[OmniboxGeolocationConfig sharedInstance] |