Pin Chrome's shortcut to the Win10 Start menu on install and OS upgrade.
[chromium-blink-merge.git] / chromecast / browser / cast_browser_process.cc
blobd3cfbfa9eade8c148a9905c0155d16a19a4a8533
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/cast_browser_process.h"
7 #include "base/logging.h"
8 #include "base/prefs/pref_service.h"
9 #include "chromecast/base/metrics/cast_metrics_helper.h"
10 #include "chromecast/browser/cast_browser_context.h"
11 #include "chromecast/browser/cast_resource_dispatcher_host_delegate.h"
12 #include "chromecast/browser/devtools/remote_debugging_server.h"
13 #include "chromecast/browser/metrics/cast_metrics_service_client.h"
14 #include "chromecast/browser/service/cast_service.h"
15 #include "chromecast/net/connectivity_checker.h"
17 #if defined(OS_ANDROID)
18 #include "components/crash/browser/crash_dump_manager_android.h"
19 #endif // defined(OS_ANDROID)
21 #if defined(USE_AURA)
22 #include "chromecast/graphics/cast_screen.h"
23 #endif // defined(USE_AURA)
25 namespace chromecast {
26 namespace shell {
28 namespace {
29 CastBrowserProcess* g_instance = NULL;
30 } // namespace
32 // static
33 CastBrowserProcess* CastBrowserProcess::GetInstance() {
34 DCHECK(g_instance);
35 return g_instance;
38 CastBrowserProcess::CastBrowserProcess()
39 : net_log_(nullptr) {
40 DCHECK(!g_instance);
41 g_instance = this;
44 CastBrowserProcess::~CastBrowserProcess() {
45 DCHECK_EQ(g_instance, this);
46 if (pref_service_)
47 pref_service_->CommitPendingWrite();
48 g_instance = NULL;
51 void CastBrowserProcess::SetBrowserContext(
52 scoped_ptr<CastBrowserContext> browser_context) {
53 DCHECK(!browser_context_);
54 browser_context_.swap(browser_context);
57 void CastBrowserProcess::SetCastService(scoped_ptr<CastService> cast_service) {
58 DCHECK(!cast_service_);
59 cast_service_.swap(cast_service);
62 #if defined(USE_AURA)
63 void CastBrowserProcess::SetCastScreen(scoped_ptr<CastScreen> cast_screen) {
64 DCHECK(!cast_screen_);
65 cast_screen_ = cast_screen.Pass();
67 #endif // defined(USE_AURA)
69 void CastBrowserProcess::SetMetricsHelper(
70 scoped_ptr<metrics::CastMetricsHelper> metrics_helper) {
71 DCHECK(!metrics_helper_);
72 metrics_helper_.swap(metrics_helper);
75 void CastBrowserProcess::SetMetricsServiceClient(
76 scoped_ptr<metrics::CastMetricsServiceClient> metrics_service_client) {
77 DCHECK(!metrics_service_client_);
78 metrics_service_client_.swap(metrics_service_client);
81 void CastBrowserProcess::SetPrefService(scoped_ptr<PrefService> pref_service) {
82 DCHECK(!pref_service_);
83 pref_service_.swap(pref_service);
86 void CastBrowserProcess::SetRemoteDebuggingServer(
87 scoped_ptr<RemoteDebuggingServer> remote_debugging_server) {
88 DCHECK(!remote_debugging_server_);
89 remote_debugging_server_.swap(remote_debugging_server);
92 void CastBrowserProcess::SetResourceDispatcherHostDelegate(
93 scoped_ptr<CastResourceDispatcherHostDelegate> delegate) {
94 DCHECK(!resource_dispatcher_host_delegate_);
95 resource_dispatcher_host_delegate_.swap(delegate);
98 #if defined(OS_ANDROID)
99 void CastBrowserProcess::SetCrashDumpManager(
100 scoped_ptr<breakpad::CrashDumpManager> crash_dump_manager) {
101 DCHECK(!crash_dump_manager_);
102 crash_dump_manager_.swap(crash_dump_manager);
104 #endif // defined(OS_ANDROID)
106 void CastBrowserProcess::SetConnectivityChecker(
107 scoped_refptr<ConnectivityChecker> connectivity_checker) {
108 DCHECK(!connectivity_checker_);
109 connectivity_checker_.swap(connectivity_checker);
112 void CastBrowserProcess::SetNetLog(net::NetLog* net_log) {
113 DCHECK(!net_log_);
114 net_log_ = net_log;
117 } // namespace shell
118 } // namespace chromecast