| OLD | NEW |
| 1 // Copyright (c) 2011 The Chromium Authors. All rights reserved. | 1 // Copyright (c) 2011 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.h" | 5 #include "content/shell/shell_browser_main.h" |
| 6 | 6 |
| 7 #include "base/bind.h" | 7 #include "base/bind.h" |
| 8 #include "base/command_line.h" |
| 8 #include "base/message_loop.h" | 9 #include "base/message_loop.h" |
| 9 #include "base/threading/thread.h" | 10 #include "base/threading/thread.h" |
| 10 #include "base/threading/thread_restrictions.h" | 11 #include "base/threading/thread_restrictions.h" |
| 11 #include "content/browser/browser_process_sub_thread.h" | 12 #include "content/browser/browser_process_sub_thread.h" |
| 12 #include "content/browser/download/download_file_manager.h" | 13 #include "content/browser/download/download_file_manager.h" |
| 13 #include "content/browser/download/save_file_manager.h" | 14 #include "content/browser/download/save_file_manager.h" |
| 14 #include "content/browser/renderer_host/resource_dispatcher_host.h" | 15 #include "content/browser/renderer_host/resource_dispatcher_host.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_content_browser_client.h" | 18 #include "content/shell/shell_content_browser_client.h" |
| 18 #include "net/base/net_module.h" | 19 #include "net/base/net_module.h" |
| 19 #include "ui/base/clipboard/clipboard.h" | 20 #include "ui/base/clipboard/clipboard.h" |
| 20 | 21 |
| 21 namespace content { | 22 namespace content { |
| 22 | 23 |
| 24 static GURL GetStartupURL() { |
| 25 const CommandLine::StringVector& args = |
| 26 CommandLine::ForCurrentProcess()->GetArgs(); |
| 27 if (args.empty()) |
| 28 return GURL("http://www.google.com/"); |
| 29 |
| 30 return GURL(args[0]); |
| 31 } |
| 32 |
| 23 ShellBrowserMainParts::ShellBrowserMainParts( | 33 ShellBrowserMainParts::ShellBrowserMainParts( |
| 24 const content::MainFunctionParams& parameters) | 34 const content::MainFunctionParams& parameters) |
| 25 : BrowserMainParts() { | 35 : BrowserMainParts() { |
| 26 ShellContentBrowserClient* shell_browser_client = | 36 ShellContentBrowserClient* shell_browser_client = |
| 27 static_cast<ShellContentBrowserClient*>( | 37 static_cast<ShellContentBrowserClient*>( |
| 28 content::GetContentClient()->browser()); | 38 content::GetContentClient()->browser()); |
| 29 shell_browser_client->set_shell_browser_main_parts(this); | 39 shell_browser_client->set_shell_browser_main_parts(this); |
| 30 } | 40 } |
| 31 | 41 |
| 32 ShellBrowserMainParts::~ShellBrowserMainParts() { | 42 ShellBrowserMainParts::~ShellBrowserMainParts() { |
| (...skipping 31 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 64 cache_thread_->StartWithOptions(options); | 74 cache_thread_->StartWithOptions(options); |
| 65 io_thread_.reset(new BrowserProcessSubThread(BrowserThread::IO)); | 75 io_thread_.reset(new BrowserProcessSubThread(BrowserThread::IO)); |
| 66 io_thread_->StartWithOptions(options); | 76 io_thread_->StartWithOptions(options); |
| 67 | 77 |
| 68 browser_context_.reset(new ShellBrowserContext(this)); | 78 browser_context_.reset(new ShellBrowserContext(this)); |
| 69 | 79 |
| 70 Shell::PlatformInitialize(); | 80 Shell::PlatformInitialize(); |
| 71 net::NetModule::SetResourceProvider(Shell::PlatformResourceProvider); | 81 net::NetModule::SetResourceProvider(Shell::PlatformResourceProvider); |
| 72 | 82 |
| 73 Shell::CreateNewWindow(browser_context_.get(), | 83 Shell::CreateNewWindow(browser_context_.get(), |
| 74 GURL("http://www.google.com"), | 84 GetStartupURL(), |
| 75 NULL, | 85 NULL, |
| 76 MSG_ROUTING_NONE, | 86 MSG_ROUTING_NONE, |
| 77 NULL); | 87 NULL); |
| 78 | 88 |
| 79 } | 89 } |
| 80 | 90 |
| 81 bool ShellBrowserMainParts::MainMessageLoopRun(int* result_code) { | 91 bool ShellBrowserMainParts::MainMessageLoopRun(int* result_code) { |
| 82 return false; | 92 return false; |
| 83 } | 93 } |
| 84 | 94 |
| 85 ResourceDispatcherHost* ShellBrowserMainParts::GetResourceDispatcherHost() { | 95 ResourceDispatcherHost* ShellBrowserMainParts::GetResourceDispatcherHost() { |
| 86 if (!resource_dispatcher_host_.get()) { | 96 if (!resource_dispatcher_host_.get()) { |
| 87 ResourceQueue::DelegateSet resource_queue_delegates; | 97 ResourceQueue::DelegateSet resource_queue_delegates; |
| 88 resource_dispatcher_host_.reset( | 98 resource_dispatcher_host_.reset( |
| 89 new ResourceDispatcherHost(resource_queue_delegates)); | 99 new ResourceDispatcherHost(resource_queue_delegates)); |
| 90 resource_dispatcher_host_->Initialize(); | 100 resource_dispatcher_host_->Initialize(); |
| 91 } | 101 } |
| 92 return resource_dispatcher_host_.get(); | 102 return resource_dispatcher_host_.get(); |
| 93 } | 103 } |
| 94 | 104 |
| 95 ui::Clipboard* ShellBrowserMainParts::GetClipboard() { | 105 ui::Clipboard* ShellBrowserMainParts::GetClipboard() { |
| 96 if (!clipboard_.get()) | 106 if (!clipboard_.get()) |
| 97 clipboard_.reset(new ui::Clipboard()); | 107 clipboard_.reset(new ui::Clipboard()); |
| 98 return clipboard_.get(); | 108 return clipboard_.get(); |
| 99 } | 109 } |
| 100 | 110 |
| 101 } // namespace | 111 } // namespace |
| OLD | NEW |