OLD | NEW |
1 // Copyright (c) 2012 The Chromium Authors. All rights reserved. | 1 // Copyright (c) 2012 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 "android_webview/lib/main/webview_main_delegate.h" | 5 #include "android_webview/lib/main/webview_main_delegate.h" |
6 | 6 |
| 7 #include "android_webview/lib/aw_browser_dependency_factory_impl.h" |
| 8 #include "android_webview/lib/aw_content_browser_client.h" |
7 #include "base/lazy_instance.h" | 9 #include "base/lazy_instance.h" |
8 #include "base/logging.h" | 10 #include "base/logging.h" |
9 #include "chrome/browser/chrome_content_browser_client.h" | |
10 #include "chrome/common/chrome_paths.h" | 11 #include "chrome/common/chrome_paths.h" |
11 #include "chrome/renderer/chrome_content_renderer_client.h" | 12 #include "chrome/renderer/chrome_content_renderer_client.h" |
12 #include "content/public/browser/browser_main_runner.h" | 13 #include "content/public/browser/browser_main_runner.h" |
13 #include "content/public/common/content_client.h" | 14 #include "content/public/common/content_client.h" |
14 | 15 |
15 namespace android_webview { | 16 namespace android_webview { |
16 | 17 |
17 base::LazyInstance<chrome::ChromeContentBrowserClient> | 18 base::LazyInstance<AwContentBrowserClient> |
18 g_webview_content_browser_client = LAZY_INSTANCE_INITIALIZER; | 19 g_webview_content_browser_client = LAZY_INSTANCE_INITIALIZER; |
19 base::LazyInstance<chrome::ChromeContentRendererClient> | 20 base::LazyInstance<chrome::ChromeContentRendererClient> |
20 g_webview_content_renderer_client = LAZY_INSTANCE_INITIALIZER; | 21 g_webview_content_renderer_client = LAZY_INSTANCE_INITIALIZER; |
21 | 22 |
22 WebViewMainDelegate::WebViewMainDelegate() { | 23 WebViewMainDelegate::WebViewMainDelegate() { |
23 } | 24 } |
24 | 25 |
25 WebViewMainDelegate::~WebViewMainDelegate() { | 26 WebViewMainDelegate::~WebViewMainDelegate() { |
26 } | 27 } |
27 | 28 |
(...skipping 11 matching lines...) Expand all Loading... |
39 } | 40 } |
40 | 41 |
41 void WebViewMainDelegate::SandboxInitialized(const std::string& process_type) { | 42 void WebViewMainDelegate::SandboxInitialized(const std::string& process_type) { |
42 // TODO(torne): Adjust linux OOM score here. | 43 // TODO(torne): Adjust linux OOM score here. |
43 } | 44 } |
44 | 45 |
45 int WebViewMainDelegate::RunProcess( | 46 int WebViewMainDelegate::RunProcess( |
46 const std::string& process_type, | 47 const std::string& process_type, |
47 const content::MainFunctionParams& main_function_params) { | 48 const content::MainFunctionParams& main_function_params) { |
48 if (process_type.empty()) { | 49 if (process_type.empty()) { |
| 50 AwBrowserDependencyFactoryImpl::InstallInstance(); |
| 51 |
49 browser_runner_.reset(content::BrowserMainRunner::Create()); | 52 browser_runner_.reset(content::BrowserMainRunner::Create()); |
50 int exit_code = browser_runner_->Initialize(main_function_params); | 53 int exit_code = browser_runner_->Initialize(main_function_params); |
51 DCHECK(exit_code < 0); | 54 DCHECK(exit_code < 0); |
52 | 55 |
53 // Return 0 so that we do NOT trigger the default behavior. On Android, the | 56 // Return 0 so that we do NOT trigger the default behavior. On Android, the |
54 // UI message loop is managed by the Java application. | 57 // UI message loop is managed by the Java application. |
55 return 0; | 58 return 0; |
56 } | 59 } |
57 | 60 |
58 return -1; | 61 return -1; |
59 } | 62 } |
60 | 63 |
61 void WebViewMainDelegate::ProcessExiting(const std::string& process_type) { | 64 void WebViewMainDelegate::ProcessExiting(const std::string& process_type) { |
62 // TODO(torne): Clean up resources when we handle them. | 65 // TODO(torne): Clean up resources when we handle them. |
63 | 66 |
64 logging::CloseLogFile(); | 67 logging::CloseLogFile(); |
65 } | 68 } |
66 | 69 |
67 content::ContentBrowserClient* | 70 content::ContentBrowserClient* |
68 WebViewMainDelegate::CreateContentBrowserClient() { | 71 WebViewMainDelegate::CreateContentBrowserClient() { |
69 return &g_webview_content_browser_client.Get(); | 72 return &g_webview_content_browser_client.Get(); |
70 } | 73 } |
71 | 74 |
72 content::ContentRendererClient* | 75 content::ContentRendererClient* |
73 WebViewMainDelegate::CreateContentRendererClient() { | 76 WebViewMainDelegate::CreateContentRendererClient() { |
74 return &g_webview_content_renderer_client.Get(); | 77 return &g_webview_content_renderer_client.Get(); |
75 } | 78 } |
76 | 79 |
77 } // namespace android_webview | 80 } // namespace android_webview |
OLD | NEW |