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/permission_request_creat or_apiary.h" | 5 #include "chrome/browser/supervised_user/child_accounts/permission_request_creat or_apiary.h" |
| 6 | 6 |
| 7 #include "base/callback.h" | 7 #include "base/callback.h" |
| 8 #include "base/command_line.h" | 8 #include "base/command_line.h" |
| 9 #include "base/json/json_reader.h" | 9 #include "base/json/json_reader.h" |
| 10 #include "base/json/json_writer.h" | 10 #include "base/json/json_writer.h" |
| 11 #include "base/logging.h" | 11 #include "base/logging.h" |
| 12 #include "base/memory/ptr_util.h" | 12 #include "base/memory/ptr_util.h" |
| 13 #include "base/strings/stringprintf.h" | 13 #include "base/strings/stringprintf.h" |
| 14 #include "base/values.h" | 14 #include "base/values.h" |
| 15 #include "chrome/browser/profiles/profile.h" | 15 #include "chrome/browser/profiles/profile.h" |
| 16 #include "chrome/browser/signin/profile_oauth2_token_service_factory.h" | 16 #include "chrome/browser/signin/profile_oauth2_token_service_factory.h" |
| 17 #include "chrome/browser/signin/signin_manager_factory.h" | 17 #include "chrome/browser/signin/signin_manager_factory.h" |
| 18 #include "chrome/browser/supervised_user/child_accounts/kids_management_api.h" | 18 #include "chrome/browser/supervised_user/child_accounts/kids_management_api.h" |
| 19 #include "chrome/common/chrome_switches.h" | 19 #include "chrome/common/chrome_switches.h" |
| 20 #include "components/data_use_measurement/core/data_use_user_data.h" | 20 #include "components/data_use_measurement/core/data_use_user_data.h" |
| 21 #include "components/signin/core/browser/profile_oauth2_token_service.h" | 21 #include "components/signin/core/browser/profile_oauth2_token_service.h" |
| 22 #include "components/signin/core/browser/signin_manager.h" | 22 #include "components/signin/core/browser/signin_manager.h" |
| 23 #include "components/signin/core/browser/signin_manager_base.h" | 23 #include "components/signin/core/browser/signin_manager_base.h" |
| 24 #include "google_apis/gaia/google_service_auth_error.h" | 24 #include "google_apis/gaia/google_service_auth_error.h" |
| 25 #include "net/base/load_flags.h" | 25 #include "net/base/load_flags.h" |
| 26 #include "net/base/net_errors.h" | 26 #include "net/base/net_errors.h" |
| 27 #include "net/http/http_status_code.h" | 27 #include "net/http/http_status_code.h" |
| 28 #include "net/traffic_annotation/network_traffic_annotation.h" | |
| 28 #include "net/url_request/url_fetcher.h" | 29 #include "net/url_request/url_fetcher.h" |
| 29 #include "net/url_request/url_request_status.h" | 30 #include "net/url_request/url_request_status.h" |
| 30 #include "url/gurl.h" | 31 #include "url/gurl.h" |
| 31 | 32 |
| 32 using net::URLFetcher; | 33 using net::URLFetcher; |
| 33 | 34 |
| 34 const char kApiPath[] = "people/me/permissionRequests"; | 35 const char kApiPath[] = "people/me/permissionRequests"; |
| 35 const char kApiScope[] = "https://www.googleapis.com/auth/kid.permission"; | 36 const char kApiScope[] = "https://www.googleapis.com/auth/kid.permission"; |
| 36 | 37 |
| 37 const int kNumRetries = 1; | 38 const int kNumRetries = 1; |
| (...skipping 137 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... | |
| 175 const base::Time& expiration_time) { | 176 const base::Time& expiration_time) { |
| 176 RequestIterator it = requests_.begin(); | 177 RequestIterator it = requests_.begin(); |
| 177 while (it != requests_.end()) { | 178 while (it != requests_.end()) { |
| 178 if (request == (*it)->access_token_request.get()) | 179 if (request == (*it)->access_token_request.get()) |
| 179 break; | 180 break; |
| 180 ++it; | 181 ++it; |
| 181 } | 182 } |
| 182 DCHECK(it != requests_.end()); | 183 DCHECK(it != requests_.end()); |
| 183 (*it)->access_token = access_token; | 184 (*it)->access_token = access_token; |
| 184 | 185 |
| 185 (*it)->url_fetcher = URLFetcher::Create((*it)->url_fetcher_id, GetApiUrl(), | 186 net::NetworkTrafficAnnotationTag traffic_annotation = |
| 186 URLFetcher::POST, this); | 187 net::DefineNetworkTrafficAnnotation("...", R"( |
|
Bernhard Bauer
2017/03/14 10:02:49
permission_request_creator
Ramin Halavati
2017/03/14 10:56:20
Done.
| |
| 188 semantics { | |
| 189 sender: "..." | |
|
Bernhard Bauer
2017/03/14 10:02:49
supervised_users
Ramin Halavati
2017/03/14 10:56:20
Done.
| |
| 190 description: "..." | |
|
Bernhard Bauer
2017/03/14 10:02:49
Requests permission for the user to access a block
Ramin Halavati
2017/03/14 10:56:20
Done.
| |
| 191 trigger: "..." | |
|
Bernhard Bauer
2017/03/14 10:02:48
Initiated by the user.
Ramin Halavati
2017/03/14 10:56:19
Done.
| |
| 192 data: "..." | |
|
Bernhard Bauer
2017/03/14 10:02:49
The request is authenticated with an OAuth2 access
Ramin Halavati
2017/03/14 10:56:20
Done.
| |
| 193 destination: WEBSITE/GOOGLE_OWNED_SERVICE/OTHER | |
| 194 } | |
| 195 policy { | |
| 196 cookies_allowed: false/true | |
|
Bernhard Bauer
2017/03/14 10:02:48
false
Ramin Halavati
2017/03/14 10:56:20
Done.
| |
| 197 cookies_store: "..." | |
|
Bernhard Bauer
2017/03/14 10:02:49
user
Ramin Halavati
2017/03/14 10:56:19
Done.
| |
| 198 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.
| |
| 199 chrome_policy { | |
| 200 [POLICY_NAME] { | |
|
Bernhard Bauer
2017/03/14 10:02:48
RestrictSigninToPattern
Ramin Halavati
2017/03/14 10:56:20
Done.
| |
| 201 policy_options {mode: MANDATORY/RECOMMENDED/UNSET} | |
|
Bernhard Bauer
2017/03/14 10:02:49
MANDATORY
Ramin Halavati
2017/03/14 10:56:19
Done.
| |
| 202 [POLICY_NAME]: ... //(value to disable it) | |
|
Bernhard Bauer
2017/03/14 10:02:49
"*@manageddomain.com"
Ramin Halavati
2017/03/14 10:56:19
Done.
| |
| 203 } | |
| 204 } | |
| 205 policy_exception_justification: "..." | |
| 206 })"); | |
| 207 (*it)->url_fetcher = | |
| 208 URLFetcher::Create((*it)->url_fetcher_id, GetApiUrl(), URLFetcher::POST, | |
| 209 this, traffic_annotation); | |
| 187 | 210 |
| 188 data_use_measurement::DataUseUserData::AttachToFetcher( | 211 data_use_measurement::DataUseUserData::AttachToFetcher( |
| 189 (*it)->url_fetcher.get(), | 212 (*it)->url_fetcher.get(), |
| 190 data_use_measurement::DataUseUserData::SUPERVISED_USER); | 213 data_use_measurement::DataUseUserData::SUPERVISED_USER); |
| 191 (*it)->url_fetcher->SetRequestContext(context_); | 214 (*it)->url_fetcher->SetRequestContext(context_); |
| 192 (*it)->url_fetcher->SetLoadFlags(net::LOAD_DO_NOT_SEND_COOKIES | | 215 (*it)->url_fetcher->SetLoadFlags(net::LOAD_DO_NOT_SEND_COOKIES | |
| 193 net::LOAD_DO_NOT_SAVE_COOKIES); | 216 net::LOAD_DO_NOT_SAVE_COOKIES); |
| 194 (*it)->url_fetcher->SetAutomaticallyRetryOnNetworkChanges(kNumRetries); | 217 (*it)->url_fetcher->SetAutomaticallyRetryOnNetworkChanges(kNumRetries); |
| 195 (*it)->url_fetcher->AddExtraRequestHeader( | 218 (*it)->url_fetcher->AddExtraRequestHeader( |
| 196 base::StringPrintf(kAuthorizationHeaderFormat, access_token.c_str())); | 219 base::StringPrintf(kAuthorizationHeaderFormat, access_token.c_str())); |
| (...skipping 80 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... | |
| 277 return; | 300 return; |
| 278 } | 301 } |
| 279 DispatchResult(it, true); | 302 DispatchResult(it, true); |
| 280 } | 303 } |
| 281 | 304 |
| 282 void PermissionRequestCreatorApiary::DispatchResult(RequestIterator it, | 305 void PermissionRequestCreatorApiary::DispatchResult(RequestIterator it, |
| 283 bool success) { | 306 bool success) { |
| 284 (*it)->callback.Run(success); | 307 (*it)->callback.Run(success); |
| 285 requests_.erase(it); | 308 requests_.erase(it); |
| 286 } | 309 } |
| OLD | NEW |