| 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/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/public/common/content_switches.h" | 12 #include "content/public/common/content_switches.h" |
| 13 #include "content/public/common/main_function_params.h" | 13 #include "content/public/common/main_function_params.h" |
| 14 #include "content/public/common/url_constants.h" | 14 #include "content/public/common/url_constants.h" |
| 15 #include "content/shell/shell.h" | 15 #include "content/shell/shell.h" |
| 16 #include "content/shell/shell_browser_context.h" | 16 #include "content/shell/shell_browser_context.h" |
| 17 #include "content/shell/shell_devtools_delegate.h" | 17 #include "content/shell/shell_devtools_delegate.h" |
| 18 #include "content/shell/shell_switches.h" | 18 #include "content/shell/shell_switches.h" |
| 19 #include "googleurl/src/gurl.h" | 19 #include "googleurl/src/gurl.h" |
| 20 #include "grit/net_resources.h" |
| 20 #include "net/base/net_module.h" | 21 #include "net/base/net_module.h" |
| 22 #include "ui/base/resource/resource_bundle.h" |
| 21 | 23 |
| 22 #if defined(OS_ANDROID) | 24 #if defined(OS_ANDROID) |
| 23 #include "net/base/network_change_notifier.h" | 25 #include "net/base/network_change_notifier.h" |
| 24 #include "net/android/network_change_notifier_factory.h" | 26 #include "net/android/network_change_notifier_factory.h" |
| 25 #endif | 27 #endif |
| 26 | 28 |
| 27 namespace content { | 29 namespace content { |
| 28 | 30 |
| 31 namespace { |
| 32 |
| 29 static GURL GetStartupURL() { | 33 static GURL GetStartupURL() { |
| 30 CommandLine* command_line = CommandLine::ForCurrentProcess(); | 34 CommandLine* command_line = CommandLine::ForCurrentProcess(); |
| 31 if (command_line->HasSwitch(switches::kContentBrowserTest)) | 35 if (command_line->HasSwitch(switches::kContentBrowserTest)) |
| 32 return GURL(); | 36 return GURL(); |
| 33 const CommandLine::StringVector& args = command_line->GetArgs(); | 37 const CommandLine::StringVector& args = command_line->GetArgs(); |
| 34 | 38 |
| 35 #if defined(OS_ANDROID) | 39 #if defined(OS_ANDROID) |
| 36 // Delay renderer creation on Android until surface is ready. | 40 // Delay renderer creation on Android until surface is ready. |
| 37 return GURL(); | 41 return GURL(); |
| 38 #endif | 42 #endif |
| 39 | 43 |
| 40 if (args.empty()) | 44 if (args.empty()) |
| 41 return GURL("http://www.google.com/"); | 45 return GURL("http://www.google.com/"); |
| 42 | 46 |
| 43 return GURL(args[0]); | 47 return GURL(args[0]); |
| 44 } | 48 } |
| 45 | 49 |
| 50 base::StringPiece PlatformResourceProvider(int key) { |
| 51 if (key == IDR_DIR_HEADER_HTML) { |
| 52 base::StringPiece html_data = |
| 53 ui::ResourceBundle::GetSharedInstance().GetRawDataResource( |
| 54 IDR_DIR_HEADER_HTML, ui::SCALE_FACTOR_NONE); |
| 55 return html_data; |
| 56 } |
| 57 return base::StringPiece(); |
| 58 } |
| 59 |
| 60 } // namespace |
| 61 |
| 46 ShellBrowserMainParts::ShellBrowserMainParts( | 62 ShellBrowserMainParts::ShellBrowserMainParts( |
| 47 const MainFunctionParams& parameters) | 63 const MainFunctionParams& parameters) |
| 48 : BrowserMainParts(), | 64 : BrowserMainParts(), |
| 49 parameters_(parameters), | 65 parameters_(parameters), |
| 50 run_message_loop_(true), | 66 run_message_loop_(true), |
| 51 devtools_delegate_(NULL) { | 67 devtools_delegate_(NULL) { |
| 52 } | 68 } |
| 53 | 69 |
| 54 ShellBrowserMainParts::~ShellBrowserMainParts() { | 70 ShellBrowserMainParts::~ShellBrowserMainParts() { |
| 55 } | 71 } |
| (...skipping 14 matching lines...) Expand all Loading... |
| 70 net::NetworkChangeNotifier::SetFactory( | 86 net::NetworkChangeNotifier::SetFactory( |
| 71 new net::android::NetworkChangeNotifierFactory()); | 87 new net::android::NetworkChangeNotifierFactory()); |
| 72 #endif | 88 #endif |
| 73 } | 89 } |
| 74 | 90 |
| 75 void ShellBrowserMainParts::PreMainMessageLoopRun() { | 91 void ShellBrowserMainParts::PreMainMessageLoopRun() { |
| 76 browser_context_.reset(new ShellBrowserContext(false)); | 92 browser_context_.reset(new ShellBrowserContext(false)); |
| 77 off_the_record_browser_context_.reset(new ShellBrowserContext(true)); | 93 off_the_record_browser_context_.reset(new ShellBrowserContext(true)); |
| 78 | 94 |
| 79 Shell::PlatformInitialize(); | 95 Shell::PlatformInitialize(); |
| 80 net::NetModule::SetResourceProvider(Shell::PlatformResourceProvider); | 96 net::NetModule::SetResourceProvider(PlatformResourceProvider); |
| 81 | 97 |
| 82 #if defined(OS_ANDROID) | 98 #if defined(OS_ANDROID) |
| 83 devtools_delegate_ = new ShellDevToolsDelegate( | 99 devtools_delegate_ = new ShellDevToolsDelegate( |
| 84 browser_context_->GetRequestContext()); | 100 browser_context_->GetRequestContext()); |
| 85 #else | 101 #else |
| 86 devtools_delegate_ = new ShellDevToolsDelegate( | 102 devtools_delegate_ = new ShellDevToolsDelegate( |
| 87 browser_context_->GetRequestContext()); | 103 browser_context_->GetRequestContext()); |
| 88 #endif | 104 #endif |
| 89 | 105 |
| 90 if (!CommandLine::ForCurrentProcess()->HasSwitch(switches::kDumpRenderTree)) { | 106 if (!CommandLine::ForCurrentProcess()->HasSwitch(switches::kDumpRenderTree)) { |
| (...skipping 19 matching lines...) Expand all Loading... |
| 110 #if defined(USE_AURA) | 126 #if defined(USE_AURA) |
| 111 Shell::PlatformExit(); | 127 Shell::PlatformExit(); |
| 112 #endif | 128 #endif |
| 113 if (devtools_delegate_) | 129 if (devtools_delegate_) |
| 114 devtools_delegate_->Stop(); | 130 devtools_delegate_->Stop(); |
| 115 browser_context_.reset(); | 131 browser_context_.reset(); |
| 116 off_the_record_browser_context_.reset(); | 132 off_the_record_browser_context_.reset(); |
| 117 } | 133 } |
| 118 | 134 |
| 119 } // namespace | 135 } // namespace |
| OLD | NEW |