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