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

Side by Side Diff: components/search_engines/template_url_fetcher.cc

Issue 2711833003: Network traffic annotation added to template_url_fetcher. (Closed)
Patch Set: Annotation updated. Created 3 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
« no previous file with comments | « no previous file | 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 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 "components/search_engines/template_url_fetcher.h" 5 #include "components/search_engines/template_url_fetcher.h"
6 6
7 #include "base/macros.h" 7 #include "base/macros.h"
8 #include "base/memory/ptr_util.h" 8 #include "base/memory/ptr_util.h"
9 #include "base/strings/string_number_conversions.h" 9 #include "base/strings/string_number_conversions.h"
10 #include "base/strings/utf_string_conversions.h" 10 #include "base/strings/utf_string_conversions.h"
11 #include "build/build_config.h" 11 #include "build/build_config.h"
12 #include "components/search_engines/template_url.h" 12 #include "components/search_engines/template_url.h"
13 #include "components/search_engines/template_url_parser.h" 13 #include "components/search_engines/template_url_parser.h"
14 #include "components/search_engines/template_url_service.h" 14 #include "components/search_engines/template_url_service.h"
15 #include "net/base/load_flags.h" 15 #include "net/base/load_flags.h"
16 #include "net/traffic_annotation/network_traffic_annotation.h"
16 #include "net/url_request/url_fetcher.h" 17 #include "net/url_request/url_fetcher.h"
17 #include "net/url_request/url_fetcher_delegate.h" 18 #include "net/url_request/url_fetcher_delegate.h"
18 #include "net/url_request/url_request_context_getter.h" 19 #include "net/url_request/url_request_context_getter.h"
19 #include "net/url_request/url_request_status.h" 20 #include "net/url_request/url_request_status.h"
20 21
22 namespace {
23 // Traffic annotation for ReqeustDelegate
24 constexpr net::NetworkTrafficAnnotationTag kTrafficAnnotation =
25 net::DefineNetworkTrafficAnnotation("open_search", R"(
26 semantics {
27 sender: "Open Search Fetcher"
Peter Kasting 2017/02/24 23:33:09 I think this should be Omnibox, as that's ultimate
Ramin Halavati 2017/02/27 09:07:57 Done.
vasilii 2017/02/27 13:14:01 Peter, why omnibox? If I search for "yandex" and t
Peter Kasting 2017/02/27 21:07:10 Because that's what these search engines are actua
28 description:
29 "The web pages can include an OpenSearch description doc in their "
Peter Kasting 2017/02/24 23:33:09 Nit: No "the"
Ramin Halavati 2017/02/27 09:07:57 Done.
30 "HTML. In this case Chromium downloads and parses the file. The "
Peter Kasting 2017/02/24 23:33:09 Is merely visiting the page, and not actually usin
vasilii 2017/02/27 12:13:05 Yes, you can land on https://yandex.ru/ and observ
31 "corresponding search engine is added to the list in the browser "
32 "(chrome://settings/searchEngines)."
33 trigger:
34 "User visits a web page containing <link rel="search"> tag."
Peter Kasting 2017/02/24 23:33:09 Nit: Two spaces after "containing" should be " a "
Ramin Halavati 2017/02/27 09:07:57 Done.
35 data: "None"
36 destination: WEBSITE
37 }
38 policy {
39 cookies_allowed: false
vasilii 2017/02/24 15:05:43 true
40 setting: "This feature cannot be disabled in settings."
41 policy_exception_justification:
42 "Not implemented, considered not useful as this feature does not "
43 "upload any data."
Peter Kasting 2017/02/24 23:33:09 Since we send cookies, this seems incorrect. Mayb
vasilii 2017/02/27 12:13:06 I didn't find anything related to cookies in the s
44 })");
45 } // namespace
46
21 // RequestDelegate ------------------------------------------------------------ 47 // RequestDelegate ------------------------------------------------------------
22 class TemplateURLFetcher::RequestDelegate : public net::URLFetcherDelegate { 48 class TemplateURLFetcher::RequestDelegate : public net::URLFetcherDelegate {
23 public: 49 public:
24 RequestDelegate( 50 RequestDelegate(
25 TemplateURLFetcher* fetcher, 51 TemplateURLFetcher* fetcher,
26 const base::string16& keyword, 52 const base::string16& keyword,
27 const GURL& osdd_url, 53 const GURL& osdd_url,
28 const GURL& favicon_url, 54 const GURL& favicon_url,
29 const URLFetcherCustomizeCallback& url_fetcher_customize_callback); 55 const URLFetcherCustomizeCallback& url_fetcher_customize_callback);
30 56
(...skipping 23 matching lines...) Expand all
54 80
55 DISALLOW_COPY_AND_ASSIGN(RequestDelegate); 81 DISALLOW_COPY_AND_ASSIGN(RequestDelegate);
56 }; 82 };
57 83
58 TemplateURLFetcher::RequestDelegate::RequestDelegate( 84 TemplateURLFetcher::RequestDelegate::RequestDelegate(
59 TemplateURLFetcher* fetcher, 85 TemplateURLFetcher* fetcher,
60 const base::string16& keyword, 86 const base::string16& keyword,
61 const GURL& osdd_url, 87 const GURL& osdd_url,
62 const GURL& favicon_url, 88 const GURL& favicon_url,
63 const URLFetcherCustomizeCallback& url_fetcher_customize_callback) 89 const URLFetcherCustomizeCallback& url_fetcher_customize_callback)
64 : url_fetcher_( 90 : url_fetcher_(net::URLFetcher::Create(osdd_url,
65 net::URLFetcher::Create(osdd_url, net::URLFetcher::GET, this)), 91 net::URLFetcher::GET,
92 this,
93 kTrafficAnnotation)),
66 fetcher_(fetcher), 94 fetcher_(fetcher),
67 keyword_(keyword), 95 keyword_(keyword),
68 osdd_url_(osdd_url), 96 osdd_url_(osdd_url),
69 favicon_url_(favicon_url) { 97 favicon_url_(favicon_url) {
70 TemplateURLService* model = fetcher_->template_url_service_; 98 TemplateURLService* model = fetcher_->template_url_service_;
71 DCHECK(model); // TemplateURLFetcher::ScheduleDownload verifies this. 99 DCHECK(model); // TemplateURLFetcher::ScheduleDownload verifies this.
72 100
73 if (!model->loaded()) { 101 if (!model->loaded()) {
74 // Start the model load and set-up waiting for it. 102 // Start the model load and set-up waiting for it.
75 template_url_subscription_ = model->RegisterOnLoadedCallback( 103 template_url_subscription_ = model->RegisterOnLoadedCallback(
(...skipping 142 matching lines...) Expand 10 before | Expand all | Expand 10 after
218 } 246 }
219 247
220 void TemplateURLFetcher::RequestCompleted(RequestDelegate* request) { 248 void TemplateURLFetcher::RequestCompleted(RequestDelegate* request) {
221 auto i = std::find_if(requests_.begin(), requests_.end(), 249 auto i = std::find_if(requests_.begin(), requests_.end(),
222 [request](const std::unique_ptr<RequestDelegate>& ptr) { 250 [request](const std::unique_ptr<RequestDelegate>& ptr) {
223 return ptr.get() == request; 251 return ptr.get() == request;
224 }); 252 });
225 DCHECK(i != requests_.end()); 253 DCHECK(i != requests_.end());
226 requests_.erase(i); 254 requests_.erase(i);
227 } 255 }
OLDNEW
« no previous file with comments | « no previous file | no next file » | no next file with comments »

Powered by Google App Engine
This is Rietveld 408576698