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" |
(...skipping 156 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
167 // instead of calling NSApplicationMain(). The primary reason is that NSAM() | 167 // instead of calling NSApplicationMain(). The primary reason is that NSAM() |
168 // never returns, which would leave all the objects currently on the stack | 168 // never returns, which would leave all the objects currently on the stack |
169 // in scoped_ptrs hanging and never cleaned up. We then load the main nib | 169 // in scoped_ptrs hanging and never cleaned up. We then load the main nib |
170 // directly. The main event loop is run from common code using the | 170 // directly. The main event loop is run from common code using the |
171 // MessageLoop API, which works out ok for us because it's a wrapper around | 171 // MessageLoop API, which works out ok for us because it's a wrapper around |
172 // CFRunLoop. | 172 // CFRunLoop. |
173 | 173 |
174 // Initialize NSApplication using the custom subclass. | 174 // Initialize NSApplication using the custom subclass. |
175 chrome_browser_application_mac::RegisterBrowserCrApp(); | 175 chrome_browser_application_mac::RegisterBrowserCrApp(); |
176 | 176 |
177 // If ui_task is not NULL, the app is actually a browser_test, so startup is | 177 // If ui_task is not NULL, the app is actually a browser_test. |
178 // handled outside of BrowserMain (which is what called this). | |
179 if (!parameters().ui_task) { | 178 if (!parameters().ui_task) { |
180 // The browser process only wants to support the language Cocoa will use, | 179 // The browser process only wants to support the language Cocoa will use, |
181 // so force the app locale to be overriden with that value. | 180 // so force the app locale to be overriden with that value. |
182 l10n_util::OverrideLocaleWithCocoaLocale(); | 181 l10n_util::OverrideLocaleWithCocoaLocale(); |
| 182 } |
183 | 183 |
184 // Before we load the nib, we need to start up the resource bundle so we | 184 // Before we load the nib, we need to start up the resource bundle so we |
185 // have the strings avaiable for localization. | 185 // have the strings avaiable for localization. |
186 // TODO(markusheintz): Read preference pref::kApplicationLocale in order | 186 // TODO(markusheintz): Read preference pref::kApplicationLocale in order |
187 // to enforce the application locale. | 187 // to enforce the application locale. |
188 const std::string loaded_locale = | 188 const std::string loaded_locale = |
189 ResourceBundle::InitSharedInstanceWithLocale(std::string(), NULL); | 189 ResourceBundle::InitSharedInstanceWithLocale(std::string(), NULL); |
190 CHECK(!loaded_locale.empty()) << "Default locale could not be found"; | 190 CHECK(!loaded_locale.empty()) << "Default locale could not be found"; |
191 | 191 |
192 base::FilePath resources_pack_path; | 192 base::FilePath resources_pack_path; |
193 PathService::Get(chrome::FILE_RESOURCES_PACK, &resources_pack_path); | 193 PathService::Get(chrome::FILE_RESOURCES_PACK, &resources_pack_path); |
194 ResourceBundle::GetSharedInstance().AddDataPackFromPath( | 194 ResourceBundle::GetSharedInstance().AddDataPackFromPath( |
195 resources_pack_path, ui::SCALE_FACTOR_NONE); | 195 resources_pack_path, ui::SCALE_FACTOR_NONE); |
196 } | |
197 | 196 |
198 // This is a no-op if the KeystoneRegistration framework is not present. | 197 // This is a no-op if the KeystoneRegistration framework is not present. |
199 // The framework is only distributed with branded Google Chrome builds. | 198 // The framework is only distributed with branded Google Chrome builds. |
200 [[KeystoneGlue defaultKeystoneGlue] registerWithKeystone]; | 199 [[KeystoneGlue defaultKeystoneGlue] registerWithKeystone]; |
201 | 200 |
202 // Disk image installation is sort of a first-run task, so it shares the | 201 // Disk image installation is sort of a first-run task, so it shares the |
203 // no first run switches. | 202 // no first run switches. |
204 // | 203 // |
205 // This needs to be done after the resource bundle is initialized (for | 204 // This needs to be done after the resource bundle is initialized (for |
206 // access to localizations in the UI) and after Keystone is initialized | 205 // access to localizations in the UI) and after Keystone is initialized |
(...skipping 40 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
247 void ChromeBrowserMainPartsMac::PostProfileInit() { | 246 void ChromeBrowserMainPartsMac::PostProfileInit() { |
248 ChromeBrowserMainPartsPosix::PostProfileInit(); | 247 ChromeBrowserMainPartsPosix::PostProfileInit(); |
249 g_browser_process->metrics_service()->RecordBreakpadRegistration( | 248 g_browser_process->metrics_service()->RecordBreakpadRegistration( |
250 breakpad::IsCrashReporterEnabled()); | 249 breakpad::IsCrashReporterEnabled()); |
251 } | 250 } |
252 | 251 |
253 void ChromeBrowserMainPartsMac::DidEndMainMessageLoop() { | 252 void ChromeBrowserMainPartsMac::DidEndMainMessageLoop() { |
254 AppController* appController = [NSApp delegate]; | 253 AppController* appController = [NSApp delegate]; |
255 [appController didEndMainMessageLoop]; | 254 [appController didEndMainMessageLoop]; |
256 } | 255 } |
OLD | NEW |