OLD | NEW |
1 // Copyright 2013 The Chromium Authors. All rights reserved. | 1 // Copyright 2013 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 "apps/shell/app/shell_main_delegate.h" | 5 #include "apps/shell/app/shell_main_delegate.h" |
6 | 6 |
7 #include "apps/shell/browser/shell_content_browser_client.h" | 7 #include "apps/shell/browser/shell_content_browser_client.h" |
8 #include "apps/shell/common/shell_content_client.h" | 8 #include "apps/shell/common/shell_content_client.h" |
| 9 #include "apps/shell/common/shell_delegate.h" |
9 #include "apps/shell/renderer/shell_content_renderer_client.h" | 10 #include "apps/shell/renderer/shell_content_renderer_client.h" |
10 #include "base/command_line.h" | 11 #include "base/command_line.h" |
11 #include "base/files/file_path.h" | 12 #include "base/files/file_path.h" |
12 #include "base/logging.h" | 13 #include "base/logging.h" |
13 #include "base/path_service.h" | 14 #include "base/path_service.h" |
14 #include "content/public/browser/browser_main_runner.h" | 15 #include "content/public/browser/browser_main_runner.h" |
15 #include "content/public/common/content_switches.h" | 16 #include "content/public/common/content_switches.h" |
16 #include "extensions/common/extension_paths.h" | 17 #include "extensions/common/extension_paths.h" |
17 #include "ui/base/resource/resource_bundle.h" | 18 #include "ui/base/resource/resource_bundle.h" |
18 | 19 |
(...skipping 12 matching lines...) Expand all Loading... |
31 settings.log_file = log_filename.value().c_str(); | 32 settings.log_file = log_filename.value().c_str(); |
32 settings.delete_old = logging::DELETE_OLD_LOG_FILE; | 33 settings.delete_old = logging::DELETE_OLD_LOG_FILE; |
33 logging::InitLogging(settings); | 34 logging::InitLogging(settings); |
34 logging::SetLogItems(true, true, true, true); | 35 logging::SetLogItems(true, true, true, true); |
35 } | 36 } |
36 | 37 |
37 } // namespace | 38 } // namespace |
38 | 39 |
39 namespace apps { | 40 namespace apps { |
40 | 41 |
41 ShellMainDelegate::ShellMainDelegate() { | 42 ShellMainDelegate::ShellMainDelegate(ShellDelegate* shell_delegate) |
| 43 : shell_delegate_(shell_delegate) { |
42 } | 44 } |
43 | 45 |
44 ShellMainDelegate::~ShellMainDelegate() { | 46 ShellMainDelegate::~ShellMainDelegate() { |
45 } | 47 } |
46 | 48 |
47 bool ShellMainDelegate::BasicStartupComplete(int* exit_code) { | 49 bool ShellMainDelegate::BasicStartupComplete(int* exit_code) { |
48 InitLogging(); | 50 InitLogging(); |
49 content_client_.reset(new ShellContentClient); | 51 content_client_.reset(new ShellContentClient); |
50 SetContentClient(content_client_.get()); | 52 SetContentClient(content_client_.get()); |
51 | 53 |
52 #if defined(OS_CHROMEOS) | 54 #if defined(OS_CHROMEOS) |
53 chromeos::RegisterPathProvider(); | 55 chromeos::RegisterPathProvider(); |
54 #endif | 56 #endif |
55 extensions::RegisterPathProvider(); | 57 extensions::RegisterPathProvider(); |
56 return false; | 58 return false; |
57 } | 59 } |
58 | 60 |
59 void ShellMainDelegate::PreSandboxStartup() { | 61 void ShellMainDelegate::PreSandboxStartup() { |
60 std::string process_type = | 62 std::string process_type = |
61 CommandLine::ForCurrentProcess()->GetSwitchValueASCII( | 63 CommandLine::ForCurrentProcess()->GetSwitchValueASCII( |
62 switches::kProcessType); | 64 switches::kProcessType); |
63 if (ProcessNeedsResourceBundle(process_type)) | 65 if (ProcessNeedsResourceBundle(process_type)) |
64 InitializeResourceBundle(); | 66 InitializeResourceBundle(); |
65 } | 67 } |
66 | 68 |
67 content::ContentBrowserClient* ShellMainDelegate::CreateContentBrowserClient() { | 69 content::ContentBrowserClient* ShellMainDelegate::CreateContentBrowserClient() { |
68 browser_client_.reset(new apps::ShellContentBrowserClient); | 70 browser_client_.reset(new apps::ShellContentBrowserClient(shell_delegate_)); |
69 return browser_client_.get(); | 71 return browser_client_.get(); |
70 } | 72 } |
71 | 73 |
72 content::ContentRendererClient* | 74 content::ContentRendererClient* |
73 ShellMainDelegate::CreateContentRendererClient() { | 75 ShellMainDelegate::CreateContentRendererClient() { |
74 renderer_client_.reset(new ShellContentRendererClient); | 76 renderer_client_.reset(new ShellContentRendererClient); |
75 return renderer_client_.get(); | 77 return renderer_client_.get(); |
76 } | 78 } |
77 | 79 |
78 // static | 80 // static |
79 bool ShellMainDelegate::ProcessNeedsResourceBundle( | 81 bool ShellMainDelegate::ProcessNeedsResourceBundle( |
80 const std::string& process_type) { | 82 const std::string& process_type) { |
81 // The browser process has no process type flag, but needs resources. | 83 // The browser process has no process type flag, but needs resources. |
82 // On Linux the zygote process opens the resources for the renderers. | 84 // On Linux the zygote process opens the resources for the renderers. |
83 return process_type.empty() || | 85 return process_type.empty() || |
84 process_type == switches::kZygoteProcess || | 86 process_type == switches::kZygoteProcess || |
85 process_type == switches::kRendererProcess || | 87 process_type == switches::kRendererProcess || |
86 process_type == switches::kUtilityProcess; | 88 process_type == switches::kUtilityProcess; |
87 } | 89 } |
88 | 90 |
89 void ShellMainDelegate::InitializeResourceBundle() { | 91 void ShellMainDelegate::InitializeResourceBundle() { |
90 base::FilePath pak_dir; | 92 base::FilePath pak_dir; |
91 PathService::Get(base::DIR_MODULE, &pak_dir); | 93 PathService::Get(base::DIR_MODULE, &pak_dir); |
92 ui::ResourceBundle::InitSharedInstanceWithPakPath( | 94 ui::ResourceBundle::InitSharedInstanceWithPakPath( |
93 pak_dir.AppendASCII("app_shell.pak")); | 95 pak_dir.AppendASCII("app_shell.pak")); |
94 } | 96 } |
95 | 97 |
96 } // namespace apps | 98 } // namespace apps |
OLD | NEW |