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
3 // found in the LICENSE file.
5 #include "chromecast/browser/service/cast_service_simple.h"
7 #include "base/command_line.h"
8 #include "chromecast/browser/cast_content_window.h"
9 #include "content/public/browser/render_view_host.h"
10 #include "content/public/browser/web_contents.h"
11 #include "net/base/filename_util.h"
12 #include "net/url_request/url_request_context_getter.h"
15 namespace chromecast
{
19 GURL
GetStartupURL() {
20 base::CommandLine
* command_line
= base::CommandLine::ForCurrentProcess();
21 const base::CommandLine::StringVector
& args
= command_line
->GetArgs();
24 return GURL("http://www.google.com/");
27 if (url
.is_valid() && url
.has_scheme())
30 return net::FilePathToFileURL(base::FilePath(args
[0]));
36 CastService
* CastService::Create(
37 content::BrowserContext
* browser_context
,
38 net::URLRequestContextGetter
* request_context_getter
,
39 const OptInStatsChangedCallback
& opt_in_stats_callback
) {
40 return new CastServiceSimple(browser_context
, opt_in_stats_callback
);
43 CastServiceSimple::CastServiceSimple(
44 content::BrowserContext
* browser_context
,
45 const OptInStatsChangedCallback
& opt_in_stats_callback
)
46 : CastService(browser_context
, opt_in_stats_callback
) {
49 CastServiceSimple::~CastServiceSimple() {
52 void CastServiceSimple::Initialize() {
55 void CastServiceSimple::StartInternal() {
56 // This is the simple version that hard-codes the size.
57 gfx::Size
initial_size(1280, 720);
59 window_
.reset(new CastContentWindow
);
60 web_contents_
= window_
->Create(initial_size
, browser_context());
62 web_contents_
->GetController().LoadURL(GetStartupURL(),
64 ui::PAGE_TRANSITION_TYPED
,
68 void CastServiceSimple::StopInternal() {
69 web_contents_
->GetRenderViewHost()->ClosePage();
70 web_contents_
.reset();
74 } // namespace chromecast