Pin Chrome's shortcut to the Win10 Start menu on install and OS upgrade.
[chromium-blink-merge.git] / chrome / browser / extensions / api / vpn_provider / vpn_service_factory.cc
bloba46b3280575abaf44248a92cc0ae2ef6f634cab0
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 "extensions/browser/api/vpn_provider/vpn_service_factory.h"
7 #include "base/memory/singleton.h"
8 #include "chrome/browser/chromeos/profiles/profile_helper.h"
9 #include "chrome/browser/profiles/profile.h"
10 #include "chromeos/dbus/dbus_thread_manager.h"
11 #include "chromeos/network/network_handler.h"
12 #include "components/keyed_service/content/browser_context_dependency_manager.h"
13 #include "extensions/browser/api/vpn_provider/vpn_service.h"
14 #include "extensions/browser/event_router.h"
15 #include "extensions/browser/extension_registry.h"
17 namespace chromeos {
19 // static
20 VpnService* VpnServiceFactory::GetForBrowserContext(
21 content::BrowserContext* context) {
22 return static_cast<VpnService*>(
23 GetInstance()->GetServiceForBrowserContext(context, true));
26 // static
27 VpnServiceFactory* VpnServiceFactory::GetInstance() {
28 return Singleton<VpnServiceFactory>::get();
31 VpnServiceFactory::VpnServiceFactory()
32 : BrowserContextKeyedServiceFactory(
33 "VpnService",
34 BrowserContextDependencyManager::GetInstance()) {
37 VpnServiceFactory::~VpnServiceFactory() {
40 bool VpnServiceFactory::ServiceIsCreatedWithBrowserContext() const {
41 return true;
44 bool VpnServiceFactory::ServiceIsNULLWhileTesting() const {
45 return true;
48 KeyedService* VpnServiceFactory::BuildServiceInstanceFor(
49 content::BrowserContext* context) const {
50 if (!chromeos::ProfileHelper::IsPrimaryProfile(
51 Profile::FromBrowserContext(context))) {
52 return nullptr;
54 return new VpnService(
55 context,
56 chromeos::ProfileHelper::GetUserIdHashFromProfile(
57 Profile::FromBrowserContext(context)),
58 extensions::ExtensionRegistry::Get(context),
59 extensions::EventRouter::Get(context),
60 DBusThreadManager::Get()->GetShillThirdPartyVpnDriverClient(),
61 NetworkHandler::Get()->network_configuration_handler(),
62 NetworkHandler::Get()->network_profile_handler(),
63 NetworkHandler::Get()->network_state_handler());
66 } // namespace chromeos