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" |
11 #include "base/threading/thread.h" | 11 #include "base/threading/thread.h" |
12 #include "base/threading/thread_restrictions.h" | 12 #include "base/threading/thread_restrictions.h" |
13 #include "content/public/common/content_switches.h" | 13 #include "content/public/common/content_switches.h" |
| 14 #include "content/public/common/main_function_params.h" |
14 #include "content/shell/shell.h" | 15 #include "content/shell/shell.h" |
15 #include "content/shell/shell_browser_context.h" | 16 #include "content/shell/shell_browser_context.h" |
16 #include "content/shell/shell_devtools_delegate.h" | 17 #include "content/shell/shell_devtools_delegate.h" |
17 #include "content/shell/shell_switches.h" | 18 #include "content/shell/shell_switches.h" |
18 #include "googleurl/src/gurl.h" | 19 #include "googleurl/src/gurl.h" |
19 #include "net/base/net_module.h" | 20 #include "net/base/net_module.h" |
20 | 21 |
21 #if defined(OS_ANDROID) | 22 #if defined(OS_ANDROID) |
22 #include "net/base/network_change_notifier.h" | 23 #include "net/base/network_change_notifier.h" |
23 #include "net/android/network_change_notifier_factory.h" | 24 #include "net/android/network_change_notifier_factory.h" |
24 #endif | 25 #endif |
25 | 26 |
26 namespace content { | 27 namespace content { |
27 | 28 |
28 static GURL GetStartupURL() { | 29 static GURL GetStartupURL() { |
29 const CommandLine::StringVector& args = | 30 const CommandLine::StringVector& args = |
30 CommandLine::ForCurrentProcess()->GetArgs(); | 31 CommandLine::ForCurrentProcess()->GetArgs(); |
31 if (args.empty()) | 32 if (args.empty()) |
32 return GURL("http://www.google.com/"); | 33 return GURL("http://www.google.com/"); |
33 | 34 |
34 return GURL(args[0]); | 35 return GURL(args[0]); |
35 } | 36 } |
36 | 37 |
37 ShellBrowserMainParts::ShellBrowserMainParts( | 38 ShellBrowserMainParts::ShellBrowserMainParts( |
38 const content::MainFunctionParams& parameters) | 39 const content::MainFunctionParams& parameters) |
39 : BrowserMainParts(), | 40 : BrowserMainParts(), |
| 41 parameters_(parameters), |
| 42 run_message_loop_(true), |
40 devtools_delegate_(NULL) { | 43 devtools_delegate_(NULL) { |
41 } | 44 } |
42 | 45 |
43 ShellBrowserMainParts::~ShellBrowserMainParts() { | 46 ShellBrowserMainParts::~ShellBrowserMainParts() { |
44 } | 47 } |
45 | 48 |
46 #if !defined(OS_MACOSX) | 49 #if !defined(OS_MACOSX) |
47 void ShellBrowserMainParts::PreMainMessageLoopStart() { | 50 void ShellBrowserMainParts::PreMainMessageLoopStart() { |
48 } | 51 } |
49 #endif | 52 #endif |
(...skipping 31 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
81 } | 84 } |
82 } | 85 } |
83 | 86 |
84 if (!CommandLine::ForCurrentProcess()->HasSwitch(switches::kDumpRenderTree)) { | 87 if (!CommandLine::ForCurrentProcess()->HasSwitch(switches::kDumpRenderTree)) { |
85 Shell::CreateNewWindow(browser_context_.get(), | 88 Shell::CreateNewWindow(browser_context_.get(), |
86 GetStartupURL(), | 89 GetStartupURL(), |
87 NULL, | 90 NULL, |
88 MSG_ROUTING_NONE, | 91 MSG_ROUTING_NONE, |
89 NULL); | 92 NULL); |
90 } | 93 } |
| 94 |
| 95 if (parameters_.ui_task) { |
| 96 parameters_.ui_task->Run(); |
| 97 delete parameters_.ui_task; |
| 98 run_message_loop_ = false; |
| 99 } |
| 100 } |
| 101 |
| 102 bool ShellBrowserMainParts::MainMessageLoopRun(int* result_code) { |
| 103 return !run_message_loop_; |
91 } | 104 } |
92 | 105 |
93 void ShellBrowserMainParts::PostMainMessageLoopRun() { | 106 void ShellBrowserMainParts::PostMainMessageLoopRun() { |
94 if (devtools_delegate_) | 107 if (devtools_delegate_) |
95 devtools_delegate_->Stop(); | 108 devtools_delegate_->Stop(); |
96 browser_context_.reset(); | 109 browser_context_.reset(); |
97 } | 110 } |
98 | 111 |
99 } // namespace | 112 } // namespace |
OLD | NEW |