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. Used for example to show birthday " |
| 92 "doodles at appropriate times." |
91 destination: GOOGLE_OWNED_SERVICE | 93 destination: GOOGLE_OWNED_SERVICE |
92 } | 94 } |
93 policy { | 95 policy { |
94 cookies_allowed: false | 96 cookies_allowed: true |
| 97 cookies_store: "user" |
95 setting: | 98 setting: |
96 "Choosing a non-Google search engine in Chromium settings under " | 99 "Choosing a non-Google search engine in Chromium settings under " |
97 "'Search Engine' will disable this feature." | 100 "'Search Engine' will disable this feature." |
98 policy_exception_justification: | 101 policy_exception_justification: |
99 "Not implemented, considered not useful as it does not upload any " | 102 "Not implemented, considered not useful as it does not upload any " |
100 "data." | 103 "data." |
101 })"); | 104 })"); |
102 fetcher_ = URLFetcher::Create( | 105 fetcher_ = URLFetcher::Create( |
103 BuildDoodleURL(GetGoogleBaseUrl(), gray_background_, override_url_), | 106 BuildDoodleURL(GetGoogleBaseUrl(), gray_background_, override_url_), |
104 URLFetcher::GET, this, traffic_annotation); | 107 URLFetcher::GET, this, traffic_annotation); |
105 fetcher_->SetRequestContext(download_context_.get()); | 108 fetcher_->SetRequestContext(download_context_.get()); |
106 fetcher_->SetLoadFlags(net::LOAD_DO_NOT_SEND_COOKIES | | 109 // TODO(treib): Use OAuth2 authentication instead of cookies. crbug.com/711314 |
107 net::LOAD_DO_NOT_SAVE_COOKIES | | 110 fetcher_->SetLoadFlags(net::LOAD_DO_NOT_SEND_AUTH_DATA); |
108 net::LOAD_DO_NOT_SEND_AUTH_DATA); | |
109 fetcher_->SetAutomaticallyRetryOnNetworkChanges(1); | 111 fetcher_->SetAutomaticallyRetryOnNetworkChanges(1); |
110 data_use_measurement::DataUseUserData::AttachToFetcher( | 112 data_use_measurement::DataUseUserData::AttachToFetcher( |
111 fetcher_.get(), data_use_measurement::DataUseUserData::DOODLE); | 113 fetcher_.get(), data_use_measurement::DataUseUserData::DOODLE); |
112 fetcher_->Start(); | 114 fetcher_->Start(); |
113 } | 115 } |
114 | 116 |
115 void DoodleFetcherImpl::OnURLFetchComplete(const URLFetcher* source) { | 117 void DoodleFetcherImpl::OnURLFetchComplete(const URLFetcher* source) { |
116 DCHECK_EQ(fetcher_.get(), source); | 118 DCHECK_EQ(fetcher_.get(), source); |
117 std::unique_ptr<net::URLFetcher> free_fetcher = std::move(fetcher_); | 119 std::unique_ptr<net::URLFetcher> free_fetcher = std::move(fetcher_); |
118 | 120 |
(...skipping 79 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
198 | 200 |
199 GURL DoodleFetcherImpl::GetGoogleBaseUrl() const { | 201 GURL DoodleFetcherImpl::GetGoogleBaseUrl() const { |
200 GURL cmd_line_url = google_util::CommandLineGoogleBaseURL(); | 202 GURL cmd_line_url = google_util::CommandLineGoogleBaseURL(); |
201 if (cmd_line_url.is_valid()) { | 203 if (cmd_line_url.is_valid()) { |
202 return cmd_line_url; | 204 return cmd_line_url; |
203 } | 205 } |
204 return google_url_tracker_->google_url(); | 206 return google_url_tracker_->google_url(); |
205 } | 207 } |
206 | 208 |
207 } // namespace doodle | 209 } // namespace doodle |
OLD | NEW |