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 "components/doodle/doodle_fetcher_impl.h" | 5 #include "components/doodle/doodle_fetcher_impl.h" |
6 | 6 |
7 #include <utility> | 7 #include <utility> |
8 | 8 |
9 #include "base/strings/stringprintf.h" | 9 #include "base/strings/stringprintf.h" |
10 #include "base/time/time.h" | 10 #include "base/time/time.h" |
(...skipping 69 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... | |
80 callbacks_.push_back(std::move(callback)); | 80 callbacks_.push_back(std::move(callback)); |
81 net::NetworkTrafficAnnotationTag traffic_annotation = | 81 net::NetworkTrafficAnnotationTag traffic_annotation = |
82 net::DefineNetworkTrafficAnnotation("doodle_fetcher", R"( | 82 net::DefineNetworkTrafficAnnotation("doodle_fetcher", R"( |
83 semantics { | 83 semantics { |
84 sender: "Doodle Fetcher" | 84 sender: "Doodle Fetcher" |
85 description: | 85 description: |
86 "Retrieves metadata (image URL, clickthrough URL etc) for any " | 86 "Retrieves metadata (image URL, clickthrough URL etc) for any " |
87 "currently running Doodle." | 87 "currently running Doodle." |
88 trigger: | 88 trigger: |
89 "Displaying the new tab page on Android." | 89 "Displaying the new tab page on Android." |
90 data: "None." | 90 data: |
91 "The user's Google cookies to show for example birthday doodles at " | |
92 "appropriate times." | |
fhorschig
2017/04/26 08:08:53
nit: pretty hard to read. How about:
The user's G
Marc Treib
2017/04/26 08:32:00
Done.
| |
91 destination: GOOGLE_OWNED_SERVICE | 93 destination: GOOGLE_OWNED_SERVICE |
92 } | 94 } |
93 policy { | 95 policy { |
94 cookies_allowed: false | 96 cookies_allowed: true |
95 setting: | 97 setting: |
96 "Choosing a non-Google search engine in Chromium settings under " | 98 "Choosing a non-Google search engine in Chromium settings under " |
97 "'Search Engine' will disable this feature." | 99 "'Search Engine' will disable this feature." |
98 policy_exception_justification: | 100 policy_exception_justification: |
99 "Not implemented, considered not useful as it does not upload any " | 101 "Not implemented, considered not useful as it does not upload any " |
100 "data." | 102 "data." |
101 })"); | 103 })"); |
102 fetcher_ = URLFetcher::Create( | 104 fetcher_ = URLFetcher::Create( |
103 BuildDoodleURL(GetGoogleBaseUrl(), gray_background_, override_url_), | 105 BuildDoodleURL(GetGoogleBaseUrl(), gray_background_, override_url_), |
104 URLFetcher::GET, this, traffic_annotation); | 106 URLFetcher::GET, this, traffic_annotation); |
105 fetcher_->SetRequestContext(download_context_.get()); | 107 fetcher_->SetRequestContext(download_context_.get()); |
106 fetcher_->SetLoadFlags(net::LOAD_DO_NOT_SEND_COOKIES | | 108 // TODO(treib): Use OAuth2 authentication instead of cookies. crbug.com/711314 |
107 net::LOAD_DO_NOT_SAVE_COOKIES | | 109 fetcher_->SetLoadFlags(net::LOAD_DO_NOT_SEND_AUTH_DATA); |
108 net::LOAD_DO_NOT_SEND_AUTH_DATA); | |
109 fetcher_->SetAutomaticallyRetryOnNetworkChanges(1); | 110 fetcher_->SetAutomaticallyRetryOnNetworkChanges(1); |
110 data_use_measurement::DataUseUserData::AttachToFetcher( | 111 data_use_measurement::DataUseUserData::AttachToFetcher( |
111 fetcher_.get(), data_use_measurement::DataUseUserData::DOODLE); | 112 fetcher_.get(), data_use_measurement::DataUseUserData::DOODLE); |
112 fetcher_->Start(); | 113 fetcher_->Start(); |
113 } | 114 } |
114 | 115 |
115 void DoodleFetcherImpl::OnURLFetchComplete(const URLFetcher* source) { | 116 void DoodleFetcherImpl::OnURLFetchComplete(const URLFetcher* source) { |
116 DCHECK_EQ(fetcher_.get(), source); | 117 DCHECK_EQ(fetcher_.get(), source); |
117 std::unique_ptr<net::URLFetcher> free_fetcher = std::move(fetcher_); | 118 std::unique_ptr<net::URLFetcher> free_fetcher = std::move(fetcher_); |
118 | 119 |
(...skipping 79 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... | |
198 | 199 |
199 GURL DoodleFetcherImpl::GetGoogleBaseUrl() const { | 200 GURL DoodleFetcherImpl::GetGoogleBaseUrl() const { |
200 GURL cmd_line_url = google_util::CommandLineGoogleBaseURL(); | 201 GURL cmd_line_url = google_util::CommandLineGoogleBaseURL(); |
201 if (cmd_line_url.is_valid()) { | 202 if (cmd_line_url.is_valid()) { |
202 return cmd_line_url; | 203 return cmd_line_url; |
203 } | 204 } |
204 return google_url_tracker_->google_url(); | 205 return google_url_tracker_->google_url(); |
205 } | 206 } |
206 | 207 |
207 } // namespace doodle | 208 } // namespace doodle |
OLD | NEW |