| 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 "content/shell/shell_browser_main_parts.h" | 5 #include "content/shell/shell_browser_main_parts.h" |
| 6 | 6 |
| 7 #include "base/bind.h" | 7 #include "base/bind.h" |
| 8 #include "base/command_line.h" | 8 #include "base/command_line.h" |
| 9 #include "base/files/file_path.h" | 9 #include "base/files/file_path.h" |
| 10 #include "base/message_loop.h" | 10 #include "base/message_loop.h" |
| 11 #include "base/threading/thread.h" | 11 #include "base/threading/thread.h" |
| 12 #include "base/threading/thread_restrictions.h" | 12 #include "base/threading/thread_restrictions.h" |
| 13 #include "cc/base/switches.h" | 13 #include "cc/base/switches.h" |
| 14 #include "content/public/browser/plugin_service.h" |
| 14 #include "content/public/common/content_switches.h" | 15 #include "content/public/common/content_switches.h" |
| 15 #include "content/public/common/main_function_params.h" | 16 #include "content/public/common/main_function_params.h" |
| 16 #include "content/public/common/url_constants.h" | 17 #include "content/public/common/url_constants.h" |
| 17 #include "content/shell/common/shell_switches.h" | 18 #include "content/shell/common/shell_switches.h" |
| 18 #include "content/shell/shell.h" | 19 #include "content/shell/shell.h" |
| 19 #include "content/shell/shell_browser_context.h" | 20 #include "content/shell/shell_browser_context.h" |
| 20 #include "content/shell/shell_devtools_delegate.h" | 21 #include "content/shell/shell_devtools_delegate.h" |
| 22 #include "content/shell/shell_plugin_service_filter.h" |
| 21 #include "googleurl/src/gurl.h" | 23 #include "googleurl/src/gurl.h" |
| 22 #include "grit/net_resources.h" | 24 #include "grit/net_resources.h" |
| 23 #include "net/base/net_module.h" | 25 #include "net/base/net_module.h" |
| 24 #include "net/base/net_util.h" | 26 #include "net/base/net_util.h" |
| 25 #include "ui/base/resource/resource_bundle.h" | 27 #include "ui/base/resource/resource_bundle.h" |
| 26 | 28 |
| 27 #if defined(OS_ANDROID) | 29 #if defined(OS_ANDROID) |
| 28 #include "net/android/network_change_notifier_factory_android.h" | 30 #include "net/android/network_change_notifier_factory_android.h" |
| 29 #include "net/base/network_change_notifier.h" | 31 #include "net/base/network_change_notifier.h" |
| 30 #endif | 32 #endif |
| (...skipping 37 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 68 return base::StringPiece(); | 70 return base::StringPiece(); |
| 69 } | 71 } |
| 70 | 72 |
| 71 } // namespace | 73 } // namespace |
| 72 | 74 |
| 73 ShellBrowserMainParts::ShellBrowserMainParts( | 75 ShellBrowserMainParts::ShellBrowserMainParts( |
| 74 const MainFunctionParams& parameters) | 76 const MainFunctionParams& parameters) |
| 75 : BrowserMainParts(), | 77 : BrowserMainParts(), |
| 76 parameters_(parameters), | 78 parameters_(parameters), |
| 77 run_message_loop_(true), | 79 run_message_loop_(true), |
| 78 devtools_delegate_(NULL) { | 80 devtools_delegate_(NULL), |
| 81 plugin_service_filter_(NULL) { |
| 79 } | 82 } |
| 80 | 83 |
| 81 ShellBrowserMainParts::~ShellBrowserMainParts() { | 84 ShellBrowserMainParts::~ShellBrowserMainParts() { |
| 82 } | 85 } |
| 83 | 86 |
| 84 #if !defined(OS_MACOSX) | 87 #if !defined(OS_MACOSX) |
| 85 void ShellBrowserMainParts::PreMainMessageLoopStart() { | 88 void ShellBrowserMainParts::PreMainMessageLoopStart() { |
| 86 #if defined(USE_AURA) && defined(USE_X11) | 89 #if defined(USE_AURA) && defined(USE_X11) |
| 87 ui::TouchFactory::SetTouchDeviceListFromCommandLine(); | 90 ui::TouchFactory::SetTouchDeviceListFromCommandLine(); |
| 88 #endif | 91 #endif |
| (...skipping 24 matching lines...) Expand all Loading... |
| 113 net::NetModule::SetResourceProvider(PlatformResourceProvider); | 116 net::NetModule::SetResourceProvider(PlatformResourceProvider); |
| 114 | 117 |
| 115 devtools_delegate_ = new ShellDevToolsDelegate(browser_context_.get()); | 118 devtools_delegate_ = new ShellDevToolsDelegate(browser_context_.get()); |
| 116 | 119 |
| 117 if (!CommandLine::ForCurrentProcess()->HasSwitch(switches::kDumpRenderTree)) { | 120 if (!CommandLine::ForCurrentProcess()->HasSwitch(switches::kDumpRenderTree)) { |
| 118 Shell::CreateNewWindow(browser_context_.get(), | 121 Shell::CreateNewWindow(browser_context_.get(), |
| 119 GetStartupURL(), | 122 GetStartupURL(), |
| 120 NULL, | 123 NULL, |
| 121 MSG_ROUTING_NONE, | 124 MSG_ROUTING_NONE, |
| 122 gfx::Size()); | 125 gfx::Size()); |
| 126 } else { |
| 127 PluginService* plugin_service = PluginService::GetInstance(); |
| 128 plugin_service_filter_.reset(new ShellPluginServiceFilter); |
| 129 plugin_service->SetFilter(plugin_service_filter_.get()); |
| 123 } | 130 } |
| 124 | 131 |
| 125 if (parameters_.ui_task) { | 132 if (parameters_.ui_task) { |
| 126 parameters_.ui_task->Run(); | 133 parameters_.ui_task->Run(); |
| 127 delete parameters_.ui_task; | 134 delete parameters_.ui_task; |
| 128 run_message_loop_ = false; | 135 run_message_loop_ = false; |
| 129 } | 136 } |
| 130 } | 137 } |
| 131 | 138 |
| 132 bool ShellBrowserMainParts::MainMessageLoopRun(int* result_code) { | 139 bool ShellBrowserMainParts::MainMessageLoopRun(int* result_code) { |
| 133 return !run_message_loop_; | 140 return !run_message_loop_; |
| 134 } | 141 } |
| 135 | 142 |
| 136 void ShellBrowserMainParts::PostMainMessageLoopRun() { | 143 void ShellBrowserMainParts::PostMainMessageLoopRun() { |
| 137 #if defined(USE_AURA) | 144 #if defined(USE_AURA) |
| 138 Shell::PlatformExit(); | 145 Shell::PlatformExit(); |
| 139 #endif | 146 #endif |
| 140 if (devtools_delegate_) | 147 if (devtools_delegate_) |
| 141 devtools_delegate_->Stop(); | 148 devtools_delegate_->Stop(); |
| 142 browser_context_.reset(); | 149 browser_context_.reset(); |
| 143 off_the_record_browser_context_.reset(); | 150 off_the_record_browser_context_.reset(); |
| 144 } | 151 } |
| 145 | 152 |
| 146 } // namespace | 153 } // namespace |
| OLD | NEW |