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; | |
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 | 104 // Helper to create a dictionary with login and token properties set from |
117 // the appropriate values in the passed-in |profile|. | 105 // the appropriate values in the passed-in |profile|. |
118 DictionaryValue* CreateLoginResult(Profile* profile) { | 106 DictionaryValue* CreateLoginResult(Profile* profile) { |
119 DictionaryValue* dictionary = new DictionaryValue(); | 107 DictionaryValue* dictionary = new DictionaryValue(); |
120 std::string username = profile->GetPrefs()->GetString( | 108 std::string username = profile->GetPrefs()->GetString( |
121 prefs::kGoogleServicesUsername); | 109 prefs::kGoogleServicesUsername); |
122 dictionary->SetString(kLoginKey, username); | 110 dictionary->SetString(kLoginKey, username); |
123 if (!username.empty()) { | 111 if (!username.empty()) { |
124 CommandLine* cmdline = CommandLine::ForCurrentProcess(); | 112 CommandLine* cmdline = CommandLine::ForCurrentProcess(); |
125 TokenService* token_service = TokenServiceFactory::GetForProfile(profile); | 113 TokenService* token_service = TokenServiceFactory::GetForProfile(profile); |
126 if (cmdline->HasSwitch(switches::kAppsGalleryReturnTokens) && | 114 if (cmdline->HasSwitch(switches::kAppsGalleryReturnTokens) && |
127 token_service->HasTokenForService(GaiaConstants::kGaiaService)) { | 115 token_service->HasTokenForService(GaiaConstants::kGaiaService)) { |
128 dictionary->SetString(kTokenKey, | 116 dictionary->SetString(kTokenKey, |
129 token_service->GetTokenForService( | 117 token_service->GetTokenForService( |
130 GaiaConstants::kGaiaService)); | 118 GaiaConstants::kGaiaService)); |
131 } | 119 } |
132 } | 120 } |
133 return dictionary; | 121 return dictionary; |
134 } | 122 } |
135 | 123 |
136 WebstoreInstaller::Delegate* test_webstore_installer_delegate = NULL; | 124 WebstoreInstaller::Delegate* test_webstore_installer_delegate = NULL; |
137 | 125 |
138 } // namespace | 126 } // namespace |
139 | 127 |
140 // static | 128 // static |
141 void WebstorePrivateApi::SetTestingProfileSyncService( | |
142 ProfileSyncService* service) { | |
143 test_sync_service = service; | |
144 } | |
145 | |
146 // static | |
147 void WebstorePrivateApi::SetWebstoreInstallerDelegateForTesting( | 129 void WebstorePrivateApi::SetWebstoreInstallerDelegateForTesting( |
148 WebstoreInstaller::Delegate* delegate) { | 130 WebstoreInstaller::Delegate* delegate) { |
149 test_webstore_installer_delegate = delegate; | 131 test_webstore_installer_delegate = delegate; |
150 } | 132 } |
151 | 133 |
152 // static | 134 // static |
153 scoped_ptr<WebstoreInstaller::Approval> | 135 scoped_ptr<WebstoreInstaller::Approval> |
154 WebstorePrivateApi::PopApprovalForTesting( | 136 WebstorePrivateApi::PopApprovalForTesting( |
155 Profile* profile, const std::string& extension_id) { | 137 Profile* profile, const std::string& extension_id) { |
156 return g_pending_approvals.Get().PopApproval(profile, extension_id); | 138 return g_pending_approvals.Get().PopApproval(profile, extension_id); |
(...skipping 362 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
519 feature_checker_->CheckGPUFeatureAvailability(); | 501 feature_checker_->CheckGPUFeatureAvailability(); |
520 return true; | 502 return true; |
521 } | 503 } |
522 | 504 |
523 void GetWebGLStatusFunction::OnFeatureCheck(bool feature_allowed) { | 505 void GetWebGLStatusFunction::OnFeatureCheck(bool feature_allowed) { |
524 CreateResult(feature_allowed); | 506 CreateResult(feature_allowed); |
525 SendResponse(true); | 507 SendResponse(true); |
526 } | 508 } |
527 | 509 |
528 } // namespace extensions | 510 } // namespace extensions |
OLD | NEW |