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/string_number_conversions.h" | |
12 #include "base/threading/thread.h" | 11 #include "base/threading/thread.h" |
13 #include "base/threading/thread_restrictions.h" | 12 #include "base/threading/thread_restrictions.h" |
14 #include "cc/base/switches.h" | 13 #include "cc/base/switches.h" |
15 #include "content/public/common/content_switches.h" | 14 #include "content/public/common/content_switches.h" |
16 #include "content/public/common/main_function_params.h" | 15 #include "content/public/common/main_function_params.h" |
17 #include "content/public/common/url_constants.h" | 16 #include "content/public/common/url_constants.h" |
18 #include "content/shell/shell.h" | 17 #include "content/shell/shell.h" |
19 #include "content/shell/shell_browser_context.h" | 18 #include "content/shell/shell_browser_context.h" |
20 #include "content/shell/shell_devtools_delegate.h" | 19 #include "content/shell/shell_devtools_delegate.h" |
21 #include "content/shell/shell_switches.h" | 20 #include "content/shell/shell_switches.h" |
(...skipping 84 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
106 #endif | 105 #endif |
107 } | 106 } |
108 | 107 |
109 void ShellBrowserMainParts::PreMainMessageLoopRun() { | 108 void ShellBrowserMainParts::PreMainMessageLoopRun() { |
110 browser_context_.reset(new ShellBrowserContext(false)); | 109 browser_context_.reset(new ShellBrowserContext(false)); |
111 off_the_record_browser_context_.reset(new ShellBrowserContext(true)); | 110 off_the_record_browser_context_.reset(new ShellBrowserContext(true)); |
112 | 111 |
113 Shell::Initialize(); | 112 Shell::Initialize(); |
114 net::NetModule::SetResourceProvider(PlatformResourceProvider); | 113 net::NetModule::SetResourceProvider(PlatformResourceProvider); |
115 | 114 |
116 int port = 0; | 115 devtools_delegate_ = new ShellDevToolsDelegate(browser_context_.get()); |
117 // On android the port number isn't used. | |
118 #if !defined(OS_ANDROID) | |
119 // See if the user specified a port on the command line (useful for | |
120 // automation). If not, use an ephemeral port by specifying 0. | |
121 const CommandLine& command_line = *CommandLine::ForCurrentProcess(); | |
122 if (command_line.HasSwitch(switches::kRemoteDebuggingPort)) { | |
123 int temp_port; | |
124 std::string port_str = | |
125 command_line.GetSwitchValueASCII(switches::kRemoteDebuggingPort); | |
126 if (base::StringToInt(port_str, &temp_port) && | |
127 temp_port > 0 && temp_port < 65535) { | |
128 port = temp_port; | |
129 } else { | |
130 DLOG(WARNING) << "Invalid http debugger port number " << temp_port; | |
131 } | |
132 } | |
133 #endif | |
134 devtools_delegate_ = new ShellDevToolsDelegate(browser_context_.get(), port); | |
135 | 116 |
136 if (!CommandLine::ForCurrentProcess()->HasSwitch(switches::kDumpRenderTree)) { | 117 if (!CommandLine::ForCurrentProcess()->HasSwitch(switches::kDumpRenderTree)) { |
137 Shell::CreateNewWindow(browser_context_.get(), | 118 Shell::CreateNewWindow(browser_context_.get(), |
138 GetStartupURL(), | 119 GetStartupURL(), |
139 NULL, | 120 NULL, |
140 MSG_ROUTING_NONE, | 121 MSG_ROUTING_NONE, |
141 gfx::Size()); | 122 gfx::Size()); |
142 } | 123 } |
143 | 124 |
144 if (parameters_.ui_task) { | 125 if (parameters_.ui_task) { |
(...skipping 11 matching lines...) Expand all Loading... |
156 #if defined(USE_AURA) | 137 #if defined(USE_AURA) |
157 Shell::PlatformExit(); | 138 Shell::PlatformExit(); |
158 #endif | 139 #endif |
159 if (devtools_delegate_) | 140 if (devtools_delegate_) |
160 devtools_delegate_->Stop(); | 141 devtools_delegate_->Stop(); |
161 browser_context_.reset(); | 142 browser_context_.reset(); |
162 off_the_record_browser_context_.reset(); | 143 off_the_record_browser_context_.reset(); |
163 } | 144 } |
164 | 145 |
165 } // namespace | 146 } // namespace |
OLD | NEW |