OLD | NEW |
1 // Copyright 2014 The Chromium Authors. All rights reserved. | 1 // Copyright 2014 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 #import <Cocoa/Cocoa.h> | 5 #import <Cocoa/Cocoa.h> |
6 | 6 |
7 #include "base/files/file_path.h" | 7 #include "base/files/file_path.h" |
8 #include "base/mac/scoped_nsobject.h" | 8 #include "base/mac/scoped_nsobject.h" |
9 #include "base/path_service.h" | 9 #include "base/path_service.h" |
| 10 #include "content/public/browser/plugin_service.h" |
10 #include "content/public/common/content_paths.h" | 11 #include "content/public/common/content_paths.h" |
11 #include "content/shell/browser/shell_browser_context.h" | 12 #include "content/shell/browser/shell_browser_context.h" |
12 #include "ui/views_content_client/views_content_client.h" | 13 #include "ui/views_content_client/views_content_client.h" |
13 #include "ui/views_content_client/views_content_client_main_parts.h" | 14 #include "ui/views_content_client/views_content_client_main_parts.h" |
14 | 15 |
15 // A simple NSApplicationDelegate that provides a basic mainMenu and can | 16 // A simple NSApplicationDelegate that provides a basic mainMenu and can |
16 // activate a task when the application has finished loading. | 17 // activate a task when the application has finished loading. |
17 @interface ViewsContentClientAppController : NSObject<NSApplicationDelegate> { | 18 @interface ViewsContentClientAppController : NSObject<NSApplicationDelegate> { |
18 @private | 19 @private |
19 base::Closure task_; | 20 base::Closure task_; |
(...skipping 25 matching lines...) Expand all Loading... |
45 }; | 46 }; |
46 | 47 |
47 ViewsContentClientMainPartsMac::ViewsContentClientMainPartsMac( | 48 ViewsContentClientMainPartsMac::ViewsContentClientMainPartsMac( |
48 const content::MainFunctionParams& content_params, | 49 const content::MainFunctionParams& content_params, |
49 ViewsContentClient* views_content_client) | 50 ViewsContentClient* views_content_client) |
50 : ViewsContentClientMainParts(content_params, views_content_client) { | 51 : ViewsContentClientMainParts(content_params, views_content_client) { |
51 // Cache the child process path to avoid triggering an AssertIOAllowed. | 52 // Cache the child process path to avoid triggering an AssertIOAllowed. |
52 base::FilePath child_process_exe; | 53 base::FilePath child_process_exe; |
53 PathService::Get(content::CHILD_PROCESS_EXE, &child_process_exe); | 54 PathService::Get(content::CHILD_PROCESS_EXE, &child_process_exe); |
54 | 55 |
| 56 // Disable plugin discovery since NPAPI plugin support on Mac requires this to |
| 57 // be done in a utility process type which isn't bundled with this executable. |
| 58 content::PluginService::GetInstance()->DisablePluginsDiscoveryForTesting(); |
| 59 |
55 app_controller_.reset([[ViewsContentClientAppController alloc] init]); | 60 app_controller_.reset([[ViewsContentClientAppController alloc] init]); |
56 [[NSApplication sharedApplication] setDelegate:app_controller_]; | 61 [[NSApplication sharedApplication] setDelegate:app_controller_]; |
57 } | 62 } |
58 | 63 |
59 void ViewsContentClientMainPartsMac::PreMainMessageLoopRun() { | 64 void ViewsContentClientMainPartsMac::PreMainMessageLoopRun() { |
60 ViewsContentClientMainParts::PreMainMessageLoopRun(); | 65 ViewsContentClientMainParts::PreMainMessageLoopRun(); |
61 | 66 |
62 // On Mac, the task must be deferred to applicationDidFinishLaunching. If not, | 67 // On Mac, the task must be deferred to applicationDidFinishLaunching. If not, |
63 // the widget can activate, but (even if configured) the mainMenu won't be | 68 // the widget can activate, but (even if configured) the mainMenu won't be |
64 // ready to switch over in the OSX UI, so it will look strange. | 69 // ready to switch over in the OSX UI, so it will look strange. |
(...skipping 44 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
109 NSString* quitTitle = [@"Quit " stringByAppendingString:appName]; | 114 NSString* quitTitle = [@"Quit " stringByAppendingString:appName]; |
110 [appMenu addItemWithTitle:quitTitle | 115 [appMenu addItemWithTitle:quitTitle |
111 action:@selector(terminate:) | 116 action:@selector(terminate:) |
112 keyEquivalent:@"q"]; | 117 keyEquivalent:@"q"]; |
113 [appMenuItem setSubmenu:appMenu]; | 118 [appMenuItem setSubmenu:appMenu]; |
114 | 119 |
115 task_.Run(); | 120 task_.Run(); |
116 } | 121 } |
117 | 122 |
118 @end | 123 @end |
OLD | NEW |