| 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/shell/shell.h" | 14 #include "content/shell/shell.h" |
| 15 #include "content/shell/shell_browser_context.h" | 15 #include "content/shell/shell_browser_context.h" |
| 16 #include "content/shell/shell_devtools_delegate.h" | 16 #include "content/shell/shell_devtools_delegate.h" |
| 17 #include "content/shell/shell_switches.h" | 17 #include "content/shell/shell_switches.h" |
| 18 #include "googleurl/src/gurl.h" | 18 #include "googleurl/src/gurl.h" |
| 19 #include "net/base/net_module.h" | 19 #include "net/base/net_module.h" |
| 20 #include "ui/base/clipboard/clipboard.h" | 20 #include "ui/base/clipboard/clipboard.h" |
| 21 | 21 |
| 22 #if defined(OS_ANDROID) |
| 23 #include "base/message_pump_android.h" |
| 24 #endif |
| 25 |
| 22 namespace content { | 26 namespace content { |
| 23 | 27 |
| 24 static GURL GetStartupURL() { | 28 static GURL GetStartupURL() { |
| 25 const CommandLine::StringVector& args = | 29 const CommandLine::StringVector& args = |
| 26 CommandLine::ForCurrentProcess()->GetArgs(); | 30 CommandLine::ForCurrentProcess()->GetArgs(); |
| 27 if (args.empty()) | 31 if (args.empty()) |
| 28 return GURL("http://www.google.com/"); | 32 return GURL("http://www.google.com/"); |
| 29 | 33 |
| 30 return GURL(args[0]); | 34 return GURL(args[0]); |
| 31 } | 35 } |
| 32 | 36 |
| 37 #if defined(OS_ANDROID) |
| 38 static base::MessagePump* CreateMessagePumpForShell() { |
| 39 return new base::MessagePumpForUI(); |
| 40 } |
| 41 #endif |
| 42 |
| 33 ShellBrowserMainParts::ShellBrowserMainParts( | 43 ShellBrowserMainParts::ShellBrowserMainParts( |
| 34 const content::MainFunctionParams& parameters) | 44 const content::MainFunctionParams& parameters) |
| 35 : BrowserMainParts(), | 45 : BrowserMainParts(), |
| 36 devtools_delegate_(NULL) { | 46 devtools_delegate_(NULL) { |
| 37 } | 47 } |
| 38 | 48 |
| 39 ShellBrowserMainParts::~ShellBrowserMainParts() { | 49 ShellBrowserMainParts::~ShellBrowserMainParts() { |
| 40 } | 50 } |
| 41 | 51 |
| 42 #if !defined(OS_MACOSX) | 52 #if !defined(OS_MACOSX) |
| 43 void ShellBrowserMainParts::PreMainMessageLoopStart() { | 53 void ShellBrowserMainParts::PreMainMessageLoopStart() { |
| 54 #if defined(OS_ANDROID) |
| 55 MessageLoopForUI::InitMessagePumpForUIFactory(&CreateMessagePumpForShell); |
| 56 MessageLoopForUI::current()->Start(); |
| 57 #endif |
| 44 } | 58 } |
| 45 #endif | 59 #endif |
| 46 | 60 |
| 47 int ShellBrowserMainParts::PreCreateThreads() { | 61 int ShellBrowserMainParts::PreCreateThreads() { |
| 48 return 0; | 62 return 0; |
| 49 } | 63 } |
| 50 | 64 |
| 65 void ShellBrowserMainParts::PreEarlyInitialization() { |
| 66 #if defined(OS_ANDROID) |
| 67 // TODO(tedchoc): Setup the NetworkChangeNotifier here. |
| 68 #endif |
| 69 } |
| 70 |
| 51 void ShellBrowserMainParts::PreMainMessageLoopRun() { | 71 void ShellBrowserMainParts::PreMainMessageLoopRun() { |
| 52 browser_context_.reset(new ShellBrowserContext); | 72 browser_context_.reset(new ShellBrowserContext); |
| 53 | 73 |
| 54 Shell::PlatformInitialize(); | 74 Shell::PlatformInitialize(); |
| 55 net::NetModule::SetResourceProvider(Shell::PlatformResourceProvider); | 75 net::NetModule::SetResourceProvider(Shell::PlatformResourceProvider); |
| 56 | 76 |
| 57 const CommandLine& command_line = *CommandLine::ForCurrentProcess(); | 77 const CommandLine& command_line = *CommandLine::ForCurrentProcess(); |
| 58 if (command_line.HasSwitch(switches::kRemoteDebuggingPort)) { | 78 if (command_line.HasSwitch(switches::kRemoteDebuggingPort)) { |
| 59 std::string port_str = | 79 std::string port_str = |
| 60 command_line.GetSwitchValueASCII(switches::kRemoteDebuggingPort); | 80 command_line.GetSwitchValueASCII(switches::kRemoteDebuggingPort); |
| (...skipping 26 matching lines...) Expand all Loading... |
| 87 return false; | 107 return false; |
| 88 } | 108 } |
| 89 | 109 |
| 90 ui::Clipboard* ShellBrowserMainParts::GetClipboard() { | 110 ui::Clipboard* ShellBrowserMainParts::GetClipboard() { |
| 91 if (!clipboard_.get()) | 111 if (!clipboard_.get()) |
| 92 clipboard_.reset(new ui::Clipboard()); | 112 clipboard_.reset(new ui::Clipboard()); |
| 93 return clipboard_.get(); | 113 return clipboard_.get(); |
| 94 } | 114 } |
| 95 | 115 |
| 96 } // namespace | 116 } // namespace |
| OLD | NEW |