OLD | NEW |
1 // Copyright 2013 The Chromium Authors. All rights reserved. | 1 // Copyright 2013 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 "chrome/browser/chromeos/login/scoped_gaia_auth_extension.h" | 5 #include "chrome/browser/chromeos/login/scoped_gaia_auth_extension.h" |
6 | 6 |
7 #include "base/command_line.h" | 7 #include "base/command_line.h" |
8 #include "chrome/browser/chromeos/system/statistics_provider.h" | 8 #include "chrome/browser/chromeos/system/statistics_provider.h" |
9 #include "chrome/browser/extensions/component_loader.h" | 9 #include "chrome/browser/extensions/component_loader.h" |
10 #include "chrome/browser/extensions/extension_service.h" | 10 #include "chrome/browser/extensions/extension_service.h" |
11 #include "chrome/browser/extensions/extension_system.h" | 11 #include "chrome/browser/extensions/extension_system.h" |
12 #include "chrome/browser/profiles/profile.h" | 12 #include "chrome/browser/profiles/profile.h" |
13 #include "chrome/common/chrome_constants.h" | 13 #include "chrome/common/chrome_constants.h" |
14 #include "chrome/common/chrome_switches.h" | 14 #include "chrome/common/chrome_switches.h" |
15 #include "chromeos/chromeos_constants.h" | |
16 #include "grit/browser_resources.h" | 15 #include "grit/browser_resources.h" |
17 | 16 |
18 namespace chromeos { | 17 namespace chromeos { |
19 | 18 |
20 namespace { | 19 namespace { |
21 | 20 |
22 extensions::ComponentLoader* GetComponentLoader(Profile* profile) { | 21 extensions::ComponentLoader* GetComponentLoader(Profile* profile) { |
23 extensions::ExtensionSystem* extension_system = | 22 extensions::ExtensionSystem* extension_system = |
24 extensions::ExtensionSystem::Get(profile); | 23 extensions::ExtensionSystem::Get(profile); |
25 ExtensionService* extension_service = extension_system->extension_service(); | 24 ExtensionService* extension_service = extension_system->extension_service(); |
26 return extension_service->component_loader(); | 25 return extension_service->component_loader(); |
27 } | 26 } |
28 | 27 |
29 void LoadGaiaAuthExtension(Profile* profile) { | 28 void LoadGaiaAuthExtension(Profile* profile) { |
30 extensions::ComponentLoader* component_loader = GetComponentLoader(profile); | 29 extensions::ComponentLoader* component_loader = GetComponentLoader(profile); |
31 const CommandLine* command_line = CommandLine::ForCurrentProcess(); | 30 const CommandLine* command_line = CommandLine::ForCurrentProcess(); |
32 if (command_line->HasSwitch(switches::kAuthExtensionPath)) { | 31 if (command_line->HasSwitch(switches::kAuthExtensionPath)) { |
33 base::FilePath auth_extension_path = | 32 base::FilePath auth_extension_path = |
34 command_line->GetSwitchValuePath(switches::kAuthExtensionPath); | 33 command_line->GetSwitchValuePath(switches::kAuthExtensionPath); |
35 component_loader->Add(IDR_GAIA_TEST_AUTH_MANIFEST, auth_extension_path); | 34 component_loader->Add(IDR_GAIA_TEST_AUTH_MANIFEST, auth_extension_path); |
36 return; | 35 return; |
37 } | 36 } |
38 | 37 |
39 bool force_keyboard_oobe = false; | 38 bool force_keyboard_oobe = false; |
40 chromeos::system::StatisticsProvider* provider = | 39 chromeos::system::StatisticsProvider* provider = |
41 chromeos::system::StatisticsProvider::GetInstance(); | 40 chromeos::system::StatisticsProvider::GetInstance(); |
42 provider->GetMachineFlag(chromeos::kOemKeyboardDrivenOobeKey, | 41 provider->GetMachineFlag(chrome::kOemKeyboardDrivenOobeKey, |
43 &force_keyboard_oobe); | 42 &force_keyboard_oobe); |
44 if (force_keyboard_oobe) { | 43 if (force_keyboard_oobe) { |
45 component_loader->Add(IDR_GAIA_AUTH_KEYBOARD_MANIFEST, | 44 component_loader->Add(IDR_GAIA_AUTH_KEYBOARD_MANIFEST, |
46 base::FilePath(FILE_PATH_LITERAL("gaia_auth"))); | 45 base::FilePath(FILE_PATH_LITERAL("gaia_auth"))); |
47 } else { | 46 } else { |
48 component_loader->Add(IDR_GAIA_AUTH_MANIFEST, | 47 component_loader->Add(IDR_GAIA_AUTH_MANIFEST, |
49 base::FilePath(FILE_PATH_LITERAL("gaia_auth"))); | 48 base::FilePath(FILE_PATH_LITERAL("gaia_auth"))); |
50 } | 49 } |
51 } | 50 } |
52 | 51 |
53 void UnloadGaiaAuthExtension(Profile* profile) { | 52 void UnloadGaiaAuthExtension(Profile* profile) { |
54 const char kGaiaAuthId[] = "mfffpogegjflfpflabcdkioaeobkgjik"; | 53 const char kGaiaAuthId[] = "mfffpogegjflfpflabcdkioaeobkgjik"; |
55 GetComponentLoader(profile)->Remove(kGaiaAuthId); | 54 GetComponentLoader(profile)->Remove(kGaiaAuthId); |
56 } | 55 } |
57 | 56 |
58 } // namespace | 57 } // namespace |
59 | 58 |
60 ScopedGaiaAuthExtension::ScopedGaiaAuthExtension(Profile* profile) | 59 ScopedGaiaAuthExtension::ScopedGaiaAuthExtension(Profile* profile) |
61 : profile_(profile) { | 60 : profile_(profile) { |
62 LoadGaiaAuthExtension(profile_); | 61 LoadGaiaAuthExtension(profile_); |
63 } | 62 } |
64 | 63 |
65 ScopedGaiaAuthExtension::~ScopedGaiaAuthExtension() { | 64 ScopedGaiaAuthExtension::~ScopedGaiaAuthExtension() { |
66 UnloadGaiaAuthExtension(profile_); | 65 UnloadGaiaAuthExtension(profile_); |
67 } | 66 } |
68 | 67 |
69 } // namespace chromeos | 68 } // namespace chromeos |
OLD | NEW |