OLD | NEW |
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 "ios/chrome/browser/physical_web/start_physical_web_discovery.h" | 5 #include "ios/chrome/browser/physical_web/start_physical_web_discovery.h" |
6 | 6 |
7 #import <CoreLocation/CoreLocation.h> | 7 #import <CoreLocation/CoreLocation.h> |
8 | 8 |
9 #include "components/physical_web/data_source/physical_web_data_source.h" | 9 #include "components/physical_web/data_source/physical_web_data_source.h" |
10 #include "components/search_engines/search_terms_data.h" | 10 #include "components/search_engines/search_terms_data.h" |
11 #include "components/search_engines/template_url_service.h" | 11 #include "components/search_engines/template_url_service.h" |
12 #include "ios/chrome/browser/application_context.h" | 12 #include "ios/chrome/browser/application_context.h" |
13 #include "ios/chrome/browser/browser_state/chrome_browser_state.h" | 13 #include "ios/chrome/browser/browser_state/chrome_browser_state.h" |
14 #import "ios/chrome/browser/experimental_flags.h" | 14 #import "ios/chrome/browser/experimental_flags.h" |
15 #import "ios/chrome/browser/geolocation/omnibox_geolocation_config.h" | 15 #import "ios/chrome/browser/geolocation/omnibox_geolocation_config.h" |
16 #include "ios/chrome/browser/physical_web/physical_web_constants.h" | 16 #include "ios/chrome/browser/physical_web/physical_web_constants.h" |
17 #include "ios/chrome/browser/pref_names.h" | 17 #include "ios/chrome/browser/pref_names.h" |
18 #include "ios/chrome/browser/search_engines/template_url_service_factory.h" | 18 #include "ios/chrome/browser/search_engines/template_url_service_factory.h" |
19 #include "url/gurl.h" | 19 #include "url/gurl.h" |
20 | 20 |
| 21 #if !defined(__has_feature) || !__has_feature(objc_arc) |
| 22 #error "This file requires ARC support." |
| 23 #endif |
| 24 |
21 void StartPhysicalWebDiscovery(PrefService* pref_service, | 25 void StartPhysicalWebDiscovery(PrefService* pref_service, |
22 ios::ChromeBrowserState* browser_state) { | 26 ios::ChromeBrowserState* browser_state) { |
23 // Do not scan if the Physical Web feature is disabled by a command line flag | 27 // Do not scan if the Physical Web feature is disabled by a command line flag |
24 // or Chrome Variations experiment. | 28 // or Chrome Variations experiment. |
25 if (!experimental_flags::IsPhysicalWebEnabled()) { | 29 if (!experimental_flags::IsPhysicalWebEnabled()) { |
26 return; | 30 return; |
27 } | 31 } |
28 | 32 |
29 // If the preference is in the default state, check if conditions allow us to | 33 // If the preference is in the default state, check if conditions allow us to |
30 // auto-enable it. The preference can be auto-enabled if the omnibox would | 34 // auto-enable it. The preference can be auto-enabled if the omnibox would |
(...skipping 37 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
68 } | 72 } |
69 | 73 |
70 // Scan only if the feature is enabled. | 74 // Scan only if the feature is enabled. |
71 if (preference_state == physical_web::kPhysicalWebOn) { | 75 if (preference_state == physical_web::kPhysicalWebOn) { |
72 GetApplicationContext()->GetPhysicalWebDataSource()->StartDiscovery(true); | 76 GetApplicationContext()->GetPhysicalWebDataSource()->StartDiscovery(true); |
73 } else { | 77 } else { |
74 GetApplicationContext()->GetPhysicalWebDataSource()->StopDiscovery(); | 78 GetApplicationContext()->GetPhysicalWebDataSource()->StopDiscovery(); |
75 } | 79 } |
76 } | 80 } |
77 | 81 |
OLD | NEW |