| 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 #include <sys/sysctl.h> | 8 #include <sys/sysctl.h> |
| 9 | 9 |
| 10 #include "base/command_line.h" | 10 #include "base/command_line.h" |
| 11 #include "base/files/file_path.h" | 11 #include "base/files/file_path.h" |
| 12 #include "base/mac/bundle_locations.h" | 12 #include "base/mac/bundle_locations.h" |
| 13 #include "base/mac/mac_util.h" | 13 #include "base/mac/mac_util.h" |
| 14 #include "base/mac/scoped_nsobject.h" | 14 #include "base/mac/scoped_nsobject.h" |
| 15 #include "base/metrics/histogram.h" | 15 #include "base/metrics/histogram.h" |
| 16 #include "base/path_service.h" | 16 #include "base/path_service.h" |
| 17 #import "chrome/browser/app_controller_mac.h" | 17 #import "chrome/browser/app_controller_mac.h" |
| 18 #include "chrome/browser/browser_process.h" | 18 #include "chrome/browser/browser_process.h" |
| 19 #import "chrome/browser/chrome_browser_application_mac.h" | 19 #import "chrome/browser/chrome_browser_application_mac.h" |
| 20 #include "chrome/browser/mac/install_from_dmg.h" | 20 #include "chrome/browser/mac/install_from_dmg.h" |
| 21 #include "chrome/browser/mac/keychain_reauthorize.h" | |
| 22 #import "chrome/browser/mac/keystone_glue.h" | 21 #import "chrome/browser/mac/keystone_glue.h" |
| 23 #include "chrome/browser/metrics/metrics_service.h" | 22 #include "chrome/browser/metrics/metrics_service.h" |
| 24 #include "chrome/common/chrome_paths.h" | 23 #include "chrome/common/chrome_paths.h" |
| 25 #include "chrome/common/chrome_switches.h" | 24 #include "chrome/common/chrome_switches.h" |
| 26 #include "components/breakpad/app/breakpad_mac.h" | 25 #include "components/breakpad/app/breakpad_mac.h" |
| 27 #include "content/public/common/main_function_params.h" | 26 #include "content/public/common/main_function_params.h" |
| 28 #include "content/public/common/result_codes.h" | 27 #include "content/public/common/result_codes.h" |
| 29 #include "ui/base/l10n/l10n_util_mac.h" | 28 #include "ui/base/l10n/l10n_util_mac.h" |
| 30 #include "ui/base/resource/resource_bundle.h" | 29 #include "ui/base/resource/resource_bundle.h" |
| 31 #include "ui/base/resource/resource_handle.h" | 30 #include "ui/base/resource/resource_handle.h" |
| 32 | 31 |
| 33 namespace { | 32 namespace { |
| 34 | 33 |
| 35 // Some users rarely restart Chrome, so they might never get a chance to run | |
| 36 // the at-launch KeychainReauthorize. To account for them, there's also an | |
| 37 // at-update KeychainReauthorize option, which runs from .keystone_install for | |
| 38 // users on a user Keystone ticket. This operation may make sense for a period | |
| 39 // of time after the application switches to being signed by the new | |
| 40 // certificate, as long as the at-update stub executable is still signed by | |
| 41 // the old one. | |
| 42 NSString* const kKeychainReauthorizeAtUpdatePref = | |
| 43 @"KeychainReauthorizeAtUpdateMay2012"; | |
| 44 const int kKeychainReauthorizeAtUpdateMaxTries = 3; | |
| 45 | |
| 46 // This is one enum instead of two so that the values can be correlated in a | 34 // This is one enum instead of two so that the values can be correlated in a |
| 47 // histogram. | 35 // histogram. |
| 48 enum CatSixtyFour { | 36 enum CatSixtyFour { |
| 49 // Older than any expected cat. | 37 // Older than any expected cat. |
| 50 SABER_TOOTHED_CAT_32 = 0, | 38 SABER_TOOTHED_CAT_32 = 0, |
| 51 SABER_TOOTHED_CAT_64, | 39 SABER_TOOTHED_CAT_64, |
| 52 | 40 |
| 53 // Known cats. | 41 // Known cats. |
| 54 SNOW_LEOPARD_32, | 42 SNOW_LEOPARD_32, |
| 55 SNOW_LEOPARD_64, | 43 SNOW_LEOPARD_64, |
| (...skipping 99 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 155 | 143 |
| 156 ChromeBrowserMainPartsMac::ChromeBrowserMainPartsMac( | 144 ChromeBrowserMainPartsMac::ChromeBrowserMainPartsMac( |
| 157 const content::MainFunctionParams& parameters) | 145 const content::MainFunctionParams& parameters) |
| 158 : ChromeBrowserMainPartsPosix(parameters) { | 146 : ChromeBrowserMainPartsPosix(parameters) { |
| 159 } | 147 } |
| 160 | 148 |
| 161 ChromeBrowserMainPartsMac::~ChromeBrowserMainPartsMac() { | 149 ChromeBrowserMainPartsMac::~ChromeBrowserMainPartsMac() { |
| 162 } | 150 } |
| 163 | 151 |
| 164 void ChromeBrowserMainPartsMac::PreEarlyInitialization() { | 152 void ChromeBrowserMainPartsMac::PreEarlyInitialization() { |
| 165 if (parsed_command_line().HasSwitch(switches::kKeychainReauthorize)) { | |
| 166 if (base::mac::AmIBundled()) { | |
| 167 LOG(FATAL) << "Inappropriate process type for Keychain reauthorization"; | |
| 168 } | |
| 169 | |
| 170 // Do Keychain reauthorization at the time of update installation. This | |
| 171 // gets three chances to run. If the first or second try doesn't complete | |
| 172 // successfully (crashes or is interrupted for any reason), there will be | |
| 173 // another chance. Once this step completes successfully, it should never | |
| 174 // have to run again. | |
| 175 // | |
| 176 // This is kicked off by a special stub executable during an automatic | |
| 177 // update. See chrome/installer/mac/keychain_reauthorize_main.cc. | |
| 178 chrome::KeychainReauthorizeIfNeeded(kKeychainReauthorizeAtUpdatePref, | |
| 179 kKeychainReauthorizeAtUpdateMaxTries); | |
| 180 | |
| 181 exit(0); | |
| 182 } | |
| 183 | |
| 184 ChromeBrowserMainPartsPosix::PreEarlyInitialization(); | 153 ChromeBrowserMainPartsPosix::PreEarlyInitialization(); |
| 185 | 154 |
| 186 if (base::mac::WasLaunchedAsHiddenLoginItem()) { | 155 if (base::mac::WasLaunchedAsHiddenLoginItem()) { |
| 187 CommandLine* singleton_command_line = CommandLine::ForCurrentProcess(); | 156 CommandLine* singleton_command_line = CommandLine::ForCurrentProcess(); |
| 188 singleton_command_line->AppendSwitch(switches::kNoStartupWindow); | 157 singleton_command_line->AppendSwitch(switches::kNoStartupWindow); |
| 189 } | 158 } |
| 190 | 159 |
| 191 RecordCatSixtyFour(); | 160 RecordCatSixtyFour(); |
| 192 } | 161 } |
| 193 | 162 |
| (...skipping 83 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 277 void ChromeBrowserMainPartsMac::PostProfileInit() { | 246 void ChromeBrowserMainPartsMac::PostProfileInit() { |
| 278 ChromeBrowserMainPartsPosix::PostProfileInit(); | 247 ChromeBrowserMainPartsPosix::PostProfileInit(); |
| 279 g_browser_process->metrics_service()->RecordBreakpadRegistration( | 248 g_browser_process->metrics_service()->RecordBreakpadRegistration( |
| 280 breakpad::IsCrashReporterEnabled()); | 249 breakpad::IsCrashReporterEnabled()); |
| 281 } | 250 } |
| 282 | 251 |
| 283 void ChromeBrowserMainPartsMac::DidEndMainMessageLoop() { | 252 void ChromeBrowserMainPartsMac::DidEndMainMessageLoop() { |
| 284 AppController* appController = [NSApp delegate]; | 253 AppController* appController = [NSApp delegate]; |
| 285 [appController didEndMainMessageLoop]; | 254 [appController didEndMainMessageLoop]; |
| 286 } | 255 } |
| OLD | NEW |