| OLD | NEW |
| 1 // Copyright 2015 The Chromium Authors. All rights reserved. | 1 // Copyright 2015 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 "blimp/engine/browser/blimp_browser_main_parts.h" | 5 #include "blimp/engine/browser/blimp_browser_main_parts.h" |
| 6 | 6 |
| 7 #include "base/command_line.h" | 7 #include "blimp/engine/browser/blimp_browser_context.h" |
| 8 #include "blimp/engine/browser/blimp_window.h" | 8 #include "blimp/engine/browser/blimp_engine_session.h" |
| 9 #include "blimp/engine/ui/blimp_screen.h" | 9 #include "blimp/net/blimp_client_session.h" |
| 10 #include "content/public/browser/browser_thread.h" | 10 #include "content/public/browser/browser_thread.h" |
| 11 #include "content/public/common/main_function_params.h" |
| 11 #include "net/base/net_module.h" | 12 #include "net/base/net_module.h" |
| 12 #include "net/log/net_log.h" | 13 #include "net/log/net_log.h" |
| 13 #include "url/gurl.h" | |
| 14 | 14 |
| 15 namespace blimp { | 15 namespace blimp { |
| 16 namespace engine { | 16 namespace engine { |
| 17 | 17 |
| 18 namespace { | |
| 19 | |
| 20 const char kDefaultURL[] = "https://www.google.com/"; | |
| 21 | |
| 22 GURL GetStartupURL() { | |
| 23 base::CommandLine* command_line = base::CommandLine::ForCurrentProcess(); | |
| 24 const base::CommandLine::StringVector& args = command_line->GetArgs(); | |
| 25 if (args.empty()) | |
| 26 return GURL(kDefaultURL); | |
| 27 | |
| 28 GURL url(args[0]); | |
| 29 if (url.is_valid() && url.has_scheme()) | |
| 30 return url; | |
| 31 | |
| 32 return GURL(kDefaultURL); | |
| 33 } | |
| 34 | |
| 35 } // namespace | |
| 36 | |
| 37 BlimpBrowserMainParts::BlimpBrowserMainParts( | 18 BlimpBrowserMainParts::BlimpBrowserMainParts( |
| 38 const content::MainFunctionParams& parameters) {} | 19 const content::MainFunctionParams& parameters) {} |
| 39 | 20 |
| 40 BlimpBrowserMainParts::~BlimpBrowserMainParts() {} | 21 BlimpBrowserMainParts::~BlimpBrowserMainParts() {} |
| 41 | 22 |
| 42 void BlimpBrowserMainParts::PreMainMessageLoopRun() { | 23 void BlimpBrowserMainParts::PreMainMessageLoopRun() { |
| 43 net_log_.reset(new net::NetLog()); | 24 net_log_.reset(new net::NetLog()); |
| 44 browser_context_.reset(new BlimpBrowserContext(false, net_log_.get())); | 25 scoped_ptr<BlimpBrowserContext> browser_context( |
| 45 BlimpWindow::Create(browser_context_.get(), GetStartupURL(), nullptr, | 26 new BlimpBrowserContext(false, net_log_.get())); |
| 46 gfx::Size()); | 27 engine_session_.reset(new BlimpEngineSession(browser_context.Pass())); |
| 47 } | 28 engine_session_->Initialize(); |
| 48 | 29 // TODO(haibinlu): remove this after a real client session can be attached. |
| 49 int BlimpBrowserMainParts::PreCreateThreads() { | 30 scoped_ptr<BlimpClientSession> startupSession(new BlimpClientSession); |
| 50 screen_.reset(new BlimpScreen); | 31 engine_session_->AttachClientSession(startupSession.Pass()); |
| 51 DCHECK(!gfx::Screen::GetScreenByType(gfx::SCREEN_TYPE_NATIVE)); | |
| 52 gfx::Screen::SetScreenInstance(gfx::SCREEN_TYPE_NATIVE, screen_.get()); | |
| 53 return 0; | |
| 54 } | 32 } |
| 55 | 33 |
| 56 void BlimpBrowserMainParts::PostMainMessageLoopRun() { | 34 void BlimpBrowserMainParts::PostMainMessageLoopRun() { |
| 57 browser_context_.reset(); | 35 engine_session_.reset(); |
| 36 } |
| 37 |
| 38 BlimpBrowserContext* BlimpBrowserMainParts::GetBrowserContext() { |
| 39 return engine_session_->browser_context(); |
| 58 } | 40 } |
| 59 | 41 |
| 60 } // namespace engine | 42 } // namespace engine |
| 61 } // namespace blimp | 43 } // namespace blimp |
| OLD | NEW |