Chromium Code Reviews| OLD | NEW |
|---|---|
| 1 // Copyright 2017 The Chromium Authors. All rights reserved. | 1 // Copyright 2017 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/identity/identity_get_auth_token_functio n.h" | 5 #include "chrome/browser/extensions/api/identity/identity_get_auth_token_functio n.h" |
| 6 | 6 |
| 7 #include "base/strings/string_number_conversions.h" | 7 #include "base/strings/string_number_conversions.h" |
| 8 #include "chrome/browser/extensions/api/identity/identity_api.h" | 8 #include "chrome/browser/extensions/api/identity/identity_api.h" |
| 9 #include "chrome/browser/extensions/api/identity/identity_constants.h" | 9 #include "chrome/browser/extensions/api/identity/identity_constants.h" |
| 10 #include "chrome/browser/profiles/profile.h" | 10 #include "chrome/browser/profiles/profile.h" |
| 11 #include "chrome/browser/signin/chrome_signin_client_factory.h" | 11 #include "chrome/browser/signin/chrome_signin_client_factory.h" |
| 12 #include "chrome/browser/signin/profile_oauth2_token_service_factory.h" | 12 #include "chrome/browser/signin/profile_oauth2_token_service_factory.h" |
| 13 #include "chrome/browser/signin/signin_manager_factory.h" | 13 #include "chrome/browser/signin/signin_manager_factory.h" |
| 14 #include "chrome/common/extensions/api/identity.h" | 14 #include "chrome/common/extensions/api/identity.h" |
| 15 #include "components/signin/core/browser/profile_oauth2_token_service.h" | 15 #include "components/signin/core/browser/profile_oauth2_token_service.h" |
| 16 #include "components/signin/core/browser/signin_manager.h" | 16 #include "components/signin/core/browser/signin_manager.h" |
| 17 #include "components/signin/core/common/profile_management_switches.h" | 17 #include "components/signin/core/common/profile_management_switches.h" |
| 18 #include "extensions/common/extension_l10n_util.h" | 18 #include "extensions/common/extension_l10n_util.h" |
| 19 #include "google_apis/gaia/gaia_urls.h" | 19 #include "google_apis/gaia/gaia_urls.h" |
| 20 #include "net/traffic_annotation/network_traffic_annotation.h" | |
| 20 | 21 |
| 21 #if defined(OS_CHROMEOS) | 22 #if defined(OS_CHROMEOS) |
| 22 #include "chrome/browser/app_mode/app_mode_utils.h" | 23 #include "chrome/browser/app_mode/app_mode_utils.h" |
| 23 #include "chrome/browser/browser_process.h" | 24 #include "chrome/browser/browser_process.h" |
| 24 #include "chrome/browser/chromeos/login/session/user_session_manager.h" | 25 #include "chrome/browser/chromeos/login/session/user_session_manager.h" |
| 25 #include "chrome/browser/chromeos/policy/browser_policy_connector_chromeos.h" | 26 #include "chrome/browser/chromeos/policy/browser_policy_connector_chromeos.h" |
| 26 #include "chrome/browser/chromeos/settings/device_oauth2_token_service.h" | 27 #include "chrome/browser/chromeos/settings/device_oauth2_token_service.h" |
| 27 #include "chrome/browser/chromeos/settings/device_oauth2_token_service_factory.h " | 28 #include "chrome/browser/chromeos/settings/device_oauth2_token_service_factory.h " |
| 28 #include "components/user_manager/user_manager.h" | 29 #include "components/user_manager/user_manager.h" |
| 29 #include "google_apis/gaia/gaia_constants.h" | 30 #include "google_apis/gaia/gaia_constants.h" |
| (...skipping 540 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... | |
| 570 } | 571 } |
| 571 #endif | 572 #endif |
| 572 login_token_request_ = service->StartRequest( | 573 login_token_request_ = service->StartRequest( |
| 573 token_key_->account_id, OAuth2TokenService::ScopeSet(), this); | 574 token_key_->account_id, OAuth2TokenService::ScopeSet(), this); |
| 574 } | 575 } |
| 575 | 576 |
| 576 void IdentityGetAuthTokenFunction::StartGaiaRequest( | 577 void IdentityGetAuthTokenFunction::StartGaiaRequest( |
| 577 const std::string& login_access_token) { | 578 const std::string& login_access_token) { |
| 578 DCHECK(!login_access_token.empty()); | 579 DCHECK(!login_access_token.empty()); |
| 579 mint_token_flow_.reset(CreateMintTokenFlow()); | 580 mint_token_flow_.reset(CreateMintTokenFlow()); |
| 580 mint_token_flow_->Start(GetProfile()->GetRequestContext(), | 581 net::NetworkTrafficAnnotationTag traffic_annotation = |
| 581 login_access_token); | 582 net::DefineNetworkTrafficAnnotation("...", R"( |
| 583 semantics { | |
| 584 sender: "..." | |
|
Michael Courage
2017/05/17 22:59:16
Chrome Identity API maybe? Really the sender is a
Ramin Halavati
2017/05/24 13:04:41
|sender| should represent this module, which is cr
| |
| 585 description: "..." | |
|
Michael Courage
2017/05/17 22:59:16
requests a token from gaia allowing an app or exte
Ramin Halavati
2017/05/24 13:04:40
Done.
| |
| 586 trigger: "..." | |
|
Michael Courage
2017/05/17 22:59:16
api call from the app/extension
Ramin Halavati
2017/05/24 13:04:40
Done.
| |
| 587 data: "..." | |
|
Michael Courage
2017/05/17 22:59:16
The data sent is the user's login token, the ident
Ramin Halavati
2017/05/24 13:04:41
Done.
| |
| 588 destination: WEBSITE/GOOGLE_OWNED_SERVICE/OTHER/LOCAL | |
|
Michael Courage
2017/05/17 22:59:16
talks to a google owned service (gaia)
Ramin Halavati
2017/05/24 13:04:41
Done.
| |
| 589 } | |
| 590 policy { | |
|
Michael Courage
2017/05/17 22:59:16
I guess it's hard to split up these annotations gi
Ramin Halavati
2017/05/24 13:04:40
Acknowledged.
| |
| 591 cookies_allowed: false/true | |
|
Michael Courage
2017/05/17 22:59:16
Looks like OAuth2ApiCallFlow disables cookies
Ramin Halavati
2017/05/24 13:04:41
Done.
| |
| 592 cookies_store: "..." | |
| 593 setting: "..." | |
| 594 chrome_policy { | |
|
Michael Courage
2017/05/17 22:59:16
I don't know much about chrome policy. There's a S
Ramin Halavati
2017/05/24 13:04:41
Acknowledged.
| |
| 595 [POLICY_NAME] { | |
| 596 policy_options {mode: MANDATORY/RECOMMENDED/UNSET} | |
| 597 [POLICY_NAME]: ... //(value to disable it) | |
| 598 } | |
| 599 } | |
| 600 policy_exception_justification: "..." | |
| 601 })"); | |
| 602 mint_token_flow_->Start(GetProfile()->GetRequestContext(), login_access_token, | |
| 603 traffic_annotation); | |
| 582 } | 604 } |
| 583 | 605 |
| 584 void IdentityGetAuthTokenFunction::ShowLoginPopup() { | 606 void IdentityGetAuthTokenFunction::ShowLoginPopup() { |
| 585 signin_flow_.reset(new IdentitySigninFlow(this, GetProfile())); | 607 signin_flow_.reset(new IdentitySigninFlow(this, GetProfile())); |
| 586 signin_flow_->Start(); | 608 signin_flow_->Start(); |
| 587 } | 609 } |
| 588 | 610 |
| 589 void IdentityGetAuthTokenFunction::ShowOAuthApprovalDialog( | 611 void IdentityGetAuthTokenFunction::ShowOAuthApprovalDialog( |
| 590 const IssueAdviceInfo& issue_advice) { | 612 const IssueAdviceInfo& issue_advice) { |
| 591 const std::string locale = extension_l10n_util::CurrentLocaleOrDefault(); | 613 const std::string locale = extension_l10n_util::CurrentLocaleOrDefault(); |
| (...skipping 46 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... | |
| 638 // Component apps using auto_approve may use Chrome's client ID by | 660 // Component apps using auto_approve may use Chrome's client ID by |
| 639 // omitting the field. | 661 // omitting the field. |
| 640 if (client_id.empty() && extension()->location() == Manifest::COMPONENT && | 662 if (client_id.empty() && extension()->location() == Manifest::COMPONENT && |
| 641 oauth2_info.auto_approve) { | 663 oauth2_info.auto_approve) { |
| 642 client_id = GaiaUrls::GetInstance()->oauth2_chrome_client_id(); | 664 client_id = GaiaUrls::GetInstance()->oauth2_chrome_client_id(); |
| 643 } | 665 } |
| 644 return client_id; | 666 return client_id; |
| 645 } | 667 } |
| 646 | 668 |
| 647 } // namespace extensions | 669 } // namespace extensions |
| OLD | NEW |