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

Side by Side Diff: chrome/browser/chrome_browser_main_mac.mm

Issue 10377173: Do Keychain reauthorization at update time (Closed) Base URL: svn://svn.chromium.org/chrome/trunk/src/
Patch Set: Created 8 years, 7 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 | Annotate | Revision Log
« no previous file with comments | « chrome/app/breakpad_mac.mm ('k') | chrome/browser/mac/keychain_reauthorize.mm » ('j') | no next file with comments »
Toggle Intra-line Diffs ('i') | Expand Comments ('e') | Collapse Comments ('c') | Show Comments Hide Comments ('s')
OLDNEW
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/chrome_browser_main_mac.h" 5 #include "chrome/browser/chrome_browser_main_mac.h"
6 6
7 #import <Cocoa/Cocoa.h> 7 #import <Cocoa/Cocoa.h>
8 8
9 #include "base/command_line.h" 9 #include "base/command_line.h"
10 #include "base/debug/debugger.h" 10 #include "base/debug/debugger.h"
(...skipping 10 matching lines...) Expand all
21 #import "chrome/browser/mac/keystone_glue.h" 21 #import "chrome/browser/mac/keystone_glue.h"
22 #include "chrome/browser/metrics/metrics_service.h" 22 #include "chrome/browser/metrics/metrics_service.h"
23 #include "chrome/common/chrome_paths.h" 23 #include "chrome/common/chrome_paths.h"
24 #include "chrome/common/chrome_switches.h" 24 #include "chrome/common/chrome_switches.h"
25 #include "content/public/common/main_function_params.h" 25 #include "content/public/common/main_function_params.h"
26 #include "content/public/common/result_codes.h" 26 #include "content/public/common/result_codes.h"
27 #include "ui/base/l10n/l10n_util_mac.h" 27 #include "ui/base/l10n/l10n_util_mac.h"
28 #include "ui/base/resource/resource_bundle.h" 28 #include "ui/base/resource/resource_bundle.h"
29 #include "ui/base/resource/resource_handle.h" 29 #include "ui/base/resource/resource_handle.h"
30 30
31 namespace {
32
33 // This preference is used to track whether the KeychainReauthorize operation
34 // has occurred at launch. This operation only makes sense while the
35 // application continues to be signed by the old certificate.
36 NSString* const kKeychainReauthorizeAtLaunchPref =
37 @"KeychainReauthorizeInAppMay2012";
38 const int kKeychainReauthorizeAtLaunchMaxTries = 2;
39
40 // Some users rarely restart Chrome, so they might never get a chance to run
41 // the at-launch KeychainReauthorize. To account for them, there's also an
42 // at-update KeychainReauthorize option, which runs from .keystone_install for
43 // users on a user Keystone ticket. This operation may make sense for a period
44 // of time after the application switches to being signed by the new
45 // certificate, as long as the at-update stub executable is still signed by
46 // the old one.
47 NSString* const kKeychainReauthorizeAtUpdatePref =
48 @"KeychainReauthorizeAtUpdateMay2012";
49 const int kKeychainReauthorizeAtUpdateMaxTries = 3;
50
51 } // namespace
52
31 void RecordBreakpadStatusUMA(MetricsService* metrics) { 53 void RecordBreakpadStatusUMA(MetricsService* metrics) {
32 metrics->RecordBreakpadRegistration(IsCrashReporterEnabled()); 54 metrics->RecordBreakpadRegistration(IsCrashReporterEnabled());
33 metrics->RecordBreakpadHasDebugger(base::debug::BeingDebugged()); 55 metrics->RecordBreakpadHasDebugger(base::debug::BeingDebugged());
34 } 56 }
35 57
36 void RecordBrowserStartupTime() { 58 void RecordBrowserStartupTime() {
37 // Not implemented on Mac for now. 59 // Not implemented on Mac for now.
38 } 60 }
39 61
40 void WarnAboutMinimumSystemRequirements() { 62 void WarnAboutMinimumSystemRequirements() {
41 // Nothing to check for on Mac right now. 63 // Nothing to check for on Mac right now.
42 } 64 }
43 65
44 // From browser_main_win.h, stubs until we figure out the right thing... 66 // From browser_main_win.h, stubs until we figure out the right thing...
45 67
46 int DoUninstallTasks(bool chrome_still_running) { 68 int DoUninstallTasks(bool chrome_still_running) {
47 return content::RESULT_CODE_NORMAL_EXIT; 69 return content::RESULT_CODE_NORMAL_EXIT;
48 } 70 }
49 71
50 // ChromeBrowserMainPartsMac --------------------------------------------------- 72 // ChromeBrowserMainPartsMac ---------------------------------------------------
51 73
52 ChromeBrowserMainPartsMac::ChromeBrowserMainPartsMac( 74 ChromeBrowserMainPartsMac::ChromeBrowserMainPartsMac(
53 const content::MainFunctionParams& parameters) 75 const content::MainFunctionParams& parameters)
54 : ChromeBrowserMainPartsPosix(parameters) { 76 : ChromeBrowserMainPartsPosix(parameters) {
55 } 77 }
56 78
57 void ChromeBrowserMainPartsMac::PreEarlyInitialization() { 79 void ChromeBrowserMainPartsMac::PreEarlyInitialization() {
80 if (parsed_command_line().HasSwitch(switches::kKeychainReauthorize)) {
81 if (base::mac::AmIBundled()) {
82 LOG(FATAL) << "Inappropriate process type for Keychain reauthorization";
83 }
84
85 // Do Keychain reauthorization at the time of update installation. This
86 // gets three chances to run. If the first or second try doesn't complete
87 // successfully (crashes or is interrupted for any reason), there will be
88 // another chance. Once this step completes successfully, it should never
89 // have to run again.
90 //
91 // This is kicked off by a special stub executable during an automatic
92 // update. See chrome/installer/mac/keychain_reauthorize_main.cc. This is
93 // done during update installation in additon to browser app launch to
94 // help reauthorize Keychain items for users who never restart Chrome.
95 chrome::browser::mac::KeychainReauthorizeIfNeeded(
96 kKeychainReauthorizeAtUpdatePref, kKeychainReauthorizeAtUpdateMaxTries);
97
98 exit(0);
99 }
100
58 ChromeBrowserMainPartsPosix::PreEarlyInitialization(); 101 ChromeBrowserMainPartsPosix::PreEarlyInitialization();
59 102
60 if (base::mac::WasLaunchedAsHiddenLoginItem()) { 103 if (base::mac::WasLaunchedAsHiddenLoginItem()) {
61 CommandLine* singleton_command_line = CommandLine::ForCurrentProcess(); 104 CommandLine* singleton_command_line = CommandLine::ForCurrentProcess();
62 singleton_command_line->AppendSwitch(switches::kNoStartupWindow); 105 singleton_command_line->AppendSwitch(switches::kNoStartupWindow);
63 } 106 }
64 } 107 }
65 108
66 void ChromeBrowserMainPartsMac::PreMainMessageLoopStart() { 109 void ChromeBrowserMainPartsMac::PreMainMessageLoopStart() {
67 ChromeBrowserMainPartsPosix::PreMainMessageLoopStart(); 110 ChromeBrowserMainPartsPosix::PreMainMessageLoopStart();
(...skipping 62 matching lines...) Expand 10 before | Expand all | Expand 10 after
130 // change this, you'll probably need to change the Valgrind suppression. 173 // change this, you'll probably need to change the Valgrind suppression.
131 [nib instantiateNibWithOwner:NSApp topLevelObjects:nil]; 174 [nib instantiateNibWithOwner:NSApp topLevelObjects:nil];
132 // Make sure the app controller has been created. 175 // Make sure the app controller has been created.
133 DCHECK([NSApp delegate]); 176 DCHECK([NSApp delegate]);
134 177
135 // Prevent Cocoa from turning command-line arguments into 178 // Prevent Cocoa from turning command-line arguments into
136 // |-application:openFiles:|, since we already handle them directly. 179 // |-application:openFiles:|, since we already handle them directly.
137 [[NSUserDefaults standardUserDefaults] 180 [[NSUserDefaults standardUserDefaults]
138 setObject:@"NO" forKey:@"NSTreatUnknownArgumentsAsOpen"]; 181 setObject:@"NO" forKey:@"NSTreatUnknownArgumentsAsOpen"];
139 182
140 // Do Keychain reauthorization. This gets two chances to run. If the first 183 // Do Keychain reauthorization at browser app launch. This gets two chances
141 // try doesn't complete successfully (crashes or is interrupted for any 184 // to run. If the first try doesn't complete successfully (crashes or is
142 // reason), there will be a second chance. Once this step completes 185 // interrupted for any reason), there will be a second chance. Once this
143 // successfully, it should never have to run again. 186 // step completes successfully, it should never have to run again.
144 NSString* const keychain_reauthorize_pref =
145 @"KeychainReauthorizeInAppMay2012";
146 const int kKeychainReauthorizeMaxTries = 2;
147
148 chrome::browser::mac::KeychainReauthorizeIfNeeded( 187 chrome::browser::mac::KeychainReauthorizeIfNeeded(
149 keychain_reauthorize_pref, kKeychainReauthorizeMaxTries); 188 kKeychainReauthorizeAtLaunchPref, kKeychainReauthorizeAtLaunchMaxTries);
150 } 189 }
151 190
152 void ChromeBrowserMainPartsMac::DidEndMainMessageLoop() { 191 void ChromeBrowserMainPartsMac::DidEndMainMessageLoop() {
153 AppController* appController = [NSApp delegate]; 192 AppController* appController = [NSApp delegate];
154 [appController didEndMainMessageLoop]; 193 [appController didEndMainMessageLoop];
155 } 194 }
OLDNEW
« no previous file with comments | « chrome/app/breakpad_mac.mm ('k') | chrome/browser/mac/keychain_reauthorize.mm » ('j') | no next file with comments »

Powered by Google App Engine
This is Rietveld 408576698