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/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 37 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... | |
48 } | 48 } |
49 | 49 |
50 // ChromeBrowserMainPartsMac --------------------------------------------------- | 50 // ChromeBrowserMainPartsMac --------------------------------------------------- |
51 | 51 |
52 ChromeBrowserMainPartsMac::ChromeBrowserMainPartsMac( | 52 ChromeBrowserMainPartsMac::ChromeBrowserMainPartsMac( |
53 const content::MainFunctionParams& parameters) | 53 const content::MainFunctionParams& parameters) |
54 : ChromeBrowserMainPartsPosix(parameters) { | 54 : ChromeBrowserMainPartsPosix(parameters) { |
55 } | 55 } |
56 | 56 |
57 void ChromeBrowserMainPartsMac::PreEarlyInitialization() { | 57 void ChromeBrowserMainPartsMac::PreEarlyInitialization() { |
58 if (parsed_command_line().HasSwitch(switches::kKeychainReauthorize)) { | |
59 if (base::mac::AmIBundled()) { | |
60 LOG(FATAL) << "Inappropriate process type for Keychain reauthorization"; | |
61 } | |
62 | |
63 // Do Keychain reauthorization at the time of update installation. This | |
64 // gets three chances to run. If the first or second try doesn't complete | |
65 // successfully (crashes or is interrupted for any reason), there will be | |
66 // another chance. Once this step completes successfully, it should never | |
67 // have to run again. | |
68 // | |
69 // This is kicked off by a special stub executable during an automatic | |
70 // update. See chrome/installer/mac/keychain_reauthorize_main.cc. This is | |
71 // done during update installation in additon to browser app launch to | |
72 // help reauthorize Keychain items for users who never restart Chrome. | |
73 NSString* const keychain_reauthorize_pref = | |
74 @"KeychainReauthorizeAtUpdateMay2012"; | |
TVL
2012/05/16 20:05:10
comment on when this key should be updated/changed
| |
75 const int kKeychainReauthorizeMaxTries = 3; | |
76 chrome::browser::mac::KeychainReauthorizeIfNeeded( | |
77 keychain_reauthorize_pref, kKeychainReauthorizeMaxTries); | |
78 | |
79 exit(0); | |
80 } | |
81 | |
58 ChromeBrowserMainPartsPosix::PreEarlyInitialization(); | 82 ChromeBrowserMainPartsPosix::PreEarlyInitialization(); |
59 | 83 |
60 if (base::mac::WasLaunchedAsHiddenLoginItem()) { | 84 if (base::mac::WasLaunchedAsHiddenLoginItem()) { |
61 CommandLine* singleton_command_line = CommandLine::ForCurrentProcess(); | 85 CommandLine* singleton_command_line = CommandLine::ForCurrentProcess(); |
62 singleton_command_line->AppendSwitch(switches::kNoStartupWindow); | 86 singleton_command_line->AppendSwitch(switches::kNoStartupWindow); |
63 } | 87 } |
64 } | 88 } |
65 | 89 |
66 void ChromeBrowserMainPartsMac::PreMainMessageLoopStart() { | 90 void ChromeBrowserMainPartsMac::PreMainMessageLoopStart() { |
67 ChromeBrowserMainPartsPosix::PreMainMessageLoopStart(); | 91 ChromeBrowserMainPartsPosix::PreMainMessageLoopStart(); |
(...skipping 62 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... | |
130 // change this, you'll probably need to change the Valgrind suppression. | 154 // change this, you'll probably need to change the Valgrind suppression. |
131 [nib instantiateNibWithOwner:NSApp topLevelObjects:nil]; | 155 [nib instantiateNibWithOwner:NSApp topLevelObjects:nil]; |
132 // Make sure the app controller has been created. | 156 // Make sure the app controller has been created. |
133 DCHECK([NSApp delegate]); | 157 DCHECK([NSApp delegate]); |
134 | 158 |
135 // Prevent Cocoa from turning command-line arguments into | 159 // Prevent Cocoa from turning command-line arguments into |
136 // |-application:openFiles:|, since we already handle them directly. | 160 // |-application:openFiles:|, since we already handle them directly. |
137 [[NSUserDefaults standardUserDefaults] | 161 [[NSUserDefaults standardUserDefaults] |
138 setObject:@"NO" forKey:@"NSTreatUnknownArgumentsAsOpen"]; | 162 setObject:@"NO" forKey:@"NSTreatUnknownArgumentsAsOpen"]; |
139 | 163 |
140 // Do Keychain reauthorization. This gets two chances to run. If the first | 164 // Do Keychain reauthorization at browser app launch. This gets two chances |
141 // try doesn't complete successfully (crashes or is interrupted for any | 165 // 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 | 166 // interrupted for any reason), there will be a second chance. Once this |
143 // successfully, it should never have to run again. | 167 // step completes successfully, it should never have to run again. |
144 NSString* const keychain_reauthorize_pref = | 168 NSString* const keychain_reauthorize_pref = |
145 @"KeychainReauthorizeInAppMay2012"; | 169 @"KeychainReauthorizeInAppMay2012"; |
TVL
2012/05/16 20:05:10
same comment. Might even make sense to move the c
| |
146 const int kKeychainReauthorizeMaxTries = 2; | 170 const int kKeychainReauthorizeMaxTries = 2; |
147 | 171 |
148 chrome::browser::mac::KeychainReauthorizeIfNeeded( | 172 chrome::browser::mac::KeychainReauthorizeIfNeeded( |
149 keychain_reauthorize_pref, kKeychainReauthorizeMaxTries); | 173 keychain_reauthorize_pref, kKeychainReauthorizeMaxTries); |
150 } | 174 } |
151 | 175 |
152 void ChromeBrowserMainPartsMac::DidEndMainMessageLoop() { | 176 void ChromeBrowserMainPartsMac::DidEndMainMessageLoop() { |
153 AppController* appController = [NSApp delegate]; | 177 AppController* appController = [NSApp delegate]; |
154 [appController didEndMainMessageLoop]; | 178 [appController didEndMainMessageLoop]; |
155 } | 179 } |
OLD | NEW |