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

Side by Side Diff: components/policy/core/common/policy_loader_ios.mm

Issue 1902633006: Convert //components/policy from scoped_ptr to std::unique_ptr (Closed) Base URL: https://chromium.googlesource.com/chromium/src.git@master
Patch Set: Address comments and use namespace alias Created 4 years, 8 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
OLDNEW
1 // Copyright 2014 The Chromium Authors. All rights reserved. 1 // Copyright 2014 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 "components/policy/core/common/policy_loader_ios.h" 5 #include "components/policy/core/common/policy_loader_ios.h"
6 6
7 #import <Foundation/Foundation.h> 7 #import <Foundation/Foundation.h>
8 #include <stddef.h> 8 #include <stddef.h>
9 #import <UIKit/UIKit.h> 9 #import <UIKit/UIKit.h>
10 10
(...skipping 91 matching lines...) Expand 10 before | Expand all | Expand 10 after
102 102
103 void PolicyLoaderIOS::InitOnBackgroundThread() { 103 void PolicyLoaderIOS::InitOnBackgroundThread() {
104 DCHECK(task_runner()->RunsTasksOnCurrentThread()); 104 DCHECK(task_runner()->RunsTasksOnCurrentThread());
105 base::Closure callback = base::Bind(&PolicyLoaderIOS::UserDefaultsChanged, 105 base::Closure callback = base::Bind(&PolicyLoaderIOS::UserDefaultsChanged,
106 weak_factory_.GetWeakPtr()); 106 weak_factory_.GetWeakPtr());
107 notification_observer_.reset( 107 notification_observer_.reset(
108 [[PolicyNotificationObserver alloc] initWithCallback:callback 108 [[PolicyNotificationObserver alloc] initWithCallback:callback
109 taskRunner:task_runner()]); 109 taskRunner:task_runner()]);
110 } 110 }
111 111
112 scoped_ptr<PolicyBundle> PolicyLoaderIOS::Load() { 112 std::unique_ptr<PolicyBundle> PolicyLoaderIOS::Load() {
113 scoped_ptr<PolicyBundle> bundle(new PolicyBundle()); 113 std::unique_ptr<PolicyBundle> bundle(new PolicyBundle());
114 NSDictionary* configuration = [[NSUserDefaults standardUserDefaults] 114 NSDictionary* configuration = [[NSUserDefaults standardUserDefaults]
115 dictionaryForKey:kConfigurationKey]; 115 dictionaryForKey:kConfigurationKey];
116 id chromePolicy = configuration[kChromePolicyKey]; 116 id chromePolicy = configuration[kChromePolicyKey];
117 id encodedChromePolicy = configuration[kEncodedChromePolicyKey]; 117 id encodedChromePolicy = configuration[kEncodedChromePolicyKey];
118 118
119 if (chromePolicy && [chromePolicy isKindOfClass:[NSDictionary class]]) { 119 if (chromePolicy && [chromePolicy isKindOfClass:[NSDictionary class]]) {
120 LoadNSDictionaryToPolicyBundle(chromePolicy, bundle.get()); 120 LoadNSDictionaryToPolicyBundle(chromePolicy, bundle.get());
121 121
122 if (encodedChromePolicy) 122 if (encodedChromePolicy)
123 NSLog(@"Ignoring EncodedChromePolicy because ChromePolicy is present."); 123 NSLog(@"Ignoring EncodedChromePolicy because ChromePolicy is present.");
(...skipping 42 matching lines...) Expand 10 before | Expand all | Expand 10 after
166 // Load() call. 166 // Load() call.
167 last_notification_time_ = base::Time::Now(); 167 last_notification_time_ = base::Time::Now();
168 Reload(false); 168 Reload(false);
169 } 169 }
170 170
171 // static 171 // static
172 void PolicyLoaderIOS::LoadNSDictionaryToPolicyBundle(NSDictionary* dictionary, 172 void PolicyLoaderIOS::LoadNSDictionaryToPolicyBundle(NSDictionary* dictionary,
173 PolicyBundle* bundle) { 173 PolicyBundle* bundle) {
174 // NSDictionary is toll-free bridged to CFDictionaryRef, which is a 174 // NSDictionary is toll-free bridged to CFDictionaryRef, which is a
175 // CFPropertyListRef. 175 // CFPropertyListRef.
176 scoped_ptr<base::Value> value = 176 std::unique_ptr<base::Value> value =
177 PropertyToValue(static_cast<CFPropertyListRef>(dictionary)); 177 PropertyToValue(static_cast<CFPropertyListRef>(dictionary));
178 base::DictionaryValue* dict = NULL; 178 base::DictionaryValue* dict = NULL;
179 if (value && value->GetAsDictionary(&dict)) { 179 if (value && value->GetAsDictionary(&dict)) {
180 PolicyMap& map = bundle->Get(PolicyNamespace(POLICY_DOMAIN_CHROME, "")); 180 PolicyMap& map = bundle->Get(PolicyNamespace(POLICY_DOMAIN_CHROME, ""));
181 map.LoadFrom(dict, POLICY_LEVEL_MANDATORY, POLICY_SCOPE_MACHINE, 181 map.LoadFrom(dict, POLICY_LEVEL_MANDATORY, POLICY_SCOPE_MACHINE,
182 POLICY_SOURCE_PLATFORM); 182 POLICY_SOURCE_PLATFORM);
183 } 183 }
184 } 184 }
185 185
186 } // namespace policy 186 } // namespace policy
OLDNEW
« no previous file with comments | « components/policy/core/common/policy_loader_ios.h ('k') | components/policy/core/common/policy_loader_ios_unittest.mm » ('j') | no next file with comments »

Powered by Google App Engine
This is Rietveld 408576698