OLD | NEW |
1 // Copyright (c) 2012 The Chromium Authors. All rights reserved. | 1 // Copyright (c) 2012 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 "chrome/browser/mac/keychain_reauthorize.h" | 5 #include "chrome/browser/mac/keychain_reauthorize.h" |
6 | 6 |
7 #import <Foundation/Foundation.h> | 7 #import <Foundation/Foundation.h> |
8 #include <Security/Security.h> | 8 #include <Security/Security.h> |
9 | 9 |
10 #include <algorithm> | 10 #include <algorithm> |
(...skipping 110 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
121 WriteKCItemsAndReauthorizedAccesses(items_and_reauthorized_accesses); | 121 WriteKCItemsAndReauthorizedAccesses(items_and_reauthorized_accesses); |
122 } | 122 } |
123 | 123 |
124 void KeychainReauthorizeIfNeeded(NSString* pref_key, int max_tries) { | 124 void KeychainReauthorizeIfNeeded(NSString* pref_key, int max_tries) { |
125 NSUserDefaults* user_defaults = [NSUserDefaults standardUserDefaults]; | 125 NSUserDefaults* user_defaults = [NSUserDefaults standardUserDefaults]; |
126 int pref_value = [user_defaults integerForKey:pref_key]; | 126 int pref_value = [user_defaults integerForKey:pref_key]; |
127 | 127 |
128 if (pref_value < max_tries) { | 128 if (pref_value < max_tries) { |
129 if (pref_value > 0) { | 129 if (pref_value > 0) { |
130 // Logs the number of previous tries that didn't complete. | 130 // Logs the number of previous tries that didn't complete. |
131 UMA_HISTOGRAM_COUNTS("OSX.KeychainReauthorizeIfNeeded", pref_value); | 131 if (base::mac::AmIBundled()) { |
| 132 UMA_HISTOGRAM_COUNTS("OSX.KeychainReauthorizeIfNeeded", pref_value); |
| 133 } else { |
| 134 UMA_HISTOGRAM_COUNTS("OSX.KeychainReauthorizeIfNeededAtUpdate", |
| 135 pref_value); |
| 136 } |
132 } | 137 } |
133 | 138 |
134 ++pref_value; | 139 ++pref_value; |
135 [user_defaults setInteger:pref_value forKey:pref_key]; | 140 [user_defaults setInteger:pref_value forKey:pref_key]; |
136 [user_defaults synchronize]; | 141 [user_defaults synchronize]; |
137 | 142 |
138 chrome::browser::mac::KeychainReauthorize(); | 143 chrome::browser::mac::KeychainReauthorize(); |
139 | 144 |
140 [user_defaults setInteger:max_tries forKey:pref_key]; | 145 [user_defaults setInteger:max_tries forKey:pref_key]; |
141 NSString* success_pref_key = [pref_key stringByAppendingString:@"Success"]; | 146 NSString* success_pref_key = [pref_key stringByAppendingString:@"Success"]; |
142 [user_defaults setBool:YES forKey:success_pref_key]; | 147 [user_defaults setBool:YES forKey:success_pref_key]; |
143 [user_defaults synchronize]; | 148 [user_defaults synchronize]; |
144 | 149 |
145 // Logs the try number (1, 2) that succeeded. | 150 // Logs the try number (1, 2) that succeeded. |
146 UMA_HISTOGRAM_COUNTS("OSX.KeychainReauthorizeIfNeededSuccess", pref_value); | 151 if (base::mac::AmIBundled()) { |
| 152 UMA_HISTOGRAM_COUNTS("OSX.KeychainReauthorizeIfNeededSuccess", |
| 153 pref_value); |
| 154 } else { |
| 155 UMA_HISTOGRAM_COUNTS("OSX.KeychainReauthorizeIfNeededAtUpdateSuccess", |
| 156 pref_value); |
| 157 } |
147 } | 158 } |
148 } | 159 } |
149 | 160 |
150 namespace { | 161 namespace { |
151 | 162 |
152 std::vector<std::string> RequirementMatches() { | 163 std::vector<std::string> RequirementMatches() { |
153 // See the designated requirement for a signed released build: | 164 // See the designated requirement for a signed released build: |
154 // codesign -d -r- "Google Chrome.app" | 165 // codesign -d -r- "Google Chrome.app" |
155 // | 166 // |
156 // Export the certificates from a signed released build: | 167 // Export the certificates from a signed released build: |
(...skipping 303 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
460 } | 471 } |
461 | 472 |
462 return new_attributes; | 473 return new_attributes; |
463 } | 474 } |
464 | 475 |
465 } // namespace | 476 } // namespace |
466 | 477 |
467 } // namespace mac | 478 } // namespace mac |
468 } // namespace browser | 479 } // namespace browser |
469 } // namespace chrome | 480 } // namespace chrome |
OLD | NEW |