[email protected] | 1bcdb53 | 2009-01-16 17:47:57 | [diff] [blame] | 1 | // Copyright (c) 2008 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] | 04abd506 | 2009-02-28 01:41:26 | [diff] [blame] | 5 | #include <crt_externs.h> |
[email protected] | 5c9587c | 2008-12-09 21:20:16 | [diff] [blame] | 6 | #include <Cocoa/Cocoa.h> |
7 | #include "base/command_line.h" | ||||
[email protected] | 74d1bb0 | 2009-03-03 00:41:23 | [diff] [blame] | 8 | #include "chrome/app/keystone_glue.h" |
[email protected] | 1bcdb53 | 2009-01-16 17:47:57 | [diff] [blame] | 9 | #include "chrome/browser/app_controller_mac.h" |
10 | #include "chrome/browser/browser_main_win.h" | ||||
[email protected] | 74d1bb0 | 2009-03-03 00:41:23 | [diff] [blame] | 11 | #include "chrome/common/result_codes.h" |
[email protected] | 5c9587c | 2008-12-09 21:20:16 | [diff] [blame] | 12 | |
[email protected] | 1bcdb53 | 2009-01-16 17:47:57 | [diff] [blame] | 13 | namespace Platform { |
14 | |||||
15 | // Perform and platform-specific work that needs to be done before the main | ||||
[email protected] | e5fd10f68 | 2009-02-25 04:56:21 | [diff] [blame] | 16 | // message loop is created and initialized. |
[email protected] | 1bcdb53 | 2009-01-16 17:47:57 | [diff] [blame] | 17 | // |
18 | // For Mac, this involves telling Cooca to finish its initalization, which we | ||||
19 | // want to do manually instead of calling NSApplicationMain(). The primary | ||||
20 | // reason is that NSAM() never returns, which would leave all the objects | ||||
21 | // currently on the stack in scoped_ptrs hanging and never cleaned up. We then | ||||
22 | // load the main nib directly. The main event loop is run from common code using | ||||
23 | // the MessageLoop API, which works out ok for us because it's a wrapper around | ||||
24 | // CFRunLoop. | ||||
25 | void WillInitializeMainMessageLoop(const CommandLine & command_line) { | ||||
26 | [NSApplication sharedApplication]; | ||||
27 | [NSBundle loadNibNamed:@"MainMenu" owner:NSApp]; | ||||
[email protected] | e5fd10f68 | 2009-02-25 04:56:21 | [diff] [blame] | 28 | |
[email protected] | 04abd506 | 2009-02-28 01:41:26 | [diff] [blame] | 29 | // Doesn't need to be in a GOOGLE_CHROME_BUILD since this references |
30 | // a framework only distributed with Google Chrome. | ||||
31 | [KeystoneGlue registerWithKeystone]; | ||||
32 | |||||
[email protected] | e5fd10f68 | 2009-02-25 04:56:21 | [diff] [blame] | 33 | // TODO(port): Use of LSUIElement=1 is a temporary fix. The right |
34 | // answer is to fix the renderer to not use Cocoa. | ||||
35 | // | ||||
36 | // Chromium.app currently as LSUIElement=1 in it's Info.plist. This | ||||
37 | // allows subprocesses (created with a relaunch of our binary) to | ||||
38 | // create an NSApplication without showing up in the dock. | ||||
39 | // Subprocesses (such as the renderer) need an NSApplication for | ||||
40 | // Cocoa happiness However, for the browser itself, we DO want it in | ||||
41 | // the dock. These 3 lines make it happen. | ||||
[email protected] | 4c8e0e0 | 2009-02-25 19:20:28 | [diff] [blame] | 42 | // |
43 | // Real fix tracked by http://code.google.com/p/chromium/issues/detail?id=8044 | ||||
[email protected] | e5fd10f68 | 2009-02-25 04:56:21 | [diff] [blame] | 44 | ProcessSerialNumber psn; |
45 | GetCurrentProcess(&psn); | ||||
[email protected] | 4c8e0e0 | 2009-02-25 19:20:28 | [diff] [blame] | 46 | TransformProcessType(&psn, kProcessTransformToForegroundApplication); |
47 | // Fix the menubar. Ugly. To be removed along with the rest of the | ||||
48 | // LSUIElement stuff. | ||||
49 | [NSApp deactivate]; | ||||
50 | [NSApp activateIgnoringOtherApps:YES]; | ||||
[email protected] | 1bcdb53 | 2009-01-16 17:47:57 | [diff] [blame] | 51 | } |
52 | |||||
53 | // Perform platform-specific work that needs to be done after the main event | ||||
54 | // loop has ended. We need to send the notifications that Cooca normally would | ||||
55 | // telling everyone the app is about to end. | ||||
56 | void WillTerminate() { | ||||
[email protected] | e5fd10f68 | 2009-02-25 04:56:21 | [diff] [blame] | 57 | [[NSNotificationCenter defaultCenter] |
[email protected] | 1bcdb53 | 2009-01-16 17:47:57 | [diff] [blame] | 58 | postNotificationName:NSApplicationWillTerminateNotification |
59 | object:NSApp]; | ||||
60 | } | ||||
61 | |||||
62 | } | ||||
63 | |||||
64 | // From browser_main_win.h, stubs until we figure out the right thing... | ||||
65 | |||||
[email protected] | 53c38d23 | 2009-02-13 20:52:18 | [diff] [blame] | 66 | int DoUninstallTasks(bool chrome_still_running) { |
[email protected] | 1bcdb53 | 2009-01-16 17:47:57 | [diff] [blame] | 67 | return ResultCodes::NORMAL_EXIT; |
68 | } | ||||
69 | |||||
70 | bool DoUpgradeTasks(const CommandLine& command_line) { | ||||
71 | return ResultCodes::NORMAL_EXIT; | ||||
72 | } | ||||
73 | |||||
74 | bool CheckForWin2000() { | ||||
75 | return false; | ||||
76 | } | ||||
77 | |||||
78 | int HandleIconsCommands(const CommandLine &parsed_command_line) { | ||||
79 | return 0; | ||||
80 | } | ||||
81 | |||||
82 | bool CheckMachineLevelInstall() { | ||||
83 | return false; | ||||
84 | } | ||||
85 | |||||
86 | void PrepareRestartOnCrashEnviroment(const CommandLine &parsed_command_line) { | ||||
87 | } | ||||
88 | |||||
89 | void RecordBreakpadStatusUMA(MetricsService* metrics) { | ||||
[email protected] | 5c9587c | 2008-12-09 21:20:16 | [diff] [blame] | 90 | } |