Chromium Code Reviews
chromiumcodereview-hr@appspot.gserviceaccount.com (chromiumcodereview-hr) | Please choose your nickname with Settings | Help | Chromium Project | Gerrit Changes | Sign out
(137)

Side by Side Diff: chromecast/browser/service/cast_service_simple.cc

Issue 2643553002: [Chromecast] Reuse the Aura window manager across receiver apps. (Closed)
Patch Set: fix unit tests Created 3 years, 11 months ago
Use n/p to move between diff chunks; N/P to move between comments. Draft comments are only viewable by you.
Jump to:
View unified diff | Download patch
OLDNEW
1 // Copyright 2014 The Chromium Authors. All rights reserved. 1 // Copyright 2014 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 "chromecast/browser/service/cast_service_simple.h" 5 #include "chromecast/browser/service/cast_service_simple.h"
6 6
7 #include <string> 7 #include <string>
8 8
9 #include "base/command_line.h" 9 #include "base/command_line.h"
10 #include "base/files/file_util.h" 10 #include "base/files/file_util.h"
11 #include "base/memory/ptr_util.h" 11 #include "base/memory/ptr_util.h"
12 #include "chromecast/graphics/cast_window_manager.h"
halliwell 2017/01/18 02:55:18 unnecessary
Joshua LeVasseur 2017/01/18 18:26:35 Done.
12 #include "content/public/browser/render_view_host.h" 13 #include "content/public/browser/render_view_host.h"
13 #include "content/public/browser/web_contents.h" 14 #include "content/public/browser/web_contents.h"
14 #include "net/base/filename_util.h" 15 #include "net/base/filename_util.h"
15 #include "net/url_request/url_request_context_getter.h" 16 #include "net/url_request/url_request_context_getter.h"
16 17
17 namespace chromecast { 18 namespace chromecast {
18 namespace shell { 19 namespace shell {
19 20
20 namespace { 21 namespace {
21 22
22 GURL GetStartupURL() { 23 GURL GetStartupURL() {
23 base::CommandLine* command_line = base::CommandLine::ForCurrentProcess(); 24 base::CommandLine* command_line = base::CommandLine::ForCurrentProcess();
24 const base::CommandLine::StringVector& args = command_line->GetArgs(); 25 const base::CommandLine::StringVector& args = command_line->GetArgs();
25 26
26 if (args.empty()) 27 if (args.empty())
27 return GURL("http://www.google.com/"); 28 return GURL("http://www.google.com/");
28 29
29 GURL url(args[0]); 30 GURL url(args[0]);
30 if (url.is_valid() && url.has_scheme()) 31 if (url.is_valid() && url.has_scheme())
31 return url; 32 return url;
32 33
33 return net::FilePathToFileURL( 34 return net::FilePathToFileURL(
34 base::MakeAbsoluteFilePath(base::FilePath(args[0]))); 35 base::MakeAbsoluteFilePath(base::FilePath(args[0])));
35 } 36 }
36 37
37 } // namespace 38 } // namespace
38 39
39 CastServiceSimple::CastServiceSimple( 40 CastServiceSimple::CastServiceSimple(content::BrowserContext* browser_context,
40 content::BrowserContext* browser_context, 41 PrefService* pref_service,
41 PrefService* pref_service) 42 CastWindowManager* window_manager)
42 : CastService(browser_context, pref_service) { 43 : CastService(browser_context, pref_service),
43 } 44 window_manager_(window_manager) {}
derekjchow1 2017/01/18 02:49:12 DCHECK(window_manager_);
Joshua LeVasseur 2017/01/18 18:26:35 Done.
44 45
45 CastServiceSimple::~CastServiceSimple() { 46 CastServiceSimple::~CastServiceSimple() {
46 } 47 }
47 48
48 void CastServiceSimple::InitializeInternal() { 49 void CastServiceSimple::InitializeInternal() {
49 startup_url_ = GetStartupURL(); 50 startup_url_ = GetStartupURL();
50 } 51 }
51 52
52 void CastServiceSimple::FinalizeInternal() { 53 void CastServiceSimple::FinalizeInternal() {
53 } 54 }
54 55
55 void CastServiceSimple::StartInternal() { 56 void CastServiceSimple::StartInternal() {
56 window_ = CastContentWindow::Create(this); 57 window_ = CastContentWindow::Create(this);
57 web_contents_ = window_->CreateWebContents(browser_context()); 58 web_contents_ = window_->CreateWebContents(browser_context());
58 window_->ShowWebContents(web_contents_.get()); 59 window_->ShowWebContents(web_contents_.get(), window_manager_);
59 60
60 web_contents_->GetController().LoadURL(startup_url_, content::Referrer(), 61 web_contents_->GetController().LoadURL(startup_url_, content::Referrer(),
61 ui::PAGE_TRANSITION_TYPED, 62 ui::PAGE_TRANSITION_TYPED,
62 std::string()); 63 std::string());
63 web_contents_->Focus(); 64 web_contents_->Focus();
64 } 65 }
65 66
66 void CastServiceSimple::StopInternal() { 67 void CastServiceSimple::StopInternal() {
67 web_contents_->ClosePage(); 68 web_contents_->ClosePage();
68 web_contents_.reset(); 69 web_contents_.reset();
69 window_.reset(); 70 window_.reset();
70 } 71 }
71 72
72 void CastServiceSimple::OnWindowDestroyed() {} 73 void CastServiceSimple::OnWindowDestroyed() {}
73 74
74 void CastServiceSimple::OnKeyEvent(const ui::KeyEvent& key_event) {} 75 void CastServiceSimple::OnKeyEvent(const ui::KeyEvent& key_event) {}
75 76
76 } // namespace shell 77 } // namespace shell
77 } // namespace chromecast 78 } // namespace chromecast
OLDNEW

Powered by Google App Engine
This is Rietveld 408576698