[email protected] | 71c0eb9 | 2012-01-03 17:57:30 | [diff] [blame] | 1 | // Copyright (c) 2012 The Chromium Authors. All rights reserved. |
[email protected] | 5c9587c | 2008-12-09 21:20:16 | [diff] [blame] | 2 | // Use of this source code is governed by a BSD-style license that can be |
| 3 | // found in the LICENSE file. |
| 4 | |
[email protected] | e6b5bc2 | 2011-09-08 22:01:56 | [diff] [blame] | 5 | #include "chrome/browser/chrome_browser_main_mac.h" |
[email protected] | 1152b7e | 2009-09-14 03:26:03 | [diff] [blame] | 6 | |
[email protected] | ce8c16ad | 2009-08-12 19:00:42 | [diff] [blame] | 7 | #import <Cocoa/Cocoa.h> |
[email protected] | 1152b7e | 2009-09-14 03:26:03 | [diff] [blame] | 8 | |
Sebastien Marchand | f1349f5 | 2019-01-25 03:16:41 | [diff] [blame] | 9 | #include "base/bind.h" |
[email protected] | 5c9587c | 2008-12-09 21:20:16 | [diff] [blame] | 10 | #include "base/command_line.h" |
[email protected] | 2f1804c | 2012-01-19 14:59:07 | [diff] [blame] | 11 | #include "base/mac/bundle_locations.h" |
tapted | 676995d | 2016-04-18 11:32:29 | [diff] [blame] | 12 | #import "base/mac/foundation_util.h" |
[email protected] | 0378bf4 | 2011-01-01 18:20:14 | [diff] [blame] | 13 | #include "base/mac/mac_util.h" |
[email protected] | a852203 | 2013-06-24 22:51:46 | [diff] [blame] | 14 | #include "base/mac/scoped_nsobject.h" |
Avi Drissman | 3730e99a | 2020-05-12 19:20:18 | [diff] [blame] | 15 | #include "base/metrics/histogram_functions.h" |
[email protected] | e1cb0e9 | 2010-06-15 07:23:59 | [diff] [blame] | 16 | #include "base/path_service.h" |
Avi Drissman | 3730e99a | 2020-05-12 19:20:18 | [diff] [blame] | 17 | #include "base/strings/sys_string_conversions.h" |
Avi Drissman | 3730e99a | 2020-05-12 19:20:18 | [diff] [blame] | 18 | #include "build/branding_buildflags.h" |
[email protected] | 3b6aa8b6 | 2009-09-15 21:36:11 | [diff] [blame] | 19 | #import "chrome/browser/app_controller_mac.h" |
Christopher Cameron | 4d18d1a | 2019-08-27 18:01:53 | [diff] [blame] | 20 | #include "chrome/browser/apps/app_shim/app_shim_listener.h" |
[email protected] | e8b6ca0 | 2013-07-10 18:00:51 | [diff] [blame] | 21 | #include "chrome/browser/browser_process.h" |
Hans Wennborg | 6334445 | 2019-10-15 10:15:21 | [diff] [blame] | 22 | #include "chrome/browser/browser_process_platform_part.h" |
[email protected] | aaa47ee | 2009-11-05 21:53:01 | [diff] [blame] | 23 | #import "chrome/browser/chrome_browser_application_mac.h" |
Christopher Lam | 32c68452 | 2017-07-28 03:05:02 | [diff] [blame] | 24 | #include "chrome/browser/first_run/first_run.h" |
[email protected] | c4d501e | 2012-03-27 20:08:02 | [diff] [blame] | 25 | #include "chrome/browser/mac/install_from_dmg.h" |
[email protected] | 5950f571 | 2011-06-20 22:15:52 | [diff] [blame] | 26 | #import "chrome/browser/mac/keystone_glue.h" |
[email protected] | 7d1aaa6 | 2014-07-18 02:21:30 | [diff] [blame] | 27 | #include "chrome/browser/mac/mac_startup_profiler.h" |
Robert Sesek | 124f80f9 | 2018-07-24 20:31:29 | [diff] [blame] | 28 | #include "chrome/browser/ui/cocoa/main_menu_builder.h" |
Avi Drissman | 3730e99a | 2020-05-12 19:20:18 | [diff] [blame] | 29 | #include "chrome/common/channel_info.h" |
[email protected] | e1cb0e9 | 2010-06-15 07:23:59 | [diff] [blame] | 30 | #include "chrome/common/chrome_paths.h" |
[email protected] | d7dbe28c | 2010-07-29 04:33:47 | [diff] [blame] | 31 | #include "chrome/common/chrome_switches.h" |
Sidney San Martín | aa4c7d6 | 2019-10-01 02:01:21 | [diff] [blame] | 32 | #include "chrome/common/pref_names.h" |
Christopher Cameron | 199deeb | 2018-10-17 20:29:53 | [diff] [blame] | 33 | #include "chrome/grit/chromium_strings.h" |
Rohit Rao | 92f84b6a | 2020-03-25 14:57:50 | [diff] [blame] | 34 | #include "components/crash/core/app/crashpad.h" |
[email protected] | d6147bd | 2014-06-11 01:58:19 | [diff] [blame] | 35 | #include "components/metrics/metrics_service.h" |
Tonko Sabolčec | 43615a9 | 2018-09-12 12:43:41 | [diff] [blame] | 36 | #include "components/os_crypt/os_crypt.h" |
Avi Drissman | 3730e99a | 2020-05-12 19:20:18 | [diff] [blame] | 37 | #include "components/version_info/channel.h" |
[email protected] | 4573fbd | 2011-10-31 20:25:18 | [diff] [blame] | 38 | #include "content/public/common/main_function_params.h" |
[email protected] | b39ef1cb | 2011-10-25 04:46:55 | [diff] [blame] | 39 | #include "content/public/common/result_codes.h" |
Christopher Cameron | 199deeb | 2018-10-17 20:29:53 | [diff] [blame] | 40 | #include "ui/base/l10n/l10n_util.h" |
[email protected] | 42ce29d | 2011-01-20 23:19:46 | [diff] [blame] | 41 | #include "ui/base/resource/resource_bundle.h" |
[email protected] | 63942f2 | 2012-05-01 06:11:52 | [diff] [blame] | 42 | #include "ui/base/resource/resource_handle.h" |
Leonard Grey | 7f2c992 | 2018-12-05 16:03:22 | [diff] [blame] | 43 | #include "ui/native_theme/native_theme_mac.h" |
[email protected] | 5c9587c | 2008-12-09 21:20:16 | [diff] [blame] | 44 | |
calamity | c95d782 | 2015-05-04 02:10:16 | [diff] [blame] | 45 | namespace { |
| 46 | |
Avi Drissman | 3730e99a | 2020-05-12 19:20:18 | [diff] [blame] | 47 | #if BUILDFLAG(GOOGLE_CHROME_BRANDING) |
| 48 | |
| 49 | // These values are persisted to logs as OSXOtherChromeInstancesResult. |
| 50 | // Entries should not be renumbered and numeric values should never be reused. |
| 51 | enum class OtherInstancesResult { |
| 52 | kFailureDontKnowWhenOtherChromeUsed, |
| 53 | kFailureToReadPlist, |
| 54 | kNoOtherChrome, |
| 55 | kOneOtherChromeAndLastUsedWithinWeek, |
| 56 | kOneOtherChromeAndLastUsedWithinMonth, |
| 57 | kOneOtherChromeAndLastUsedMoreThanAMonthAgo, |
| 58 | kMoreThanOneOtherChromeAndLastUsedWithinWeek, |
| 59 | kMoreThanOneOtherChromeAndLastUsedWithinMonth, |
| 60 | kMoreThanOneOtherChromeAndLastUsedMoreThanAMonthAgo, |
| 61 | kMaxValue = kMoreThanOneOtherChromeAndLastUsedMoreThanAMonthAgo, |
| 62 | }; |
| 63 | |
| 64 | struct WhenLastUsed { |
| 65 | int within_last_week = 0; |
| 66 | int within_last_month = 0; |
| 67 | int before_last_month = 0; |
| 68 | }; |
| 69 | |
| 70 | OtherInstancesResult OtherInstancesResultForWhenLastUsed( |
| 71 | const WhenLastUsed& used) { |
| 72 | if (used.within_last_week + used.within_last_month + used.before_last_month == |
| 73 | 0) { |
| 74 | return OtherInstancesResult::kNoOtherChrome; |
| 75 | } |
| 76 | |
| 77 | if (used.within_last_week + used.within_last_month + used.before_last_month == |
| 78 | 1) { |
| 79 | if (used.within_last_week) |
| 80 | return OtherInstancesResult::kOneOtherChromeAndLastUsedWithinWeek; |
| 81 | |
| 82 | if (used.within_last_month) |
| 83 | return OtherInstancesResult::kOneOtherChromeAndLastUsedWithinMonth; |
| 84 | |
| 85 | return OtherInstancesResult::kOneOtherChromeAndLastUsedMoreThanAMonthAgo; |
| 86 | } |
| 87 | |
| 88 | if (used.within_last_week) |
| 89 | return OtherInstancesResult::kMoreThanOneOtherChromeAndLastUsedWithinWeek; |
| 90 | |
| 91 | if (used.within_last_month) |
| 92 | return OtherInstancesResult::kMoreThanOneOtherChromeAndLastUsedWithinMonth; |
| 93 | |
| 94 | return OtherInstancesResult:: |
| 95 | kMoreThanOneOtherChromeAndLastUsedMoreThanAMonthAgo; |
| 96 | } |
| 97 | |
| 98 | void RecordChromeQueryResults(NSMetadataQuery* query) { |
| 99 | __block bool other_chrome_last_used_unknown = false; |
| 100 | __block bool failed_to_read_plist = false; |
| 101 | __block WhenLastUsed same_channel; |
| 102 | __block WhenLastUsed different_channel; |
| 103 | |
| 104 | NSURL* this_url = NSBundle.mainBundle.bundleURL; |
| 105 | std::string this_channel = chrome::GetChannelName(); |
| 106 | NSDate* about_a_week_ago = |
| 107 | [[NSDate date] dateByAddingTimeInterval:-7 * 24 * 60 * 60]; |
| 108 | NSDate* about_a_month_ago = |
| 109 | [[NSDate date] dateByAddingTimeInterval:-30 * 24 * 60 * 60]; |
| 110 | |
| 111 | [query enumerateResultsUsingBlock:^(id result, NSUInteger idx, BOOL* stop) { |
| 112 | // Skip this copy of Chrome. Note that NSMetadataItemURLKey is not used as |
| 113 | // it always returns nil while NSMetadataItemPathKey returns a legit path. |
| 114 | // Filed as FB7689234. |
| 115 | NSString* app_path = base::mac::ObjCCast<NSString>( |
| 116 | [result valueForAttribute:NSMetadataItemPathKey]); |
Avi Drissman | 852b58e3 | 2020-05-27 17:16:32 | [diff] [blame] | 117 | if (!app_path) { |
| 118 | // It seems implausible, but there are Macs in the field for which |
| 119 | // Spotlight will find results for the query of locating Chrome but cannot |
| 120 | // actually return a path to the result. https://crbug.com/1086555 |
| 121 | failed_to_read_plist = true; |
| 122 | *stop = YES; |
| 123 | return; |
| 124 | } |
| 125 | |
Avi Drissman | 3730e99a | 2020-05-12 19:20:18 | [diff] [blame] | 126 | NSURL* app_url = [NSURL fileURLWithPath:app_path isDirectory:YES]; |
| 127 | if ([app_url isEqual:this_url]) |
| 128 | return; |
| 129 | |
| 130 | NSURL* plist_url = [[app_url URLByAppendingPathComponent:@"Contents" |
| 131 | isDirectory:YES] |
| 132 | URLByAppendingPathComponent:@"Info.plist" |
| 133 | isDirectory:NO]; |
| 134 | NSDictionary* plist = [NSDictionary dictionaryWithContentsOfURL:plist_url]; |
| 135 | if (!plist) { |
| 136 | failed_to_read_plist = true; |
| 137 | *stop = YES; |
| 138 | return; |
| 139 | } |
| 140 | |
| 141 | // Skip any SxS-capable copies of Chrome. |
| 142 | if (plist[@"CrProductDirName"]) |
| 143 | return; |
| 144 | |
| 145 | WhenLastUsed* when_last_used = &different_channel; |
| 146 | if (this_channel == base::SysNSStringToUTF8(plist[@"KSChannelID"])) |
| 147 | when_last_used = &same_channel; |
| 148 | |
| 149 | NSDate* last_used = base::mac::ObjCCast<NSDate>( |
| 150 | [result valueForAttribute:NSMetadataItemLastUsedDateKey]); |
| 151 | if (!last_used) { |
| 152 | other_chrome_last_used_unknown = true; |
| 153 | *stop = YES; |
| 154 | return; |
| 155 | } |
| 156 | |
| 157 | if ([last_used compare:about_a_week_ago] == NSOrderedDescending) |
| 158 | ++when_last_used->within_last_week; |
| 159 | else if ([last_used compare:about_a_month_ago] == NSOrderedDescending) |
| 160 | ++when_last_used->within_last_month; |
| 161 | else |
| 162 | ++when_last_used->before_last_month; |
| 163 | }]; |
| 164 | |
| 165 | if (other_chrome_last_used_unknown) { |
| 166 | base::UmaHistogramEnumeration( |
| 167 | "OSX.Installation.OtherChromeInstances.SameChannel", |
| 168 | OtherInstancesResult::kFailureDontKnowWhenOtherChromeUsed); |
| 169 | base::UmaHistogramEnumeration( |
| 170 | "OSX.Installation.OtherChromeInstances.DifferentChannel", |
| 171 | OtherInstancesResult::kFailureDontKnowWhenOtherChromeUsed); |
| 172 | return; |
| 173 | } |
| 174 | |
| 175 | if (failed_to_read_plist) { |
| 176 | base::UmaHistogramEnumeration( |
| 177 | "OSX.Installation.OtherChromeInstances.SameChannel", |
| 178 | OtherInstancesResult::kFailureToReadPlist); |
| 179 | base::UmaHistogramEnumeration( |
| 180 | "OSX.Installation.OtherChromeInstances.DifferentChannel", |
| 181 | OtherInstancesResult::kFailureToReadPlist); |
| 182 | return; |
| 183 | } |
| 184 | |
| 185 | base::UmaHistogramEnumeration( |
| 186 | "OSX.Installation.OtherChromeInstances.SameChannel", |
| 187 | OtherInstancesResultForWhenLastUsed(same_channel)); |
| 188 | base::UmaHistogramEnumeration( |
| 189 | "OSX.Installation.OtherChromeInstances.DifferentChannel", |
| 190 | OtherInstancesResultForWhenLastUsed(different_channel)); |
| 191 | } |
| 192 | |
| 193 | void ExecuteChromeQuery() { |
| 194 | __block NSMetadataQuery* query = [[NSMetadataQuery alloc] init]; |
| 195 | |
| 196 | __block id token = [[NSNotificationCenter defaultCenter] |
| 197 | addObserverForName:NSMetadataQueryDidFinishGatheringNotification |
| 198 | object:query |
| 199 | queue:[NSOperationQueue mainQueue] |
| 200 | usingBlock:^(NSNotification* note) { |
| 201 | [query stopQuery]; |
| 202 | RecordChromeQueryResults(query); |
| 203 | [query release]; |
| 204 | [[NSNotificationCenter defaultCenter] removeObserver:token]; |
| 205 | }]; |
| 206 | |
| 207 | query.predicate = |
| 208 | [NSPredicate predicateWithFormat: |
| 209 | @"kMDItemContentType == 'com.apple.application-bundle'" |
| 210 | @"AND kMDItemCFBundleIdentifier == 'com.google.Chrome'"]; |
| 211 | |
| 212 | [query startQuery]; |
| 213 | } |
| 214 | |
| 215 | // Records statistics about this install of Chromium if it is a Google Chrome |
| 216 | // Beta or Google Chrome Dev instance. This is to allow for decisions to be made |
| 217 | // about the migration of user data directories. |
| 218 | void RecordBetaAndDevStats() { |
| 219 | version_info::Channel channel = chrome::GetChannel(); |
| 220 | if (channel != version_info::Channel::BETA && |
| 221 | channel != version_info::Channel::DEV) { |
| 222 | return; |
| 223 | } |
| 224 | |
| 225 | ExecuteChromeQuery(); |
| 226 | } |
| 227 | |
| 228 | #endif // GOOGLE_CHROME_BRANDING |
| 229 | |
calamity | c95d782 | 2015-05-04 02:10:16 | [diff] [blame] | 230 | } // namespace |
| 231 | |
[email protected] | e6b5bc2 | 2011-09-08 22:01:56 | [diff] [blame] | 232 | // ChromeBrowserMainPartsMac --------------------------------------------------- |
[email protected] | 1fec6435 | 2010-07-27 13:55:21 | [diff] [blame] | 233 | |
[email protected] | e6b5bc2 | 2011-09-08 22:01:56 | [diff] [blame] | 234 | ChromeBrowserMainPartsMac::ChromeBrowserMainPartsMac( |
Ran Ji | a96d43d4 | 2018-05-02 17:14:53 | [diff] [blame] | 235 | const content::MainFunctionParams& parameters, |
Xi Han | 85079c2 | 2019-04-18 21:43:05 | [diff] [blame] | 236 | StartupData* startup_data) |
| 237 | : ChromeBrowserMainPartsPosix(parameters, startup_data) {} |
[email protected] | 1fec6435 | 2010-07-27 13:55:21 | [diff] [blame] | 238 | |
[email protected] | 39fc5d32 | 2012-09-15 10:54:55 | [diff] [blame] | 239 | ChromeBrowserMainPartsMac::~ChromeBrowserMainPartsMac() { |
| 240 | } |
| 241 | |
Scott Violet | 9068b4df | 2018-01-12 16:44:21 | [diff] [blame] | 242 | int ChromeBrowserMainPartsMac::PreEarlyInitialization() { |
[email protected] | 769ddfe | 2014-06-13 23:13:20 | [diff] [blame] | 243 | if (base::mac::WasLaunchedAsLoginItemRestoreState()) { |
avi | 3ef9ec9e | 2014-12-22 22:50:17 | [diff] [blame] | 244 | base::CommandLine* singleton_command_line = |
| 245 | base::CommandLine::ForCurrentProcess(); |
[email protected] | 769ddfe | 2014-06-13 23:13:20 | [diff] [blame] | 246 | singleton_command_line->AppendSwitch(switches::kRestoreLastSession); |
| 247 | } else if (base::mac::WasLaunchedAsHiddenLoginItem()) { |
avi | 3ef9ec9e | 2014-12-22 22:50:17 | [diff] [blame] | 248 | base::CommandLine* singleton_command_line = |
| 249 | base::CommandLine::ForCurrentProcess(); |
[email protected] | f967b72 | 2011-09-07 00:58:04 | [diff] [blame] | 250 | singleton_command_line->AppendSwitch(switches::kNoStartupWindow); |
| 251 | } |
Scott Violet | 9068b4df | 2018-01-12 16:44:21 | [diff] [blame] | 252 | |
Scott Violet | 740c263 | 2018-03-09 04:11:42 | [diff] [blame] | 253 | return ChromeBrowserMainPartsPosix::PreEarlyInitialization(); |
Scott Violet | 875789e | 2018-02-02 07:46:48 | [diff] [blame] | 254 | } |
[email protected] | a88f636 | 2014-03-18 04:25:35 | [diff] [blame] | 255 | |
Scott Violet | 875789e | 2018-02-02 07:46:48 | [diff] [blame] | 256 | void ChromeBrowserMainPartsMac::PreMainMessageLoopStart() { |
| 257 | MacStartupProfiler::GetInstance()->Profile( |
| 258 | MacStartupProfiler::PRE_MAIN_MESSAGE_LOOP_START); |
| 259 | ChromeBrowserMainPartsPosix::PreMainMessageLoopStart(); |
| 260 | |
| 261 | // ChromeBrowserMainParts should have loaded the resource bundle by this |
| 262 | // point (needed to load the nib). |
| 263 | CHECK(ui::ResourceBundle::HasSharedInstance()); |
[email protected] | a88f636 | 2014-03-18 04:25:35 | [diff] [blame] | 264 | |
[email protected] | c4d501e | 2012-03-27 20:08:02 | [diff] [blame] | 265 | // This is a no-op if the KeystoneRegistration framework is not present. |
| 266 | // The framework is only distributed with branded Google Chrome builds. |
| 267 | [[KeystoneGlue defaultKeystoneGlue] registerWithKeystone]; |
| 268 | |
| 269 | // Disk image installation is sort of a first-run task, so it shares the |
[email protected] | 0a160a1b | 2013-08-08 22:20:00 | [diff] [blame] | 270 | // no first run switches. |
[email protected] | c4d501e | 2012-03-27 20:08:02 | [diff] [blame] | 271 | // |
| 272 | // This needs to be done after the resource bundle is initialized (for |
| 273 | // access to localizations in the UI) and after Keystone is initialized |
| 274 | // (because the installation may need to promote Keystone) but before the |
| 275 | // app controller is set up (and thus before MainMenu.nib is loaded, because |
| 276 | // the app controller assumes that a browser has been set up and will crash |
| 277 | // upon receipt of certain notifications if no browser exists), before |
| 278 | // anyone tries doing anything silly like firing off an import job, and |
| 279 | // before anything creating preferences like Local State in order for the |
| 280 | // relaunched installed application to still consider itself as first-run. |
[email protected] | 0a160a1b | 2013-08-08 22:20:00 | [diff] [blame] | 281 | if (!first_run::IsFirstRunSuppressed(parsed_command_line())) { |
[email protected] | c4d501e | 2012-03-27 20:08:02 | [diff] [blame] | 282 | if (MaybeInstallFromDiskImage()) { |
| 283 | // The application was installed and the installed copy has been |
| 284 | // launched. This process is now obsolete. Exit. |
| 285 | exit(0); |
| 286 | } |
| 287 | } |
| 288 | |
Robert Sesek | 124f80f9 | 2018-07-24 20:31:29 | [diff] [blame] | 289 | // Create the app delegate. This object is intentionally leaked as a global |
| 290 | // singleton. It is accessed through -[NSApp delegate]. |
| 291 | AppController* app_controller = [[AppController alloc] init]; |
| 292 | [NSApp setDelegate:app_controller]; |
| 293 | |
Christopher Cameron | 199deeb | 2018-10-17 20:29:53 | [diff] [blame] | 294 | chrome::BuildMainMenu(NSApp, app_controller, |
| 295 | l10n_util::GetStringUTF16(IDS_PRODUCT_NAME), false); |
Robert Sesek | 124f80f9 | 2018-07-24 20:31:29 | [diff] [blame] | 296 | [app_controller mainMenuCreated]; |
kerrnel | 26eeef0 | 2017-03-10 19:03:43 | [diff] [blame] | 297 | |
Tonko Sabolčec | 43615a9 | 2018-09-12 12:43:41 | [diff] [blame] | 298 | PrefService* local_state = g_browser_process->local_state(); |
| 299 | DCHECK(local_state); |
Sidney San Martín | aa4c7d6 | 2019-10-01 02:01:21 | [diff] [blame] | 300 | |
Sidney San Martín | aa4c7d6 | 2019-10-01 02:01:21 | [diff] [blame] | 301 | // AppKit only restores windows to their original spaces when relaunching |
| 302 | // apps after a restart, and puts them all on the current space when an app |
| 303 | // is manually quit and relaunched. If Chrome restarted itself, ask AppKit to |
| 304 | // treat this launch like a system restart and restore everything. |
| 305 | if (local_state->GetBoolean(prefs::kWasRestarted)) { |
| 306 | [NSUserDefaults.standardUserDefaults registerDefaults:@{ |
| 307 | @"NSWindowRestoresWorkspaceAtLaunch" : @YES |
| 308 | }]; |
| 309 | } |
[email protected] | f967b72 | 2011-09-07 00:58:04 | [diff] [blame] | 310 | } |
[email protected] | 03d8d3e9 | 2011-09-20 06:07:11 | [diff] [blame] | 311 | |
[email protected] | 7d1aaa6 | 2014-07-18 02:21:30 | [diff] [blame] | 312 | void ChromeBrowserMainPartsMac::PostMainMessageLoopStart() { |
| 313 | MacStartupProfiler::GetInstance()->Profile( |
| 314 | MacStartupProfiler::POST_MAIN_MESSAGE_LOOP_START); |
[email protected] | 6ddc1097 | 2014-07-29 07:53:33 | [diff] [blame] | 315 | ChromeBrowserMainPartsPosix::PostMainMessageLoopStart(); |
Avi Drissman | 3730e99a | 2020-05-12 19:20:18 | [diff] [blame] | 316 | |
| 317 | #if BUILDFLAG(GOOGLE_CHROME_BRANDING) |
| 318 | RecordBetaAndDevStats(); |
| 319 | #endif // GOOGLE_CHROME_BRANDING |
[email protected] | 7d1aaa6 | 2014-07-18 02:21:30 | [diff] [blame] | 320 | } |
| 321 | |
[email protected] | bdad6e6 | 2014-05-06 08:47:37 | [diff] [blame] | 322 | void ChromeBrowserMainPartsMac::PreProfileInit() { |
[email protected] | 7d1aaa6 | 2014-07-18 02:21:30 | [diff] [blame] | 323 | MacStartupProfiler::GetInstance()->Profile( |
| 324 | MacStartupProfiler::PRE_PROFILE_INIT); |
[email protected] | bdad6e6 | 2014-05-06 08:47:37 | [diff] [blame] | 325 | ChromeBrowserMainPartsPosix::PreProfileInit(); |
mlerman | a312cec | 2015-01-28 21:13:33 | [diff] [blame] | 326 | |
[email protected] | bdad6e6 | 2014-05-06 08:47:37 | [diff] [blame] | 327 | // This is called here so that the app shim socket is only created after |
| 328 | // taking the singleton lock. |
Christopher Cameron | 4d18d1a | 2019-08-27 18:01:53 | [diff] [blame] | 329 | g_browser_process->platform_part()->app_shim_listener()->Init(); |
[email protected] | bdad6e6 | 2014-05-06 08:47:37 | [diff] [blame] | 330 | } |
| 331 | |
[email protected] | e8b6ca0 | 2013-07-10 18:00:51 | [diff] [blame] | 332 | void ChromeBrowserMainPartsMac::PostProfileInit() { |
[email protected] | 7d1aaa6 | 2014-07-18 02:21:30 | [diff] [blame] | 333 | MacStartupProfiler::GetInstance()->Profile( |
| 334 | MacStartupProfiler::POST_PROFILE_INIT); |
[email protected] | e8b6ca0 | 2013-07-10 18:00:51 | [diff] [blame] | 335 | ChromeBrowserMainPartsPosix::PostProfileInit(); |
mark | d413b2d | 2015-03-13 07:45:40 | [diff] [blame] | 336 | |
[email protected] | e8b6ca0 | 2013-07-10 18:00:51 | [diff] [blame] | 337 | g_browser_process->metrics_service()->RecordBreakpadRegistration( |
mark | d413b2d | 2015-03-13 07:45:40 | [diff] [blame] | 338 | crash_reporter::GetUploadsEnabled()); |
calamity | c95d782 | 2015-05-04 02:10:16 | [diff] [blame] | 339 | |
borisv | 957d52d | 2016-04-13 18:35:43 | [diff] [blame] | 340 | // Activation of Keystone is not automatic but done in response to the |
| 341 | // counting and reporting of profiles. |
| 342 | KeystoneGlue* glue = [KeystoneGlue defaultKeystoneGlue]; |
| 343 | if (glue && ![glue isRegisteredAndActive]) { |
| 344 | // If profile loading has failed, we still need to handle other tasks |
| 345 | // like marking of the product as active. |
Joshua Pawlicki | 9fbc841 | 2019-03-20 16:05:12 | [diff] [blame] | 346 | [glue setRegistrationActive]; |
borisv | 957d52d | 2016-04-13 18:35:43 | [diff] [blame] | 347 | } |
[email protected] | e8b6ca0 | 2013-07-10 18:00:51 | [diff] [blame] | 348 | } |
| 349 | |
[email protected] | 03d8d3e9 | 2011-09-20 06:07:11 | [diff] [blame] | 350 | void ChromeBrowserMainPartsMac::DidEndMainMessageLoop() { |
tapted | 676995d | 2016-04-18 11:32:29 | [diff] [blame] | 351 | AppController* appController = |
| 352 | base::mac::ObjCCastStrict<AppController>([NSApp delegate]); |
[email protected] | 03d8d3e9 | 2011-09-20 06:07:11 | [diff] [blame] | 353 | [appController didEndMainMessageLoop]; |
| 354 | } |