blob: 8ed837f8397f3a8d5f7ec943a8105f554261846a (
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
91
92
|
// 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 "chrome/browser/browser_main.h"
#import <Cocoa/Cocoa.h>
#include "app/resource_bundle.h"
#include "base/command_line.h"
#include "base/debug_util.h"
#include "chrome/app/breakpad_mac.h"
#import "chrome/app/keystone_glue.h"
#import "chrome/browser/app_controller_mac.h"
#include "chrome/browser/browser_main_win.h"
#import "chrome/browser/chrome_application_mac.h"
#include "chrome/browser/metrics/metrics_service.h"
#include "chrome/common/main_function_params.h"
#include "chrome/common/result_codes.h"
namespace Platform {
// Tell 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 MainFunctionParams& parameters) {
// Initialize NSApplication using the custom subclass. Check whether NSApp
// was already initialized using another class, because that would break
// some things.
[CrApplication sharedApplication];
if (![NSApp isKindOfClass:[CrApplication class]]) {
LOG(ERROR) << "NSApp should be of type CrApplication, not "
<< [[NSApp className] UTF8String];
DCHECK(false) << "NSApp is of wrong type";
}
// Before we load the nib, we need to start up the resource bundle so we have
// the strings avaiable for localization.
if (!parameters.ui_task) {
ResourceBundle::InitSharedInstance(std::wstring());
// We only load the theme resources in the browser process, since this is
// the browser process, load them.
ResourceBundle::GetSharedInstance().LoadThemeResources();
}
// Now load the nib.
[NSBundle loadNibNamed:@"MainMenu" owner:NSApp];
// This is a no-op if the KeystoneRegistration framework is not present.
// The framework is only distributed with branded Google Chrome builds.
[[KeystoneGlue defaultKeystoneGlue] registerWithKeystone];
}
void DidEndMainMessageLoop() {
AppController* appController = [NSApp delegate];
[appController didEndMainMessageLoop];
}
void RecordBreakpadStatusUMA(MetricsService* metrics) {
metrics->RecordBreakpadRegistration(IsCrashReporterEnabled());
metrics->RecordBreakpadHasDebugger(DebugUtil::BeingDebugged());
}
} // namespace Platform
// 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 false;
}
bool CheckForWin2000() {
return false;
}
int HandleIconsCommands(const CommandLine& parsed_command_line) {
return 0;
}
bool CheckMachineLevelInstall() {
return false;
}
void PrepareRestartOnCrashEnviroment(const CommandLine& parsed_command_line) {
}
|