| 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/string_number_conversions.h" |
| (...skipping 40 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 51 | 51 |
| 52 MessageLoop* ShellBrowserMainParts::GetMainMessageLoop() { | 52 MessageLoop* ShellBrowserMainParts::GetMainMessageLoop() { |
| 53 return NULL; | 53 return NULL; |
| 54 } | 54 } |
| 55 | 55 |
| 56 int ShellBrowserMainParts::PreCreateThreads() { | 56 int ShellBrowserMainParts::PreCreateThreads() { |
| 57 return 0; | 57 return 0; |
| 58 } | 58 } |
| 59 | 59 |
| 60 void ShellBrowserMainParts::PreMainMessageLoopRun() { | 60 void ShellBrowserMainParts::PreMainMessageLoopRun() { |
| 61 browser_context_.reset(new ShellBrowserContext(this)); | |
| 62 | |
| 63 Shell::PlatformInitialize(); | 61 Shell::PlatformInitialize(); |
| 64 net::NetModule::SetResourceProvider(Shell::PlatformResourceProvider); | 62 net::NetModule::SetResourceProvider(Shell::PlatformResourceProvider); |
| 65 | 63 |
| 66 const CommandLine& command_line = *CommandLine::ForCurrentProcess(); | 64 const CommandLine& command_line = *CommandLine::ForCurrentProcess(); |
| 67 if (command_line.HasSwitch(switches::kRemoteDebuggingPort)) { | 65 if (command_line.HasSwitch(switches::kRemoteDebuggingPort)) { |
| 68 std::string port_str = | 66 std::string port_str = |
| 69 command_line.GetSwitchValueASCII(switches::kRemoteDebuggingPort); | 67 command_line.GetSwitchValueASCII(switches::kRemoteDebuggingPort); |
| 70 int port; | 68 int port; |
| 71 if (base::StringToInt(port_str, &port) && port > 0 && port < 65535) { | 69 if (base::StringToInt(port_str, &port) && port > 0 && port < 65535) { |
| 72 devtools_delegate_ = new ShellDevToolsDelegate( | 70 devtools_delegate_ = new ShellDevToolsDelegate( |
| 73 port, | 71 port, |
| 74 browser_context_->GetRequestContext()); | 72 ShellBrowserContext::GetInstance()->GetRequestContext()); |
| 75 } else { | 73 } else { |
| 76 DLOG(WARNING) << "Invalid http debugger port number " << port; | 74 DLOG(WARNING) << "Invalid http debugger port number " << port; |
| 77 } | 75 } |
| 78 } | 76 } |
| 79 | 77 |
| 80 if (!CommandLine::ForCurrentProcess()->HasSwitch(switches::kDumpRenderTree)) { | 78 if (!CommandLine::ForCurrentProcess()->HasSwitch(switches::kDumpRenderTree)) { |
| 81 Shell::CreateNewWindow(browser_context_.get(), | 79 Shell::CreateNewWindow(ShellBrowserContext::GetInstance(), |
| 82 GetStartupURL(), | 80 GetStartupURL(), |
| 83 NULL, | 81 NULL, |
| 84 MSG_ROUTING_NONE, | 82 MSG_ROUTING_NONE, |
| 85 NULL); | 83 NULL); |
| 86 } | 84 } |
| 87 } | 85 } |
| 88 | 86 |
| 89 void ShellBrowserMainParts::PostMainMessageLoopRun() { | 87 void ShellBrowserMainParts::PostMainMessageLoopRun() { |
| 90 if (devtools_delegate_) | 88 if (devtools_delegate_) |
| 91 devtools_delegate_->Stop(); | 89 devtools_delegate_->Stop(); |
| 92 browser_context_.reset(); | |
| 93 } | 90 } |
| 94 | 91 |
| 95 bool ShellBrowserMainParts::MainMessageLoopRun(int* result_code) { | 92 bool ShellBrowserMainParts::MainMessageLoopRun(int* result_code) { |
| 96 return false; | 93 return false; |
| 97 } | 94 } |
| 98 | 95 |
| 99 ui::Clipboard* ShellBrowserMainParts::GetClipboard() { | 96 ui::Clipboard* ShellBrowserMainParts::GetClipboard() { |
| 100 if (!clipboard_.get()) | 97 if (!clipboard_.get()) |
| 101 clipboard_.reset(new ui::Clipboard()); | 98 clipboard_.reset(new ui::Clipboard()); |
| 102 return clipboard_.get(); | 99 return clipboard_.get(); |
| 103 } | 100 } |
| 104 | 101 |
| 105 } // namespace | 102 } // namespace |
| OLD | NEW |