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

Side by Side Diff: chrome/browser/extensions/api/identity/identity_apitest.cc

Issue 178193030: Rename ProfileKeyedAPI to BrowserContextKeyedAPI and GetProfile to Get. (Closed) Base URL: svn://svn.chromium.org/chrome/trunk/src
Patch Set: nits Created 6 years, 9 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 (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 "base/command_line.h" 5 #include "base/command_line.h"
6 #include "base/strings/string_util.h" 6 #include "base/strings/string_util.h"
7 #include "base/strings/stringprintf.h" 7 #include "base/strings/stringprintf.h"
8 #include "base/values.h" 8 #include "base/values.h"
9 #include "chrome/browser/chrome_notification_types.h" 9 #include "chrome/browser/chrome_notification_types.h"
10 #include "chrome/browser/extensions/api/identity/identity_api.h" 10 #include "chrome/browser/extensions/api/identity/identity_api.h"
(...skipping 355 matching lines...) Expand 10 before | Expand all | Expand 10 after
366 oauth2_info.scopes.push_back("scope2"); 366 oauth2_info.scopes.push_back("scope2");
367 } 367 }
368 368
369 extension_id_ = ext->id(); 369 extension_id_ = ext->id();
370 oauth_scopes_ = std::set<std::string>(oauth2_info.scopes.begin(), 370 oauth_scopes_ = std::set<std::string>(oauth2_info.scopes.begin(),
371 oauth2_info.scopes.end()); 371 oauth2_info.scopes.end());
372 return ext; 372 return ext;
373 } 373 }
374 374
375 IdentityAPI* id_api() { 375 IdentityAPI* id_api() {
376 return IdentityAPI::GetFactoryInstance()->GetForProfile( 376 return IdentityAPI::GetFactoryInstance()->Get(browser()->profile());
377 browser()->profile());
378 } 377 }
379 378
380 const std::string GetPrimaryAccountId() { 379 const std::string GetPrimaryAccountId() {
381 SigninManagerBase* signin_manager = 380 SigninManagerBase* signin_manager =
382 SigninManagerFactory::GetForProfile(browser()->profile()); 381 SigninManagerFactory::GetForProfile(browser()->profile());
383 return signin_manager->GetAuthenticatedAccountId(); 382 return signin_manager->GetAuthenticatedAccountId();
384 } 383 }
385 384
386 void SetCachedToken(const IdentityTokenCacheValue& token_data) { 385 void SetCachedToken(const IdentityTokenCacheValue& token_data) {
387 ExtensionTokenKey key(extension_id_, GetPrimaryAccountId(), oauth_scopes_); 386 ExtensionTokenKey key(extension_id_, GetPrimaryAccountId(), oauth_scopes_);
(...skipping 661 matching lines...) Expand 10 before | Expand all | Expand 10 after
1049 new IdentityRemoveCachedAuthTokenFunction); 1048 new IdentityRemoveCachedAuthTokenFunction);
1050 func->set_extension(utils::CreateEmptyExtension(kExtensionId).get()); 1049 func->set_extension(utils::CreateEmptyExtension(kExtensionId).get());
1051 return utils::RunFunction( 1050 return utils::RunFunction(
1052 func.get(), 1051 func.get(),
1053 std::string("[{\"token\": \"") + kAccessToken + "\"}]", 1052 std::string("[{\"token\": \"") + kAccessToken + "\"}]",
1054 browser(), 1053 browser(),
1055 extension_function_test_utils::NONE); 1054 extension_function_test_utils::NONE);
1056 } 1055 }
1057 1056
1058 IdentityAPI* id_api() { 1057 IdentityAPI* id_api() {
1059 return IdentityAPI::GetFactoryInstance()->GetForProfile( 1058 return IdentityAPI::GetFactoryInstance()->Get(browser()->profile());
1060 browser()->profile());
1061 } 1059 }
1062 1060
1063 void SetCachedToken(IdentityTokenCacheValue& token_data) { 1061 void SetCachedToken(IdentityTokenCacheValue& token_data) {
1064 ExtensionTokenKey key(extensions::id_util::GenerateId(kExtensionId), 1062 ExtensionTokenKey key(extensions::id_util::GenerateId(kExtensionId),
1065 "test@example.com", 1063 "test@example.com",
1066 std::set<std::string>()); 1064 std::set<std::string>());
1067 id_api()->SetCachedToken(key, token_data); 1065 id_api()->SetCachedToken(key, token_data);
1068 } 1066 }
1069 1067
1070 const IdentityTokenCacheValue& GetCachedToken() { 1068 const IdentityTokenCacheValue& GetCachedToken() {
(...skipping 201 matching lines...) Expand 10 before | Expand all | Expand 10 after
1272 EXPECT_EQ(std::string("https://abcdefghij.chromiumapp.org/callback#test"), 1270 EXPECT_EQ(std::string("https://abcdefghij.chromiumapp.org/callback#test"),
1273 url); 1271 url);
1274 } 1272 }
1275 1273
1276 } // namespace extensions 1274 } // namespace extensions
1277 1275
1278 // Tests the chrome.identity API implemented by custom JS bindings . 1276 // Tests the chrome.identity API implemented by custom JS bindings .
1279 IN_PROC_BROWSER_TEST_F(ExtensionApiTest, ChromeIdentityJsBindings) { 1277 IN_PROC_BROWSER_TEST_F(ExtensionApiTest, ChromeIdentityJsBindings) {
1280 ASSERT_TRUE(RunExtensionTest("identity/js_bindings")) << message_; 1278 ASSERT_TRUE(RunExtensionTest("identity/js_bindings")) << message_;
1281 } 1279 }
OLDNEW

Powered by Google App Engine
This is Rietveld 408576698