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/message_loop.h" | 9 #include "base/message_loop.h" |
| 10 #include "base/string_number_conversions.h" |
10 #include "base/threading/thread.h" | 11 #include "base/threading/thread.h" |
11 #include "base/threading/thread_restrictions.h" | 12 #include "base/threading/thread_restrictions.h" |
12 #include "content/public/common/content_switches.h" | 13 #include "content/public/common/content_switches.h" |
13 #include "content/public/common/main_function_params.h" | 14 #include "content/public/common/main_function_params.h" |
14 #include "content/public/common/url_constants.h" | 15 #include "content/public/common/url_constants.h" |
15 #include "content/shell/shell.h" | 16 #include "content/shell/shell.h" |
16 #include "content/shell/shell_browser_context.h" | 17 #include "content/shell/shell_browser_context.h" |
17 #include "content/shell/shell_devtools_delegate.h" | 18 #include "content/shell/shell_devtools_delegate.h" |
18 #include "content/shell/shell_switches.h" | 19 #include "content/shell/shell_switches.h" |
19 #include "googleurl/src/gurl.h" | 20 #include "googleurl/src/gurl.h" |
(...skipping 68 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
88 #endif | 89 #endif |
89 } | 90 } |
90 | 91 |
91 void ShellBrowserMainParts::PreMainMessageLoopRun() { | 92 void ShellBrowserMainParts::PreMainMessageLoopRun() { |
92 browser_context_.reset(new ShellBrowserContext(false)); | 93 browser_context_.reset(new ShellBrowserContext(false)); |
93 off_the_record_browser_context_.reset(new ShellBrowserContext(true)); | 94 off_the_record_browser_context_.reset(new ShellBrowserContext(true)); |
94 | 95 |
95 Shell::PlatformInitialize(); | 96 Shell::PlatformInitialize(); |
96 net::NetModule::SetResourceProvider(PlatformResourceProvider); | 97 net::NetModule::SetResourceProvider(PlatformResourceProvider); |
97 | 98 |
| 99 int port = 0; |
| 100 // On android the port number isn't used. |
| 101 #if !defined(OS_ANDROID) |
| 102 // See if the user specified a port on the command line (useful for |
| 103 // automation). If not, use an ephemeral port by specifying 0. |
| 104 const CommandLine& command_line = *CommandLine::ForCurrentProcess(); |
| 105 if (command_line.HasSwitch(switches::kRemoteDebuggingPort)) { |
| 106 int temp_port; |
| 107 std::string port_str = |
| 108 command_line.GetSwitchValueASCII(switches::kRemoteDebuggingPort); |
| 109 if (base::StringToInt(port_str, &temp_port) && |
| 110 temp_port > 0 && temp_port < 65535) { |
| 111 port = temp_port; |
| 112 } else { |
| 113 DLOG(WARNING) << "Invalid http debugger port number " << temp_port; |
| 114 } |
| 115 } |
| 116 #endif |
98 devtools_delegate_ = new ShellDevToolsDelegate( | 117 devtools_delegate_ = new ShellDevToolsDelegate( |
99 browser_context_->GetRequestContext()); | 118 port, browser_context_->GetRequestContext()); |
100 | 119 |
101 if (!CommandLine::ForCurrentProcess()->HasSwitch(switches::kDumpRenderTree)) { | 120 if (!CommandLine::ForCurrentProcess()->HasSwitch(switches::kDumpRenderTree)) { |
102 Shell::CreateNewWindow(browser_context_.get(), | 121 Shell::CreateNewWindow(browser_context_.get(), |
103 GetStartupURL(), | 122 GetStartupURL(), |
104 NULL, | 123 NULL, |
105 MSG_ROUTING_NONE, | 124 MSG_ROUTING_NONE, |
106 NULL); | 125 NULL); |
107 } | 126 } |
108 | 127 |
109 if (parameters_.ui_task) { | 128 if (parameters_.ui_task) { |
(...skipping 11 matching lines...) Expand all Loading... |
121 #if defined(USE_AURA) | 140 #if defined(USE_AURA) |
122 Shell::PlatformExit(); | 141 Shell::PlatformExit(); |
123 #endif | 142 #endif |
124 if (devtools_delegate_) | 143 if (devtools_delegate_) |
125 devtools_delegate_->Stop(); | 144 devtools_delegate_->Stop(); |
126 browser_context_.reset(); | 145 browser_context_.reset(); |
127 off_the_record_browser_context_.reset(); | 146 off_the_record_browser_context_.reset(); |
128 } | 147 } |
129 | 148 |
130 } // namespace | 149 } // namespace |
OLD | NEW |