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

Side by Side Diff: extensions/shell/app/shell_main_delegate.cc

Issue 437503004: Add NaCl support to app_shell (Closed) Base URL: svn://svn.chromium.org/chrome/trunk/src
Patch Set: (nacl-init) rebase Created 6 years, 4 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 | « extensions/shell/app/shell_main_delegate.h ('k') | extensions/shell/app_shell.gyp » ('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 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 #include "extensions/shell/app/shell_main_delegate.h" 5 #include "extensions/shell/app/shell_main_delegate.h"
6 6
7 #include "base/command_line.h" 7 #include "base/command_line.h"
8 #include "base/files/file_path.h" 8 #include "base/files/file_path.h"
9 #include "base/logging.h" 9 #include "base/logging.h"
10 #include "base/path_service.h" 10 #include "base/path_service.h"
11 #include "content/public/browser/browser_main_runner.h" 11 #include "content/public/browser/browser_main_runner.h"
12 #include "content/public/common/content_switches.h" 12 #include "content/public/common/content_switches.h"
13 #include "extensions/common/extension_paths.h" 13 #include "extensions/common/extension_paths.h"
14 #include "extensions/shell/browser/default_shell_browser_main_delegate.h" 14 #include "extensions/shell/browser/default_shell_browser_main_delegate.h"
15 #include "extensions/shell/browser/shell_content_browser_client.h" 15 #include "extensions/shell/browser/shell_content_browser_client.h"
16 #include "extensions/shell/common/shell_content_client.h" 16 #include "extensions/shell/common/shell_content_client.h"
17 #include "extensions/shell/renderer/shell_content_renderer_client.h" 17 #include "extensions/shell/renderer/shell_content_renderer_client.h"
18 #include "extensions/shell/renderer/shell_renderer_main_delegate.h" 18 #include "extensions/shell/renderer/shell_renderer_main_delegate.h"
19 #include "ui/base/resource/resource_bundle.h" 19 #include "ui/base/resource/resource_bundle.h"
20 20
21 #if defined(OS_CHROMEOS) 21 #if defined(OS_CHROMEOS)
22 #include "chromeos/chromeos_paths.h" 22 #include "chromeos/chromeos_paths.h"
23 #endif 23 #endif
24 24
25 #if !defined(DISABLE_NACL)
26 #include "components/nacl/common/nacl_paths.h"
27 #include "components/nacl/common/nacl_switches.h"
28 #include "components/nacl/zygote/nacl_fork_delegate_linux.h"
29 #endif
30
25 namespace { 31 namespace {
26 32
27 void InitLogging() { 33 void InitLogging() {
28 base::FilePath log_filename; 34 base::FilePath log_filename;
29 PathService::Get(base::DIR_EXE, &log_filename); 35 PathService::Get(base::DIR_EXE, &log_filename);
30 log_filename = log_filename.AppendASCII("app_shell.log"); 36 log_filename = log_filename.AppendASCII("app_shell.log");
31 logging::LoggingSettings settings; 37 logging::LoggingSettings settings;
32 settings.logging_dest = logging::LOG_TO_ALL; 38 settings.logging_dest = logging::LOG_TO_ALL;
33 settings.log_file = log_filename.value().c_str(); 39 settings.log_file = log_filename.value().c_str();
34 settings.delete_old = logging::DELETE_OLD_LOG_FILE; 40 settings.delete_old = logging::DELETE_OLD_LOG_FILE;
(...skipping 12 matching lines...) Expand all
47 } 53 }
48 54
49 bool ShellMainDelegate::BasicStartupComplete(int* exit_code) { 55 bool ShellMainDelegate::BasicStartupComplete(int* exit_code) {
50 InitLogging(); 56 InitLogging();
51 content_client_.reset(new ShellContentClient); 57 content_client_.reset(new ShellContentClient);
52 SetContentClient(content_client_.get()); 58 SetContentClient(content_client_.get());
53 59
54 #if defined(OS_CHROMEOS) 60 #if defined(OS_CHROMEOS)
55 chromeos::RegisterPathProvider(); 61 chromeos::RegisterPathProvider();
56 #endif 62 #endif
63 #if !defined(DISABLE_NACL)
64 nacl::RegisterPathProvider();
65 #endif
57 extensions::RegisterPathProvider(); 66 extensions::RegisterPathProvider();
58 return false; 67 return false;
59 } 68 }
60 69
61 void ShellMainDelegate::PreSandboxStartup() { 70 void ShellMainDelegate::PreSandboxStartup() {
62 std::string process_type = 71 std::string process_type =
63 CommandLine::ForCurrentProcess()->GetSwitchValueASCII( 72 CommandLine::ForCurrentProcess()->GetSwitchValueASCII(
64 switches::kProcessType); 73 switches::kProcessType);
65 if (ProcessNeedsResourceBundle(process_type)) 74 if (ProcessNeedsResourceBundle(process_type))
66 InitializeResourceBundle(); 75 InitializeResourceBundle();
67 } 76 }
68 77
69 content::ContentBrowserClient* ShellMainDelegate::CreateContentBrowserClient() { 78 content::ContentBrowserClient* ShellMainDelegate::CreateContentBrowserClient() {
70 browser_client_.reset(CreateShellContentBrowserClient()); 79 browser_client_.reset(CreateShellContentBrowserClient());
71 return browser_client_.get(); 80 return browser_client_.get();
72 } 81 }
73 82
74 content::ContentBrowserClient* 83 content::ContentBrowserClient*
75 ShellMainDelegate::CreateShellContentBrowserClient() { 84 ShellMainDelegate::CreateShellContentBrowserClient() {
76 return new ShellContentBrowserClient(new DefaultShellBrowserMainDelegate()); 85 return new ShellContentBrowserClient(new DefaultShellBrowserMainDelegate());
77 } 86 }
78 87
79 content::ContentRendererClient* 88 content::ContentRendererClient*
80 ShellMainDelegate::CreateContentRendererClient() { 89 ShellMainDelegate::CreateContentRendererClient() {
81 renderer_client_.reset( 90 renderer_client_.reset(
82 new ShellContentRendererClient(CreateShellRendererMainDelegate())); 91 new ShellContentRendererClient(CreateShellRendererMainDelegate()));
83 return renderer_client_.get(); 92 return renderer_client_.get();
84 } 93 }
85 94
95 void ShellMainDelegate::ZygoteStarting(
96 ScopedVector<content::ZygoteForkDelegate>* delegates) {
97 #if !defined(DISABLE_NACL)
98 nacl::AddNaClZygoteForkDelegates(delegates);
99 #endif
100 }
101
86 scoped_ptr<ShellRendererMainDelegate> 102 scoped_ptr<ShellRendererMainDelegate>
87 ShellMainDelegate::CreateShellRendererMainDelegate() { 103 ShellMainDelegate::CreateShellRendererMainDelegate() {
88 return scoped_ptr<ShellRendererMainDelegate>(); 104 return scoped_ptr<ShellRendererMainDelegate>();
89 } 105 }
90 106
91 void ShellMainDelegate::InitializeResourceBundle() { 107 void ShellMainDelegate::InitializeResourceBundle() {
92 base::FilePath extensions_shell_and_test_pak_path; 108 base::FilePath extensions_shell_and_test_pak_path;
93 PathService::Get(base::DIR_MODULE, &extensions_shell_and_test_pak_path); 109 PathService::Get(base::DIR_MODULE, &extensions_shell_and_test_pak_path);
94 ui::ResourceBundle::InitSharedInstanceWithPakPath( 110 ui::ResourceBundle::InitSharedInstanceWithPakPath(
95 extensions_shell_and_test_pak_path.AppendASCII( 111 extensions_shell_and_test_pak_path.AppendASCII(
96 "extensions_shell_and_test.pak")); 112 "extensions_shell_and_test.pak"));
97 } 113 }
98 114
99 // static 115 // static
100 bool ShellMainDelegate::ProcessNeedsResourceBundle( 116 bool ShellMainDelegate::ProcessNeedsResourceBundle(
101 const std::string& process_type) { 117 const std::string& process_type) {
102 // The browser process has no process type flag, but needs resources. 118 // The browser process has no process type flag, but needs resources.
103 // On Linux the zygote process opens the resources for the renderers. 119 // On Linux the zygote process opens the resources for the renderers.
104 return process_type.empty() || 120 return process_type.empty() ||
105 process_type == switches::kZygoteProcess || 121 process_type == switches::kZygoteProcess ||
106 process_type == switches::kRendererProcess || 122 process_type == switches::kRendererProcess ||
123 #if !defined(DISABLE_NACL)
124 process_type == switches::kNaClLoaderProcess ||
125 #endif
107 process_type == switches::kUtilityProcess; 126 process_type == switches::kUtilityProcess;
108 } 127 }
109 128
110 } // namespace extensions 129 } // namespace extensions
OLDNEW
« no previous file with comments | « extensions/shell/app/shell_main_delegate.h ('k') | extensions/shell/app_shell.gyp » ('j') | no next file with comments »

Powered by Google App Engine
This is Rietveld 408576698