Chromium Code Reviews| OLD | NEW |
|---|---|
| 1 // Copyright 2014 The Chromium Authors. All rights reserved. | 1 // Copyright 2014 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/supervised_user/child_accounts/family_info_fetcher.h" | 5 #include "chrome/browser/supervised_user/child_accounts/family_info_fetcher.h" |
| 6 | 6 |
| 7 #include <stddef.h> | 7 #include <stddef.h> |
| 8 | 8 |
| 9 #include "base/json/json_reader.h" | 9 #include "base/json/json_reader.h" |
| 10 #include "base/macros.h" | 10 #include "base/macros.h" |
| 11 #include "base/strings/stringprintf.h" | 11 #include "base/strings/stringprintf.h" |
| 12 #include "base/values.h" | 12 #include "base/values.h" |
| 13 #include "chrome/browser/supervised_user/child_accounts/kids_management_api.h" | 13 #include "chrome/browser/supervised_user/child_accounts/kids_management_api.h" |
| 14 #include "components/data_use_measurement/core/data_use_user_data.h" | 14 #include "components/data_use_measurement/core/data_use_user_data.h" |
| 15 #include "net/base/load_flags.h" | 15 #include "net/base/load_flags.h" |
| 16 #include "net/http/http_status_code.h" | 16 #include "net/http/http_status_code.h" |
| 17 #include "net/traffic_annotation/network_traffic_annotation.h" | |
| 17 #include "net/url_request/url_request_status.h" | 18 #include "net/url_request/url_request_status.h" |
| 18 #include "url/gurl.h" | 19 #include "url/gurl.h" |
| 19 | 20 |
| 20 const char kGetFamilyProfileApiPath[] = "families/mine?alt=json"; | 21 const char kGetFamilyProfileApiPath[] = "families/mine?alt=json"; |
| 21 const char kGetFamilyMembersApiPath[] = "families/mine/members?alt=json"; | 22 const char kGetFamilyMembersApiPath[] = "families/mine/members?alt=json"; |
| 22 const char kScope[] = "https://www.googleapis.com/auth/kid.family.readonly"; | 23 const char kScope[] = "https://www.googleapis.com/auth/kid.family.readonly"; |
| 23 const char kAuthorizationHeaderFormat[] = "Authorization: Bearer %s"; | 24 const char kAuthorizationHeaderFormat[] = "Authorization: Bearer %s"; |
| 24 const int kNumRetries = 1; | 25 const int kNumRetries = 1; |
| 25 | 26 |
| 26 const char kIdFamily[] = "family"; | 27 const char kIdFamily[] = "family"; |
| (...skipping 137 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... | |
| 164 | 165 |
| 165 void FamilyInfoFetcher::OnGetTokenSuccess( | 166 void FamilyInfoFetcher::OnGetTokenSuccess( |
| 166 const OAuth2TokenService::Request* request, | 167 const OAuth2TokenService::Request* request, |
| 167 const std::string& access_token, | 168 const std::string& access_token, |
| 168 const base::Time& expiration_time) { | 169 const base::Time& expiration_time) { |
| 169 DCHECK_EQ(access_token_request_.get(), request); | 170 DCHECK_EQ(access_token_request_.get(), request); |
| 170 access_token_ = access_token; | 171 access_token_ = access_token; |
| 171 | 172 |
| 172 GURL url = kids_management_api::GetURL(request_path_); | 173 GURL url = kids_management_api::GetURL(request_path_); |
| 173 const int id = 0; | 174 const int id = 0; |
| 174 url_fetcher_ = net::URLFetcher::Create(id, url, net::URLFetcher::GET, this); | 175 net::NetworkTrafficAnnotationTag traffic_annotation = |
| 176 net::DefineNetworkTrafficAnnotation("...", R"( | |
|
Bernhard Bauer
2017/03/14 10:02:48
family_info
Ramin Halavati
2017/03/14 10:56:19
Done.
| |
| 177 semantics { | |
| 178 sender: "..." | |
|
Bernhard Bauer
2017/03/14 10:02:48
supervised_users
Ramin Halavati
2017/03/14 10:56:19
Done.
| |
| 179 description: "..." | |
|
Bernhard Bauer
2017/03/14 10:02:47
Fetches information about the user's family group
Ramin Halavati
2017/03/14 10:56:19
Done.
| |
| 180 trigger: "..." | |
|
Bernhard Bauer
2017/03/14 10:02:48
Triggered in regular intervals to update profile i
Ramin Halavati
2017/03/14 10:56:19
Done.
| |
| 181 data: "..." | |
|
Bernhard Bauer
2017/03/14 10:02:47
The request is authenticated with an OAuth2 access
Ramin Halavati
2017/03/14 10:56:19
Done.
| |
| 182 destination: WEBSITE/GOOGLE_OWNED_SERVICE/OTHER | |
|
Bernhard Bauer
2017/03/14 10:02:47
GOOGLE_OWNED_SERVICE
Ramin Halavati
2017/03/14 10:56:19
Done.
| |
| 183 } | |
| 184 policy { | |
| 185 cookies_allowed: false/true | |
|
Bernhard Bauer
2017/03/14 10:02:47
false
Ramin Halavati
2017/03/14 10:56:19
Done.
| |
| 186 cookies_store: "..." | |
|
Bernhard Bauer
2017/03/14 10:02:48
user
Ramin Halavati
2017/03/14 10:56:19
Done.
| |
| 187 setting: "..." | |
|
Bernhard Bauer
2017/03/14 10:02:48
This feature is only enabled for child accounts. I
Ramin Halavati
2017/03/14 10:56:19
Done.
| |
| 188 chrome_policy { | |
| 189 [POLICY_NAME] { | |
|
Bernhard Bauer
2017/03/14 10:02:48
RestrictSigninToPattern
Ramin Halavati
2017/03/14 10:56:19
Done.
| |
| 190 policy_options {mode: MANDATORY/RECOMMENDED/UNSET} | |
|
Bernhard Bauer
2017/03/14 10:02:48
MANDATORY
Ramin Halavati
2017/03/14 10:56:19
Done.
| |
| 191 [POLICY_NAME]: ... //(value to disable it) | |
|
Bernhard Bauer
2017/03/14 10:02:48
"*@manageddomain.com"
Ramin Halavati
2017/03/14 10:56:19
Done.
| |
| 192 } | |
| 193 } | |
| 194 policy_exception_justification: "..." | |
| 195 })"); | |
| 196 url_fetcher_ = net::URLFetcher::Create(id, url, net::URLFetcher::GET, this, | |
| 197 traffic_annotation); | |
| 175 | 198 |
| 176 data_use_measurement::DataUseUserData::AttachToFetcher( | 199 data_use_measurement::DataUseUserData::AttachToFetcher( |
| 177 url_fetcher_.get(), | 200 url_fetcher_.get(), |
| 178 data_use_measurement::DataUseUserData::SUPERVISED_USER); | 201 data_use_measurement::DataUseUserData::SUPERVISED_USER); |
| 179 url_fetcher_->SetRequestContext(request_context_); | 202 url_fetcher_->SetRequestContext(request_context_); |
| 180 url_fetcher_->SetLoadFlags(net::LOAD_DO_NOT_SEND_COOKIES | | 203 url_fetcher_->SetLoadFlags(net::LOAD_DO_NOT_SEND_COOKIES | |
| 181 net::LOAD_DO_NOT_SAVE_COOKIES); | 204 net::LOAD_DO_NOT_SAVE_COOKIES); |
| 182 url_fetcher_->SetAutomaticallyRetryOnNetworkChanges(kNumRetries); | 205 url_fetcher_->SetAutomaticallyRetryOnNetworkChanges(kNumRetries); |
| 183 url_fetcher_->AddExtraRequestHeader( | 206 url_fetcher_->AddExtraRequestHeader( |
| 184 base::StringPrintf(kAuthorizationHeaderFormat, access_token.c_str())); | 207 base::StringPrintf(kAuthorizationHeaderFormat, access_token.c_str())); |
| (...skipping 132 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... | |
| 317 consumer_->OnFailure(SERVICE_ERROR); | 340 consumer_->OnFailure(SERVICE_ERROR); |
| 318 return; | 341 return; |
| 319 } | 342 } |
| 320 std::vector<FamilyMember> members; | 343 std::vector<FamilyMember> members; |
| 321 if (!ParseMembers(members_list, &members)){ | 344 if (!ParseMembers(members_list, &members)){ |
| 322 consumer_->OnFailure(SERVICE_ERROR); | 345 consumer_->OnFailure(SERVICE_ERROR); |
| 323 return; | 346 return; |
| 324 } | 347 } |
| 325 consumer_->OnGetFamilyMembersSuccess(members); | 348 consumer_->OnGetFamilyMembersSuccess(members); |
| 326 } | 349 } |
| OLD | NEW |