Chromium Code Reviews
chromiumcodereview-hr@appspot.gserviceaccount.com (chromiumcodereview-hr) | Please choose your nickname with Settings | Help | Chromium Project | Gerrit Changes | Sign out
(90)

Side by Side Diff: chrome/browser/browser_main_mac.mm

Issue 201121: Chrome should shut down cleanly when quit from the Dock icon menu, during... (Closed) Base URL: svn://svn.chromium.org/chrome/trunk/src/
Patch Set: '' Created 11 years, 3 months ago
Use n/p to move between diff chunks; N/P to move between comments. Draft comments are only viewable by you.
Jump to:
View unified diff | Download patch | Annotate | Revision Log
« no previous file with comments | « chrome/browser/browser_main_gtk.cc ('k') | chrome/browser/browser_main_win.cc » ('j') | no next file with comments »
Toggle Intra-line Diffs ('i') | Expand Comments ('e') | Collapse Comments ('c') | Show Comments Hide Comments ('s')
OLDNEW
1 // Copyright (c) 2008 The Chromium Authors. All rights reserved. 1 // Copyright (c) 2008 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/browser_main.h" 5 #include "chrome/browser/browser_main.h"
6 6
7 #import <Cocoa/Cocoa.h> 7 #import <Cocoa/Cocoa.h>
8 8
9 #include "app/resource_bundle.h" 9 #include "app/resource_bundle.h"
10 #include "base/command_line.h" 10 #include "base/command_line.h"
11 #include "base/debug_util.h" 11 #include "base/debug_util.h"
12 #include "chrome/app/breakpad_mac.h" 12 #include "chrome/app/breakpad_mac.h"
13 #import "chrome/app/keystone_glue.h" 13 #import "chrome/app/keystone_glue.h"
14 #import "chrome/browser/app_controller_mac.h"
14 #include "chrome/browser/browser_main_win.h" 15 #include "chrome/browser/browser_main_win.h"
16 #import "chrome/browser/chrome_application_mac.h"
15 #include "chrome/browser/metrics/metrics_service.h" 17 #include "chrome/browser/metrics/metrics_service.h"
16 #include "chrome/common/main_function_params.h" 18 #include "chrome/common/main_function_params.h"
17 #include "chrome/common/result_codes.h" 19 #include "chrome/common/result_codes.h"
18 20
19 namespace Platform { 21 namespace Platform {
20 22
21 // Perform any platform-specific work that needs to be done before the main 23 // Tell Cooca to finish its initalization, which we want to do manually
22 // message loop is created and initialized. 24 // instead of calling NSApplicationMain(). The primary reason is that NSAM()
23 // 25 // never returns, which would leave all the objects currently on the stack
24 // For Mac, this involves telling Cooca to finish its initalization, which we 26 // in scoped_ptrs hanging and never cleaned up. We then load the main nib
25 // want to do manually instead of calling NSApplicationMain(). The primary 27 // directly. The main event loop is run from common code using the
26 // reason is that NSAM() never returns, which would leave all the objects 28 // MessageLoop API, which works out ok for us because it's a wrapper around
27 // currently on the stack in scoped_ptrs hanging and never cleaned up. We then
28 // load the main nib directly. The main event loop is run from common code using
29 // the MessageLoop API, which works out ok for us because it's a wrapper around
30 // CFRunLoop. 29 // CFRunLoop.
31 void WillInitializeMainMessageLoop(const MainFunctionParams& parameters) { 30 void WillInitializeMainMessageLoop(const MainFunctionParams& parameters) {
32 [NSApplication sharedApplication]; 31 // Initialize NSApplication using the custom subclass. Check whether NSApp
32 // was already initialized using another class, because that would break
33 // some things.
34 [CrApplication sharedApplication];
35 if (![NSApp isKindOfClass:[CrApplication class]]) {
36 LOG(ERROR) << "NSApp should be of type CrApplication, not "
37 << [[NSApp className] UTF8String];
38 DCHECK(false) << "NSApp is of wrong type";
39 }
40
33 // Before we load the nib, we need to start up the resource bundle so we have 41 // Before we load the nib, we need to start up the resource bundle so we have
34 // the strings avaiable for localization. 42 // the strings avaiable for localization.
35 if (!parameters.ui_task) { 43 if (!parameters.ui_task) {
36 ResourceBundle::InitSharedInstance(std::wstring()); 44 ResourceBundle::InitSharedInstance(std::wstring());
37 // We only load the theme resources in the browser process, since this is 45 // We only load the theme resources in the browser process, since this is
38 // the browser process, load them. 46 // the browser process, load them.
39 ResourceBundle::GetSharedInstance().LoadThemeResources(); 47 ResourceBundle::GetSharedInstance().LoadThemeResources();
40 } 48 }
41 // Now load the nib. 49 // Now load the nib.
42 [NSBundle loadNibNamed:@"MainMenu" owner:NSApp]; 50 [NSBundle loadNibNamed:@"MainMenu" owner:NSApp];
43 51
44 // This is a no-op if the KeystoneRegistration framework is not present. 52 // This is a no-op if the KeystoneRegistration framework is not present.
45 // The framework is only distributed with branded Google Chrome builds. 53 // The framework is only distributed with branded Google Chrome builds.
46 [[KeystoneGlue defaultKeystoneGlue] registerWithKeystone]; 54 [[KeystoneGlue defaultKeystoneGlue] registerWithKeystone];
47 } 55 }
48 56
49 // Perform platform-specific work that needs to be done after the main event 57 void DidEndMainMessageLoop() {
50 // loop has ended. We need to send the notifications that Cooca normally would 58 AppController* appController = [NSApp delegate];
51 // telling everyone the app is about to end. 59 [appController didEndMainMessageLoop];
52 void WillTerminate() {
53 [[NSNotificationCenter defaultCenter]
54 postNotificationName:NSApplicationWillTerminateNotification
55 object:NSApp];
56 } 60 }
57 61
58 void RecordBreakpadStatusUMA(MetricsService* metrics) { 62 void RecordBreakpadStatusUMA(MetricsService* metrics) {
59 metrics->RecordBreakpadRegistration(IsCrashReporterEnabled()); 63 metrics->RecordBreakpadRegistration(IsCrashReporterEnabled());
60 metrics->RecordBreakpadHasDebugger(DebugUtil::BeingDebugged()); 64 metrics->RecordBreakpadHasDebugger(DebugUtil::BeingDebugged());
61 } 65 }
62 66
63 } // namespace Platform 67 } // namespace Platform
64 68
65 // From browser_main_win.h, stubs until we figure out the right thing... 69 // From browser_main_win.h, stubs until we figure out the right thing...
(...skipping 13 matching lines...) Expand all
79 int HandleIconsCommands(const CommandLine& parsed_command_line) { 83 int HandleIconsCommands(const CommandLine& parsed_command_line) {
80 return 0; 84 return 0;
81 } 85 }
82 86
83 bool CheckMachineLevelInstall() { 87 bool CheckMachineLevelInstall() {
84 return false; 88 return false;
85 } 89 }
86 90
87 void PrepareRestartOnCrashEnviroment(const CommandLine& parsed_command_line) { 91 void PrepareRestartOnCrashEnviroment(const CommandLine& parsed_command_line) {
88 } 92 }
OLDNEW
« no previous file with comments | « chrome/browser/browser_main_gtk.cc ('k') | chrome/browser/browser_main_win.cc » ('j') | no next file with comments »

Powered by Google App Engine
This is Rietveld 408576698