blob: 458d54d2d8c97935ab1ed28bed2957cae1239ab8 [file] [log] [blame]
[email protected]1bcdb532009-01-16 17:47:571// Copyright (c) 2008 The Chromium Authors. All rights reserved.
[email protected]5c9587c2008-12-09 21:20:162// Use of this source code is governed by a BSD-style license that can be
3// found in the LICENSE file.
4
[email protected]04abd5062009-02-28 01:41:265#include <crt_externs.h>
[email protected]5c9587c2008-12-09 21:20:166#include <Cocoa/Cocoa.h>
7#include "base/command_line.h"
[email protected]74d1bb02009-03-03 00:41:238#include "chrome/app/keystone_glue.h"
[email protected]1bcdb532009-01-16 17:47:579#include "chrome/browser/app_controller_mac.h"
10#include "chrome/browser/browser_main_win.h"
[email protected]74d1bb02009-03-03 00:41:2311#include "chrome/common/result_codes.h"
[email protected]5c9587c2008-12-09 21:20:1612
[email protected]1bcdb532009-01-16 17:47:5713namespace Platform {
14
15// Perform and platform-specific work that needs to be done before the main
[email protected]e5fd10f682009-02-25 04:56:2116// message loop is created and initialized.
[email protected]1bcdb532009-01-16 17:47:5717//
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.
25void WillInitializeMainMessageLoop(const CommandLine & command_line) {
26 [NSApplication sharedApplication];
27 [NSBundle loadNibNamed:@"MainMenu" owner:NSApp];
[email protected]e5fd10f682009-02-25 04:56:2128
[email protected]04abd5062009-02-28 01:41:2629 // 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]e5fd10f682009-02-25 04:56:2133 // 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]4c8e0e02009-02-25 19:20:2842 //
43 // Real fix tracked by http://code.google.com/p/chromium/issues/detail?id=8044
[email protected]e5fd10f682009-02-25 04:56:2144 ProcessSerialNumber psn;
45 GetCurrentProcess(&psn);
[email protected]4c8e0e02009-02-25 19:20:2846 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]1bcdb532009-01-16 17:47:5751}
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.
56void WillTerminate() {
[email protected]e5fd10f682009-02-25 04:56:2157 [[NSNotificationCenter defaultCenter]
[email protected]1bcdb532009-01-16 17:47:5758 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]53c38d232009-02-13 20:52:1866int DoUninstallTasks(bool chrome_still_running) {
[email protected]1bcdb532009-01-16 17:47:5767 return ResultCodes::NORMAL_EXIT;
68}
69
70bool DoUpgradeTasks(const CommandLine& command_line) {
71 return ResultCodes::NORMAL_EXIT;
72}
73
74bool CheckForWin2000() {
75 return false;
76}
77
78int HandleIconsCommands(const CommandLine &parsed_command_line) {
79 return 0;
80}
81
82bool CheckMachineLevelInstall() {
83 return false;
84}
85
86void PrepareRestartOnCrashEnviroment(const CommandLine &parsed_command_line) {
87}
88
89void RecordBreakpadStatusUMA(MetricsService* metrics) {
[email protected]5c9587c2008-12-09 21:20:1690}