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

Side by Side Diff: ios/chrome/browser/ui/settings/physical_web_collection_view_controller.mm

Issue 2735463002: Physical Web toggle should render as Off with pref in Default state (Closed)
Patch Set: Created 3 years, 9 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 | « no previous file | 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
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
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
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
OLDNEW
« no previous file with comments | « no previous file | no next file » | no next file with comments »

Powered by Google App Engine
This is Rietveld 408576698