Chromium Code Reviews
chromiumcodereview-hr@appspot.gserviceaccount.com (chromiumcodereview-hr) | Please choose your nickname with Settings | Help | Chromium Project | Gerrit Changes | Sign out
(41)

Side by Side Diff: chrome/browser/chromeos/login/scoped_gaia_auth_extension.cc

Issue 14643006: [chromeos] Remove dependencies of StatisticsProvider on chrome. (Closed) Base URL: svn://svn.chromium.org/chrome/trunk/src
Patch Set: trybots Created 7 years, 7 months ago
Use n/p to move between diff chunks; N/P to move between comments. Draft comments are only viewable by you.
Jump to:
View unified diff | Download patch | Annotate | Revision Log
OLDNEW
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"
15 #include "grit/browser_resources.h" 16 #include "grit/browser_resources.h"
16 17
17 namespace chromeos { 18 namespace chromeos {
18 19
19 namespace { 20 namespace {
20 21
21 extensions::ComponentLoader* GetComponentLoader(Profile* profile) { 22 extensions::ComponentLoader* GetComponentLoader(Profile* profile) {
22 extensions::ExtensionSystem* extension_system = 23 extensions::ExtensionSystem* extension_system =
23 extensions::ExtensionSystem::Get(profile); 24 extensions::ExtensionSystem::Get(profile);
24 ExtensionService* extension_service = extension_system->extension_service(); 25 ExtensionService* extension_service = extension_system->extension_service();
25 return extension_service->component_loader(); 26 return extension_service->component_loader();
26 } 27 }
27 28
28 void LoadGaiaAuthExtension(Profile* profile) { 29 void LoadGaiaAuthExtension(Profile* profile) {
29 extensions::ComponentLoader* component_loader = GetComponentLoader(profile); 30 extensions::ComponentLoader* component_loader = GetComponentLoader(profile);
30 const CommandLine* command_line = CommandLine::ForCurrentProcess(); 31 const CommandLine* command_line = CommandLine::ForCurrentProcess();
31 if (command_line->HasSwitch(switches::kAuthExtensionPath)) { 32 if (command_line->HasSwitch(switches::kAuthExtensionPath)) {
32 base::FilePath auth_extension_path = 33 base::FilePath auth_extension_path =
33 command_line->GetSwitchValuePath(switches::kAuthExtensionPath); 34 command_line->GetSwitchValuePath(switches::kAuthExtensionPath);
34 component_loader->Add(IDR_GAIA_TEST_AUTH_MANIFEST, auth_extension_path); 35 component_loader->Add(IDR_GAIA_TEST_AUTH_MANIFEST, auth_extension_path);
35 return; 36 return;
36 } 37 }
37 38
38 bool force_keyboard_oobe = false; 39 bool force_keyboard_oobe = false;
39 chromeos::system::StatisticsProvider* provider = 40 chromeos::system::StatisticsProvider* provider =
40 chromeos::system::StatisticsProvider::GetInstance(); 41 chromeos::system::StatisticsProvider::GetInstance();
41 provider->GetMachineFlag(chrome::kOemKeyboardDrivenOobeKey, 42 provider->GetMachineFlag(chromeos::kOemKeyboardDrivenOobeKey,
42 &force_keyboard_oobe); 43 &force_keyboard_oobe);
43 if (force_keyboard_oobe) { 44 if (force_keyboard_oobe) {
44 component_loader->Add(IDR_GAIA_AUTH_KEYBOARD_MANIFEST, 45 component_loader->Add(IDR_GAIA_AUTH_KEYBOARD_MANIFEST,
45 base::FilePath(FILE_PATH_LITERAL("gaia_auth"))); 46 base::FilePath(FILE_PATH_LITERAL("gaia_auth")));
46 } else { 47 } else {
47 component_loader->Add(IDR_GAIA_AUTH_MANIFEST, 48 component_loader->Add(IDR_GAIA_AUTH_MANIFEST,
48 base::FilePath(FILE_PATH_LITERAL("gaia_auth"))); 49 base::FilePath(FILE_PATH_LITERAL("gaia_auth")));
49 } 50 }
50 } 51 }
51 52
52 void UnloadGaiaAuthExtension(Profile* profile) { 53 void UnloadGaiaAuthExtension(Profile* profile) {
53 const char kGaiaAuthId[] = "mfffpogegjflfpflabcdkioaeobkgjik"; 54 const char kGaiaAuthId[] = "mfffpogegjflfpflabcdkioaeobkgjik";
54 GetComponentLoader(profile)->Remove(kGaiaAuthId); 55 GetComponentLoader(profile)->Remove(kGaiaAuthId);
55 } 56 }
56 57
57 } // namespace 58 } // namespace
58 59
59 ScopedGaiaAuthExtension::ScopedGaiaAuthExtension(Profile* profile) 60 ScopedGaiaAuthExtension::ScopedGaiaAuthExtension(Profile* profile)
60 : profile_(profile) { 61 : profile_(profile) {
61 LoadGaiaAuthExtension(profile_); 62 LoadGaiaAuthExtension(profile_);
62 } 63 }
63 64
64 ScopedGaiaAuthExtension::~ScopedGaiaAuthExtension() { 65 ScopedGaiaAuthExtension::~ScopedGaiaAuthExtension() {
65 UnloadGaiaAuthExtension(profile_); 66 UnloadGaiaAuthExtension(profile_);
66 } 67 }
67 68
68 } // namespace chromeos 69 } // namespace chromeos
OLDNEW

Powered by Google App Engine
This is Rietveld 408576698