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/renderer/shell_content_renderer_client.h" | 9 #include "apps/shell/renderer/shell_content_renderer_client.h" |
10 #include "base/command_line.h" | 10 #include "base/command_line.h" |
(...skipping 20 matching lines...) Expand all Loading... |
31 settings.log_file = log_filename.value().c_str(); | 31 settings.log_file = log_filename.value().c_str(); |
32 settings.delete_old = logging::DELETE_OLD_LOG_FILE; | 32 settings.delete_old = logging::DELETE_OLD_LOG_FILE; |
33 logging::InitLogging(settings); | 33 logging::InitLogging(settings); |
34 logging::SetLogItems(true, true, true, true); | 34 logging::SetLogItems(true, true, true, true); |
35 } | 35 } |
36 | 36 |
37 } // namespace | 37 } // namespace |
38 | 38 |
39 namespace apps { | 39 namespace apps { |
40 | 40 |
41 ShellMainDelegate::ShellMainDelegate() { | 41 ShellMainDelegate::ShellMainDelegate( |
| 42 ShellBrowserMainDelegate* browser_main_delegate) |
| 43 : browser_main_delegate_(browser_main_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( |
| 71 new apps::ShellContentBrowserClient(browser_main_delegate_)); |
69 return browser_client_.get(); | 72 return browser_client_.get(); |
70 } | 73 } |
71 | 74 |
72 content::ContentRendererClient* | 75 content::ContentRendererClient* |
73 ShellMainDelegate::CreateContentRendererClient() { | 76 ShellMainDelegate::CreateContentRendererClient() { |
74 renderer_client_.reset(new ShellContentRendererClient); | 77 renderer_client_.reset(new ShellContentRendererClient); |
75 return renderer_client_.get(); | 78 return renderer_client_.get(); |
76 } | 79 } |
77 | 80 |
78 // static | 81 // static |
79 bool ShellMainDelegate::ProcessNeedsResourceBundle( | 82 bool ShellMainDelegate::ProcessNeedsResourceBundle( |
80 const std::string& process_type) { | 83 const std::string& process_type) { |
81 // The browser process has no process type flag, but needs resources. | 84 // The browser process has no process type flag, but needs resources. |
82 // On Linux the zygote process opens the resources for the renderers. | 85 // On Linux the zygote process opens the resources for the renderers. |
83 return process_type.empty() || | 86 return process_type.empty() || |
84 process_type == switches::kZygoteProcess || | 87 process_type == switches::kZygoteProcess || |
85 process_type == switches::kRendererProcess || | 88 process_type == switches::kRendererProcess || |
86 process_type == switches::kUtilityProcess; | 89 process_type == switches::kUtilityProcess; |
87 } | 90 } |
88 | 91 |
89 void ShellMainDelegate::InitializeResourceBundle() { | 92 void ShellMainDelegate::InitializeResourceBundle() { |
90 base::FilePath pak_dir; | 93 base::FilePath pak_dir; |
91 PathService::Get(base::DIR_MODULE, &pak_dir); | 94 PathService::Get(base::DIR_MODULE, &pak_dir); |
92 ui::ResourceBundle::InitSharedInstanceWithPakPath( | 95 ui::ResourceBundle::InitSharedInstanceWithPakPath( |
93 pak_dir.AppendASCII("app_shell.pak")); | 96 pak_dir.AppendASCII("app_shell.pak")); |
94 } | 97 } |
95 | 98 |
96 } // namespace apps | 99 } // namespace apps |
OLD | NEW |