OLD | NEW |
1 // Copyright (c) 2011 The Chromium Authors. All rights reserved. | 1 // Copyright (c) 2011 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/extension_webstore_private_api.h" | 5 #include "chrome/browser/extensions/extension_webstore_private_api.h" |
6 | 6 |
7 #include <string> | 7 #include <string> |
8 | 8 |
9 #include "base/string_util.h" | 9 #include "base/string_util.h" |
10 #include "base/utf_string_conversions.h" | 10 #include "base/utf_string_conversions.h" |
(...skipping 54 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
65 return profile->GetProfileSyncService(); | 65 return profile->GetProfileSyncService(); |
66 } | 66 } |
67 | 67 |
68 bool IsWebStoreURL(Profile* profile, const GURL& url) { | 68 bool IsWebStoreURL(Profile* profile, const GURL& url) { |
69 ExtensionService* service = profile->GetExtensionService(); | 69 ExtensionService* service = profile->GetExtensionService(); |
70 const Extension* store = service->GetWebStoreApp(); | 70 const Extension* store = service->GetWebStoreApp(); |
71 if (!store) { | 71 if (!store) { |
72 NOTREACHED(); | 72 NOTREACHED(); |
73 return false; | 73 return false; |
74 } | 74 } |
75 return (service->GetExtensionByWebExtent(url) == store); | 75 return (service->extensions()->GetByWebExtent(ExtensionURLInfo(url)) == |
| 76 store); |
76 } | 77 } |
77 | 78 |
78 // Whitelists extension IDs for use by webstorePrivate.silentlyInstall. | 79 // Whitelists extension IDs for use by webstorePrivate.silentlyInstall. |
79 bool trust_test_ids = false; | 80 bool trust_test_ids = false; |
80 | 81 |
81 bool IsTrustedForSilentInstall(const std::string& id) { | 82 bool IsTrustedForSilentInstall(const std::string& id) { |
82 // Trust the extensions in api_test/webstore_private/bundle when the flag | 83 // Trust the extensions in api_test/webstore_private/bundle when the flag |
83 // is set. | 84 // is set. |
84 if (trust_test_ids && | 85 if (trust_test_ids && |
85 (id == "begfmnajjkbjdgmffnjaojchoncnmngg" || | 86 (id == "begfmnajjkbjdgmffnjaojchoncnmngg" || |
(...skipping 398 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
484 bool SetStoreLoginFunction::RunImpl() { | 485 bool SetStoreLoginFunction::RunImpl() { |
485 if (!IsWebStoreURL(profile_, source_url())) | 486 if (!IsWebStoreURL(profile_, source_url())) |
486 return false; | 487 return false; |
487 std::string login; | 488 std::string login; |
488 EXTENSION_FUNCTION_VALIDATE(args_->GetString(0, &login)); | 489 EXTENSION_FUNCTION_VALIDATE(args_->GetString(0, &login)); |
489 ExtensionService* service = profile_->GetExtensionService(); | 490 ExtensionService* service = profile_->GetExtensionService(); |
490 ExtensionPrefs* prefs = service->extension_prefs(); | 491 ExtensionPrefs* prefs = service->extension_prefs(); |
491 prefs->SetWebStoreLogin(login); | 492 prefs->SetWebStoreLogin(login); |
492 return true; | 493 return true; |
493 } | 494 } |
OLD | NEW |