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

Side by Side Diff: components/ntp_snippets/remote/json_request.cc

Issue 2709483006: Network traffic annotation added to ntp_snippets. (Closed)
Patch Set: Created 3 years, 10 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
« no previous file with comments | « components/ntp_snippets/DEPS ('k') | no next file » | no next file with comments »
Toggle Intra-line Diffs ('i') | Expand Comments ('e') | Collapse Comments ('c') | Show Comments Hide Comments ('s')
OLDNEW
1 // Copyright 2016 The Chromium Authors. All rights reserved. 1 // Copyright 2016 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 "components/ntp_snippets/remote/json_request.h" 5 #include "components/ntp_snippets/remote/json_request.h"
6 6
7 #include <algorithm> 7 #include <algorithm>
8 #include <utility> 8 #include <utility>
9 #include <vector> 9 #include <vector>
10 10
(...skipping 12 matching lines...) Expand all
23 #include "components/ntp_snippets/user_classifier.h" 23 #include "components/ntp_snippets/user_classifier.h"
24 #include "components/signin/core/browser/profile_oauth2_token_service.h" 24 #include "components/signin/core/browser/profile_oauth2_token_service.h"
25 #include "components/signin/core/browser/signin_manager.h" 25 #include "components/signin/core/browser/signin_manager.h"
26 #include "components/signin/core/browser/signin_manager_base.h" 26 #include "components/signin/core/browser/signin_manager_base.h"
27 #include "components/variations/net/variations_http_headers.h" 27 #include "components/variations/net/variations_http_headers.h"
28 #include "components/variations/variations_associated_data.h" 28 #include "components/variations/variations_associated_data.h"
29 #include "grit/components_strings.h" 29 #include "grit/components_strings.h"
30 #include "net/base/load_flags.h" 30 #include "net/base/load_flags.h"
31 #include "net/http/http_response_headers.h" 31 #include "net/http/http_response_headers.h"
32 #include "net/http/http_status_code.h" 32 #include "net/http/http_status_code.h"
33 #include "net/traffic_annotation/network_traffic_annotation.h"
33 #include "net/url_request/url_fetcher.h" 34 #include "net/url_request/url_fetcher.h"
34 #include "net/url_request/url_request_context_getter.h" 35 #include "net/url_request/url_request_context_getter.h"
35 #include "third_party/icu/source/common/unicode/uloc.h" 36 #include "third_party/icu/source/common/unicode/uloc.h"
36 #include "third_party/icu/source/common/unicode/utypes.h" 37 #include "third_party/icu/source/common/unicode/utypes.h"
37 #include "ui/base/l10n/l10n_util.h" 38 #include "ui/base/l10n/l10n_util.h"
38 39
39 using net::URLFetcher; 40 using net::URLFetcher;
40 using net::URLRequestContextGetter; 41 using net::URLRequestContextGetter;
41 using net::HttpRequestHeaders; 42 using net::HttpRequestHeaders;
42 using net::URLRequestStatus; 43 using net::URLRequestStatus;
(...skipping 381 matching lines...) Expand 10 before | Expand all | Expand 10 after
424 bool success = base::JSONWriter::WriteWithOptions( 425 bool success = base::JSONWriter::WriteWithOptions(
425 *request, base::JSONWriter::OPTIONS_PRETTY_PRINT, &request_json); 426 *request, base::JSONWriter::OPTIONS_PRETTY_PRINT, &request_json);
426 DCHECK(success); 427 DCHECK(success);
427 return request_json; 428 return request_json;
428 } 429 }
429 430
430 std::unique_ptr<net::URLFetcher> JsonRequest::Builder::BuildURLFetcher( 431 std::unique_ptr<net::URLFetcher> JsonRequest::Builder::BuildURLFetcher(
431 net::URLFetcherDelegate* delegate, 432 net::URLFetcherDelegate* delegate,
432 const std::string& headers, 433 const std::string& headers,
433 const std::string& body) const { 434 const std::string& body) const {
434 std::unique_ptr<net::URLFetcher> url_fetcher = 435 net::NetworkTrafficAnnotationTag traffic_annotation =
435 net::URLFetcher::Create(url_, net::URLFetcher::POST, delegate); 436 net::DefineNetworkTrafficAnnotation("...", R"(
Marc Treib 2017/02/23 14:53:46 ntp_snippets_fetch
Ramin Halavati 2017/02/27 10:31:22 Done.
437 semantics {
438 sender: "..."
Marc Treib 2017/02/23 14:53:46 New Tab page content suggestions fetch
Ramin Halavati 2017/02/27 10:31:21 Done.
439 description: "..."
Marc Treib 2017/02/23 14:53:46 Google Chrome can show content suggestions (e.g. n
Ramin Halavati 2017/02/27 10:31:21 Done.
440 trigger: "..."
Marc Treib 2017/02/23 14:53:46 Triggered periodically in the background, or upon
Ramin Halavati 2017/02/27 10:31:21 Done.
441 data: "..."
Marc Treib 2017/02/23 14:53:46 The Chrome UI language, as well as a second langua
Ramin Halavati 2017/02/27 10:31:21 Done.
442 destination: WEBSITE/GOOGLE_OWNED_SERVICE/OTHER
Marc Treib 2017/02/23 14:53:46 GOOGLE_OWNED_SERVICE
Ramin Halavati 2017/02/27 10:31:21 Done.
443 }
444 policy {
445 cookies_allowed: false/true
Marc Treib 2017/02/23 14:53:46 false (I think? Not exactly sure what "cookies/cha
Ramin Halavati 2017/02/27 10:31:21 Yes, LoadFlags are set to not send or save cookie.
446 cookies_store: "..."
Marc Treib 2017/02/23 14:53:46 n/a
Ramin Halavati 2017/02/27 10:31:22 Done.
447 setting: "..."
Marc Treib 2017/02/23 14:53:46 n/a (though we might add one; see crbug.com/695129
Ramin Halavati 2017/02/27 10:31:21 Done.
448 policy {
449 [POLICY_NAME] {
Marc Treib 2017/02/23 14:53:46 NTPContentSuggestionsEnabled
Ramin Halavati 2017/02/27 10:31:21 Done.
450 policy_options {mode: MANDATORY/RECOMMENDED/UNSET}
Marc Treib 2017/02/23 14:53:46 Not sure what this means? Currently the policy is
Ramin Halavati 2017/02/27 10:31:21 Done.
451 value: ...
Marc Treib 2017/02/23 14:53:46 ?
Ramin Halavati 2017/02/27 10:31:21 It should be the value that disables this feature,
452 }
453 }
454 policy_exception_justification: "..."
455 })");
456 std::unique_ptr<net::URLFetcher> url_fetcher = net::URLFetcher::Create(
457 url_, net::URLFetcher::POST, delegate, traffic_annotation);
436 url_fetcher->SetRequestContext(url_request_context_getter_.get()); 458 url_fetcher->SetRequestContext(url_request_context_getter_.get());
437 url_fetcher->SetLoadFlags(net::LOAD_DO_NOT_SEND_COOKIES | 459 url_fetcher->SetLoadFlags(net::LOAD_DO_NOT_SEND_COOKIES |
438 net::LOAD_DO_NOT_SAVE_COOKIES); 460 net::LOAD_DO_NOT_SAVE_COOKIES);
439 data_use_measurement::DataUseUserData::AttachToFetcher( 461 data_use_measurement::DataUseUserData::AttachToFetcher(
440 url_fetcher.get(), 462 url_fetcher.get(),
441 data_use_measurement::DataUseUserData::NTP_SNIPPETS_SUGGESTIONS); 463 data_use_measurement::DataUseUserData::NTP_SNIPPETS_SUGGESTIONS);
442 464
443 url_fetcher->SetExtraRequestHeaders(headers); 465 url_fetcher->SetExtraRequestHeaders(headers);
444 url_fetcher->SetUploadData("application/json", body); 466 url_fetcher->SetUploadData("application/json", body);
445 467
(...skipping 36 matching lines...) Expand 10 before | Expand all | Expand 10 after
482 "NewTabPage.Languages.UILanguageRatioInTwoTopLanguages", 504 "NewTabPage.Languages.UILanguageRatioInTwoTopLanguages",
483 ratio_ui_in_both_languages * 100); 505 ratio_ui_in_both_languages * 100);
484 break; 506 break;
485 } 507 }
486 } 508 }
487 } 509 }
488 510
489 } // namespace internal 511 } // namespace internal
490 512
491 } // namespace ntp_snippets 513 } // namespace ntp_snippets
OLDNEW
« no previous file with comments | « components/ntp_snippets/DEPS ('k') | no next file » | no next file with comments »

Powered by Google App Engine
This is Rietveld 408576698