| OLD | NEW |
| 1 // Copyright 2015 The Chromium Authors. All rights reserved. | 1 // Copyright 2015 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 #import "ios/chrome/browser/ui/settings/physical_web_collection_view_controller.
h" | 5 #import "ios/chrome/browser/ui/settings/physical_web_collection_view_controller.
h" |
| 6 | 6 |
| 7 #import <CoreLocation/CoreLocation.h> | 7 #import <CoreLocation/CoreLocation.h> |
| 8 | 8 |
| 9 #import "base/ios/weak_nsobject.h" | 9 #import "base/ios/weak_nsobject.h" |
| 10 #import "base/mac/foundation_util.h" | 10 #import "base/mac/foundation_util.h" |
| (...skipping 67 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 78 } | 78 } |
| 79 | 79 |
| 80 - (instancetype)initWithStyle:(CollectionViewControllerStyle)style { | 80 - (instancetype)initWithStyle:(CollectionViewControllerStyle)style { |
| 81 NOTREACHED(); | 81 NOTREACHED(); |
| 82 return nil; | 82 return nil; |
| 83 } | 83 } |
| 84 | 84 |
| 85 #pragma mark - Preference switch | 85 #pragma mark - Preference switch |
| 86 | 86 |
| 87 + (BOOL)shouldEnableForPreferenceState:(int)preferenceState { | 87 + (BOOL)shouldEnableForPreferenceState:(int)preferenceState { |
| 88 // In the default (onboarding) state, render the preference as On if the | 88 // Render the preference as "on" only if the preference is explicitly enabled. |
| 89 // location app permission is granted. | |
| 90 if (preferenceState == physical_web::kPhysicalWebOnboarding) { | |
| 91 CLAuthorizationStatus authStatus = [CLLocationManager authorizationStatus]; | |
| 92 return (authStatus == kCLAuthorizationStatusAuthorizedWhenInUse || | |
| 93 authStatus == kCLAuthorizationStatusAuthorizedAlways); | |
| 94 } | |
| 95 | |
| 96 return (preferenceState == physical_web::kPhysicalWebOn); | 89 return (preferenceState == physical_web::kPhysicalWebOn); |
| 97 } | 90 } |
| 98 | 91 |
| 99 - (void)physicalWebSwitched:(UISwitch*)switchView { | 92 - (void)physicalWebSwitched:(UISwitch*)switchView { |
| 100 [self updatePhysicalWebEnabled:switchView.isOn]; | 93 [self updatePhysicalWebEnabled:switchView.isOn]; |
| 101 } | 94 } |
| 102 | 95 |
| 103 - (void)updatePhysicalWebEnabled:(BOOL)enabled { | 96 - (void)updatePhysicalWebEnabled:(BOOL)enabled { |
| 104 _physicalWebEnabled.SetValue(enabled ? physical_web::kPhysicalWebOn | 97 _physicalWebEnabled.SetValue(enabled ? physical_web::kPhysicalWebOn |
| 105 : physical_web::kPhysicalWebOff); | 98 : physical_web::kPhysicalWebOff); |
| (...skipping 134 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 240 NSInteger type = [self.collectionViewModel itemTypeForIndexPath:indexPath]; | 233 NSInteger type = [self.collectionViewModel itemTypeForIndexPath:indexPath]; |
| 241 switch (type) { | 234 switch (type) { |
| 242 case ItemTypePhysicalWebSwitch: | 235 case ItemTypePhysicalWebSwitch: |
| 243 return YES; | 236 return YES; |
| 244 default: | 237 default: |
| 245 return NO; | 238 return NO; |
| 246 } | 239 } |
| 247 } | 240 } |
| 248 | 241 |
| 249 @end | 242 @end |
| OLD | NEW |