Pin Chrome's shortcut to the Win10 Start menu on install and OS upgrade.
[chromium-blink-merge.git] / chromecast / browser / service / cast_service_simple.cc
blob2a40b3e16df58646ede57f86dd0e818f380e176a
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 "base/files/file_util.h"
9 #include "chromecast/browser/cast_content_window.h"
10 #include "content/public/browser/render_view_host.h"
11 #include "content/public/browser/web_contents.h"
12 #include "net/base/filename_util.h"
13 #include "net/url_request/url_request_context_getter.h"
15 namespace chromecast {
17 namespace {
19 GURL GetStartupURL() {
20 base::CommandLine* command_line = base::CommandLine::ForCurrentProcess();
21 const base::CommandLine::StringVector& args = command_line->GetArgs();
23 if (args.empty())
24 return GURL("http://www.google.com/");
26 GURL url(args[0]);
27 if (url.is_valid() && url.has_scheme())
28 return url;
30 return net::FilePathToFileURL(
31 base::MakeAbsoluteFilePath(base::FilePath(args[0])));
34 } // namespace
36 // static
37 scoped_ptr<CastService> CastService::Create(
38 content::BrowserContext* browser_context,
39 PrefService* pref_service,
40 metrics::CastMetricsServiceClient* metrics_service_client,
41 net::URLRequestContextGetter* request_context_getter) {
42 return scoped_ptr<CastService>(new CastServiceSimple(browser_context,
43 pref_service,
44 metrics_service_client));
47 CastServiceSimple::CastServiceSimple(
48 content::BrowserContext* browser_context,
49 PrefService* pref_service,
50 metrics::CastMetricsServiceClient* metrics_service_client)
51 : CastService(browser_context, pref_service, metrics_service_client) {
54 CastServiceSimple::~CastServiceSimple() {
57 void CastServiceSimple::InitializeInternal() {
58 startup_url_ = GetStartupURL();
61 void CastServiceSimple::FinalizeInternal() {
64 void CastServiceSimple::StartInternal() {
65 // This is the simple version that hard-codes the size.
66 gfx::Size initial_size(1280, 720);
68 window_.reset(new CastContentWindow);
69 web_contents_ = window_->CreateWebContents(initial_size, browser_context());
70 window_->CreateWindowTree(initial_size, web_contents_.get());
72 web_contents_->GetController().LoadURL(startup_url_, content::Referrer(),
73 ui::PAGE_TRANSITION_TYPED,
74 std::string());
77 void CastServiceSimple::StopInternal() {
78 web_contents_->ClosePage();
79 web_contents_.reset();
80 window_.reset();
83 } // namespace chromecast