| 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/aw_main_delegate.h" | 5 #include "android_webview/lib/main/aw_main_delegate.h" |
| 6 | 6 |
| 7 #include "android_webview/browser/aw_content_browser_client.h" | 7 #include "android_webview/browser/aw_content_browser_client.h" |
| 8 #include "android_webview/browser/scoped_allow_wait_for_legacy_web_view_api.h" | 8 #include "android_webview/browser/scoped_allow_wait_for_legacy_web_view_api.h" |
| 9 #include "android_webview/lib/aw_browser_dependency_factory_impl.h" | 9 #include "android_webview/lib/aw_browser_dependency_factory_impl.h" |
| 10 #include "android_webview/native/aw_geolocation_permission_context.h" | 10 #include "android_webview/native/aw_geolocation_permission_context.h" |
| 11 #include "android_webview/native/aw_quota_manager_bridge_impl.h" | 11 #include "android_webview/native/aw_quota_manager_bridge_impl.h" |
| 12 #include "android_webview/native/aw_web_contents_view_delegate.h" | 12 #include "android_webview/native/aw_web_contents_view_delegate.h" |
| 13 #include "android_webview/renderer/aw_content_renderer_client.h" | 13 #include "android_webview/renderer/aw_content_renderer_client.h" |
| 14 #include "base/command_line.h" | 14 #include "base/command_line.h" |
| 15 #include "base/lazy_instance.h" | 15 #include "base/lazy_instance.h" |
| 16 #include "base/logging.h" | 16 #include "base/logging.h" |
| 17 #include "base/memory/scoped_ptr.h" | 17 #include "base/memory/scoped_ptr.h" |
| 18 #include "base/threading/thread_restrictions.h" | 18 #include "base/threading/thread_restrictions.h" |
| 19 #include "cc/base/switches.h" | 19 #include "cc/base/switches.h" |
| 20 #include "content/public/browser/browser_main_runner.h" | 20 #include "content/public/browser/browser_main_runner.h" |
| 21 #include "content/public/browser/browser_thread.h" | 21 #include "content/public/browser/browser_thread.h" |
| 22 #include "content/public/common/content_switches.h" | 22 #include "content/public/common/content_switches.h" |
| 23 #include "content/public/common/startup_task_runner.h" |
| 23 #include "gpu/command_buffer/client/gl_in_process_context.h" | 24 #include "gpu/command_buffer/client/gl_in_process_context.h" |
| 24 #include "webkit/common/gpu/webgraphicscontext3d_in_process_command_buffer_impl.
h" | 25 #include "webkit/common/gpu/webgraphicscontext3d_in_process_command_buffer_impl.
h" |
| 25 | 26 |
| 26 namespace android_webview { | 27 namespace android_webview { |
| 27 | 28 |
| 28 namespace { | 29 namespace { |
| 29 | 30 |
| 30 // TODO(boliu): Remove this global Allow once the underlying issues are | 31 // TODO(boliu): Remove this global Allow once the underlying issues are |
| 31 // resolved - http://crbug.com/240453. See AwMainDelegate::RunProcess below. | 32 // resolved - http://crbug.com/240453. See AwMainDelegate::RunProcess below. |
| 32 base::LazyInstance<scoped_ptr<ScopedAllowWaitForLegacyWebViewApi> > | 33 base::LazyInstance<scoped_ptr<ScopedAllowWaitForLegacyWebViewApi> > |
| (...skipping 32 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 65 void AwMainDelegate::SandboxInitialized(const std::string& process_type) { | 66 void AwMainDelegate::SandboxInitialized(const std::string& process_type) { |
| 66 // TODO(torne): Adjust linux OOM score here. | 67 // TODO(torne): Adjust linux OOM score here. |
| 67 } | 68 } |
| 68 | 69 |
| 69 int AwMainDelegate::RunProcess( | 70 int AwMainDelegate::RunProcess( |
| 70 const std::string& process_type, | 71 const std::string& process_type, |
| 71 const content::MainFunctionParams& main_function_params) { | 72 const content::MainFunctionParams& main_function_params) { |
| 72 if (process_type.empty()) { | 73 if (process_type.empty()) { |
| 73 AwBrowserDependencyFactoryImpl::InstallInstance(); | 74 AwBrowserDependencyFactoryImpl::InstallInstance(); |
| 74 | 75 |
| 76 // In Webview we must run all startup tasks immediately, since applications |
| 77 // may depend on startup being complete on return from this function (or, |
| 78 // to be precise, its callers from Java). |
| 79 scoped_refptr<content::StartupTaskRunner> startup_task_runner( |
| 80 new content::StartupTaskRunner(content::StartupTaskRunner::IMMEDIATE, |
| 81 GetStartupObserver())); |
| 82 |
| 75 browser_runner_.reset(content::BrowserMainRunner::Create()); | 83 browser_runner_.reset(content::BrowserMainRunner::Create()); |
| 76 int exit_code = browser_runner_->Initialize(main_function_params); | 84 |
| 85 int exit_code = |
| 86 browser_runner_->Initialize(main_function_params, startup_task_runner); |
| 87 |
| 77 DCHECK(exit_code < 0); | 88 DCHECK(exit_code < 0); |
| 78 | 89 |
| 79 g_allow_wait_in_ui_thread.Get().reset( | 90 g_allow_wait_in_ui_thread.Get().reset( |
| 80 new ScopedAllowWaitForLegacyWebViewApi); | 91 new ScopedAllowWaitForLegacyWebViewApi); |
| 81 | 92 |
| 82 // Return 0 so that we do NOT trigger the default behavior. On Android, the | 93 // Return 0 so that we do NOT trigger the default behavior. On Android, the |
| 83 // UI message loop is managed by the Java application. | 94 // UI message loop is managed by the Java application. |
| 84 return 0; | 95 return 0; |
| 85 } | 96 } |
| 86 | 97 |
| (...skipping 28 matching lines...) Expand all Loading... |
| 115 AwBrowserContext* browser_context) { | 126 AwBrowserContext* browser_context) { |
| 116 return AwGeolocationPermissionContext::Create(browser_context); | 127 return AwGeolocationPermissionContext::Create(browser_context); |
| 117 } | 128 } |
| 118 | 129 |
| 119 content::WebContentsViewDelegate* AwMainDelegate::CreateViewDelegate( | 130 content::WebContentsViewDelegate* AwMainDelegate::CreateViewDelegate( |
| 120 content::WebContents* web_contents) { | 131 content::WebContents* web_contents) { |
| 121 return AwWebContentsViewDelegate::Create(web_contents); | 132 return AwWebContentsViewDelegate::Create(web_contents); |
| 122 } | 133 } |
| 123 | 134 |
| 124 } // namespace android_webview | 135 } // namespace android_webview |
| OLD | NEW |