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/command_line.h" |
9 #include "base/message_loop.h" | 9 #include "base/message_loop.h" |
10 #include "base/threading/thread.h" | 10 #include "base/threading/thread.h" |
11 #include "base/threading/thread_restrictions.h" | 11 #include "base/threading/thread_restrictions.h" |
12 #include "content/browser/browser_process_sub_thread.h" | 12 #include "content/browser/browser_process_sub_thread.h" |
13 #include "content/browser/download/download_file_manager.h" | 13 #include "content/browser/download/download_file_manager.h" |
14 #include "content/browser/download/save_file_manager.h" | 14 #include "content/browser/download/save_file_manager.h" |
15 #include "content/browser/plugin_service_impl.h" | 15 #include "content/browser/plugin_service_impl.h" |
16 #include "content/shell/shell.h" | 16 #include "content/shell/shell.h" |
17 #include "content/shell/shell_browser_context.h" | 17 #include "content/shell/shell_browser_context.h" |
18 #include "content/shell/shell_content_browser_client.h" | 18 #include "content/shell/shell_content_browser_client.h" |
| 19 #include "content/shell/shell_main_delegate.h" |
19 #include "net/base/net_module.h" | 20 #include "net/base/net_module.h" |
20 #include "ui/base/clipboard/clipboard.h" | 21 #include "ui/base/clipboard/clipboard.h" |
21 | 22 |
22 namespace content { | 23 namespace content { |
23 | 24 |
24 static GURL GetStartupURL() { | 25 static GURL GetStartupURL() { |
25 const CommandLine::StringVector& args = | 26 const CommandLine::StringVector& args = |
26 CommandLine::ForCurrentProcess()->GetArgs(); | 27 CommandLine::ForCurrentProcess()->GetArgs(); |
27 if (args.empty()) | 28 if (args.empty()) |
28 return GURL("http://www.google.com/"); | 29 return GURL("http://www.google.com/"); |
29 | 30 |
30 return GURL(args[0]); | 31 return GURL(args[0]); |
31 } | 32 } |
32 | 33 |
33 ShellBrowserMainParts::ShellBrowserMainParts( | 34 ShellBrowserMainParts::ShellBrowserMainParts( |
| 35 ShellMainDelegate* delegate, |
34 const content::MainFunctionParams& parameters) | 36 const content::MainFunctionParams& parameters) |
35 : BrowserMainParts() { | 37 : BrowserMainParts(), |
| 38 delegate_(delegate) { |
36 ShellContentBrowserClient* shell_browser_client = | 39 ShellContentBrowserClient* shell_browser_client = |
37 static_cast<ShellContentBrowserClient*>( | 40 static_cast<ShellContentBrowserClient*>( |
38 content::GetContentClient()->browser()); | 41 content::GetContentClient()->browser()); |
39 shell_browser_client->set_shell_browser_main_parts(this); | 42 shell_browser_client->set_shell_browser_main_parts(this); |
40 } | 43 } |
41 | 44 |
42 ShellBrowserMainParts::~ShellBrowserMainParts() { | 45 ShellBrowserMainParts::~ShellBrowserMainParts() { |
43 } | 46 } |
44 | 47 |
| 48 MessageLoop* ShellBrowserMainParts::GetMainMessageLoop() { |
| 49 #if defined(TEST_EMBEDDED_MESSAGE_LOOP) |
| 50 return delegate_->CreateBrowserMessageLoop(); |
| 51 #else |
| 52 return NULL; |
| 53 #endif |
| 54 } |
| 55 |
45 void ShellBrowserMainParts::PreMainMessageLoopRun() { | 56 void ShellBrowserMainParts::PreMainMessageLoopRun() { |
46 browser_context_.reset(new ShellBrowserContext(this)); | 57 browser_context_.reset(new ShellBrowserContext(this)); |
47 | 58 |
48 Shell::PlatformInitialize(); | 59 Shell::PlatformInitialize(); |
49 net::NetModule::SetResourceProvider(Shell::PlatformResourceProvider); | 60 net::NetModule::SetResourceProvider(Shell::PlatformResourceProvider); |
50 | 61 |
51 Shell::CreateNewWindow(browser_context_.get(), | 62 Shell::CreateNewWindow(browser_context_.get(), |
52 GetStartupURL(), | 63 GetStartupURL(), |
53 NULL, | 64 NULL, |
54 MSG_ROUTING_NONE, | 65 MSG_ROUTING_NONE, |
55 NULL); | 66 NULL); |
56 } | 67 } |
57 | 68 |
58 void ShellBrowserMainParts::PostMainMessageLoopRun() { | 69 void ShellBrowserMainParts::PostMainMessageLoopRun() { |
59 browser_context_.reset(); | 70 browser_context_.reset(); |
60 } | 71 } |
61 | 72 |
62 bool ShellBrowserMainParts::MainMessageLoopRun(int* result_code) { | 73 bool ShellBrowserMainParts::MainMessageLoopRun(int* result_code) { |
63 return false; | 74 return false; |
64 } | 75 } |
65 | 76 |
66 ui::Clipboard* ShellBrowserMainParts::GetClipboard() { | 77 ui::Clipboard* ShellBrowserMainParts::GetClipboard() { |
67 if (!clipboard_.get()) | 78 if (!clipboard_.get()) |
68 clipboard_.reset(new ui::Clipboard()); | 79 clipboard_.reset(new ui::Clipboard()); |
69 return clipboard_.get(); | 80 return clipboard_.get(); |
70 } | 81 } |
71 | 82 |
72 } // namespace | 83 } // namespace |
OLD | NEW |