OLD | NEW |
---|---|
1 // Copyright (c) 2012 The Chromium Authors. All rights reserved. | 1 // Copyright (c) 2012 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/extensions/api/webstore_private/webstore_private_api.h" | 5 #include "chrome/browser/extensions/api/webstore_private/webstore_private_api.h" |
6 | 6 |
7 #include "base/bind_helpers.h" | 7 #include "base/bind_helpers.h" |
8 #include "base/command_line.h" | 8 #include "base/command_line.h" |
9 #include "base/lazy_instance.h" | 9 #include "base/lazy_instance.h" |
10 #include "base/memory/scoped_vector.h" | 10 #include "base/memory/scoped_vector.h" |
(...skipping 83 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... | |
94 | 94 |
95 const char kCannotSpecifyIconDataAndUrlError[] = | 95 const char kCannotSpecifyIconDataAndUrlError[] = |
96 "You cannot specify both icon data and an icon url"; | 96 "You cannot specify both icon data and an icon url"; |
97 const char kInvalidIconUrlError[] = "Invalid icon url"; | 97 const char kInvalidIconUrlError[] = "Invalid icon url"; |
98 const char kInvalidIdError[] = "Invalid id"; | 98 const char kInvalidIdError[] = "Invalid id"; |
99 const char kInvalidManifestError[] = "Invalid manifest"; | 99 const char kInvalidManifestError[] = "Invalid manifest"; |
100 const char kNoPreviousBeginInstallWithManifestError[] = | 100 const char kNoPreviousBeginInstallWithManifestError[] = |
101 "* does not match a previous call to beginInstallWithManifest3"; | 101 "* does not match a previous call to beginInstallWithManifest3"; |
102 const char kUserCancelledError[] = "User cancelled install"; | 102 const char kUserCancelledError[] = "User cancelled install"; |
103 | 103 |
104 ProfileSyncService* test_sync_service = NULL; | 104 ProfileSyncService* test_sync_service = NULL; |
Lei Zhang
2012/09/28 18:41:24
delete
Nico
2012/09/29 11:08:40
Done.
| |
105 | 105 |
106 // Returns either the test sync service, or the real one from |profile|. | |
107 ProfileSyncService* GetSyncService(Profile* profile) { | |
108 // TODO(webstore): It seems |test_sync_service| is not used anywhere. It | |
109 // should be removed. | |
110 if (test_sync_service) | |
111 return test_sync_service; | |
112 else | |
113 return ProfileSyncServiceFactory::GetInstance()->GetForProfile(profile); | |
114 } | |
115 | |
116 // Helper to create a dictionary with login and token properties set from | 106 // Helper to create a dictionary with login and token properties set from |
117 // the appropriate values in the passed-in |profile|. | 107 // the appropriate values in the passed-in |profile|. |
118 DictionaryValue* CreateLoginResult(Profile* profile) { | 108 DictionaryValue* CreateLoginResult(Profile* profile) { |
119 DictionaryValue* dictionary = new DictionaryValue(); | 109 DictionaryValue* dictionary = new DictionaryValue(); |
120 std::string username = profile->GetPrefs()->GetString( | 110 std::string username = profile->GetPrefs()->GetString( |
121 prefs::kGoogleServicesUsername); | 111 prefs::kGoogleServicesUsername); |
122 dictionary->SetString(kLoginKey, username); | 112 dictionary->SetString(kLoginKey, username); |
123 if (!username.empty()) { | 113 if (!username.empty()) { |
124 CommandLine* cmdline = CommandLine::ForCurrentProcess(); | 114 CommandLine* cmdline = CommandLine::ForCurrentProcess(); |
125 TokenService* token_service = TokenServiceFactory::GetForProfile(profile); | 115 TokenService* token_service = TokenServiceFactory::GetForProfile(profile); |
126 if (cmdline->HasSwitch(switches::kAppsGalleryReturnTokens) && | 116 if (cmdline->HasSwitch(switches::kAppsGalleryReturnTokens) && |
127 token_service->HasTokenForService(GaiaConstants::kGaiaService)) { | 117 token_service->HasTokenForService(GaiaConstants::kGaiaService)) { |
128 dictionary->SetString(kTokenKey, | 118 dictionary->SetString(kTokenKey, |
129 token_service->GetTokenForService( | 119 token_service->GetTokenForService( |
130 GaiaConstants::kGaiaService)); | 120 GaiaConstants::kGaiaService)); |
131 } | 121 } |
132 } | 122 } |
133 return dictionary; | 123 return dictionary; |
134 } | 124 } |
135 | 125 |
136 WebstoreInstaller::Delegate* test_webstore_installer_delegate = NULL; | 126 WebstoreInstaller::Delegate* test_webstore_installer_delegate = NULL; |
137 | 127 |
138 } // namespace | 128 } // namespace |
139 | 129 |
140 // static | 130 // static |
141 void WebstorePrivateApi::SetTestingProfileSyncService( | 131 void WebstorePrivateApi::SetTestingProfileSyncService( |
Lei Zhang
2012/09/28 18:41:24
delete
| |
142 ProfileSyncService* service) { | 132 ProfileSyncService* service) { |
143 test_sync_service = service; | 133 test_sync_service = service; |
144 } | 134 } |
145 | 135 |
146 // static | 136 // static |
147 void WebstorePrivateApi::SetWebstoreInstallerDelegateForTesting( | 137 void WebstorePrivateApi::SetWebstoreInstallerDelegateForTesting( |
148 WebstoreInstaller::Delegate* delegate) { | 138 WebstoreInstaller::Delegate* delegate) { |
149 test_webstore_installer_delegate = delegate; | 139 test_webstore_installer_delegate = delegate; |
150 } | 140 } |
151 | 141 |
(...skipping 367 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... | |
519 feature_checker_->CheckGPUFeatureAvailability(); | 509 feature_checker_->CheckGPUFeatureAvailability(); |
520 return true; | 510 return true; |
521 } | 511 } |
522 | 512 |
523 void GetWebGLStatusFunction::OnFeatureCheck(bool feature_allowed) { | 513 void GetWebGLStatusFunction::OnFeatureCheck(bool feature_allowed) { |
524 CreateResult(feature_allowed); | 514 CreateResult(feature_allowed); |
525 SendResponse(true); | 515 SendResponse(true); |
526 } | 516 } |
527 | 517 |
528 } // namespace extensions | 518 } // namespace extensions |
OLD | NEW |