| 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 "google_apis/gcm/engine/unregistration_request.h" | 5 #include "google_apis/gcm/engine/unregistration_request.h" |
| 6 | 6 |
| 7 #include <utility> | 7 #include <utility> |
| 8 | 8 |
| 9 #include "base/bind.h" | 9 #include "base/bind.h" |
| 10 #include "base/location.h" | 10 #include "base/location.h" |
| 11 #include "base/strings/string_number_conversions.h" | 11 #include "base/strings/string_number_conversions.h" |
| 12 #include "base/strings/string_piece.h" | 12 #include "base/strings/string_piece.h" |
| 13 #include "base/threading/thread_task_runner_handle.h" | 13 #include "base/threading/thread_task_runner_handle.h" |
| 14 #include "base/values.h" | 14 #include "base/values.h" |
| 15 #include "google_apis/gcm/base/gcm_util.h" | 15 #include "google_apis/gcm/base/gcm_util.h" |
| 16 #include "google_apis/gcm/monitoring/gcm_stats_recorder.h" | 16 #include "google_apis/gcm/monitoring/gcm_stats_recorder.h" |
| 17 #include "net/base/escape.h" | 17 #include "net/base/escape.h" |
| 18 #include "net/base/load_flags.h" | 18 #include "net/base/load_flags.h" |
| 19 #include "net/http/http_request_headers.h" | 19 #include "net/http/http_request_headers.h" |
| 20 #include "net/http/http_status_code.h" | 20 #include "net/http/http_status_code.h" |
| 21 #include "net/traffic_annotation/network_traffic_annotation.h" |
| 21 #include "net/url_request/url_fetcher.h" | 22 #include "net/url_request/url_fetcher.h" |
| 22 #include "net/url_request/url_request_context_getter.h" | 23 #include "net/url_request/url_request_context_getter.h" |
| 23 #include "net/url_request/url_request_status.h" | 24 #include "net/url_request/url_request_status.h" |
| 24 | 25 |
| 25 namespace gcm { | 26 namespace gcm { |
| 26 | 27 |
| 27 namespace { | 28 namespace { |
| 28 | 29 |
| 29 const char kRequestContentType[] = "application/x-www-form-urlencoded"; | 30 const char kRequestContentType[] = "application/x-www-form-urlencoded"; |
| 30 | 31 |
| (...skipping 89 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 120 source_to_record_(source_to_record), | 121 source_to_record_(source_to_record), |
| 121 weak_ptr_factory_(this) { | 122 weak_ptr_factory_(this) { |
| 122 DCHECK_GE(max_retry_count, 0); | 123 DCHECK_GE(max_retry_count, 0); |
| 123 } | 124 } |
| 124 | 125 |
| 125 UnregistrationRequest::~UnregistrationRequest() {} | 126 UnregistrationRequest::~UnregistrationRequest() {} |
| 126 | 127 |
| 127 void UnregistrationRequest::Start() { | 128 void UnregistrationRequest::Start() { |
| 128 DCHECK(!callback_.is_null()); | 129 DCHECK(!callback_.is_null()); |
| 129 DCHECK(!url_fetcher_.get()); | 130 DCHECK(!url_fetcher_.get()); |
| 130 | 131 net::NetworkTrafficAnnotationTag traffic_annotation = |
| 131 url_fetcher_ = | 132 net::DefineNetworkTrafficAnnotation("gcm_unregistration", R"( |
| 132 net::URLFetcher::Create(registration_url_, net::URLFetcher::POST, this); | 133 semantics { |
| 134 sender: "GCM Driver" |
| 135 description: |
| 136 "Chromium interacts with Google Cloud Messaging to receive push " |
| 137 "messages for various browser features, as well as on behalf of " |
| 138 "websites and extensions. This requests Google Cloud Messaging to " |
| 139 "invalidate the included registration so that it can no longer be " |
| 140 "used to distribute messages to Chromium." |
| 141 trigger: |
| 142 "Immediately after a feature, website or extension removes a " |
| 143 "registration they previously created with the GCM Driver." |
| 144 data: |
| 145 "The profile-bound Android ID and associated secret, and the " |
| 146 "identifiers for the feature, website or extension that is " |
| 147 "removing the registration." |
| 148 destination: GOOGLE_OWNED_SERVICE |
| 149 } |
| 150 policy { |
| 151 cookies_allowed: false |
| 152 setting: |
| 153 "Support for interacting with Google Cloud Messaging is enabled by " |
| 154 "default, and there is no configuration option to completely " |
| 155 "disable it." |
| 156 policy_exception_justification: |
| 157 "Not implemented, considered not useful." |
| 158 })"); |
| 159 url_fetcher_ = net::URLFetcher::Create( |
| 160 registration_url_, net::URLFetcher::POST, this, traffic_annotation); |
| 133 url_fetcher_->SetRequestContext(request_context_getter_.get()); | 161 url_fetcher_->SetRequestContext(request_context_getter_.get()); |
| 134 url_fetcher_->SetLoadFlags(net::LOAD_DO_NOT_SEND_COOKIES | | 162 url_fetcher_->SetLoadFlags(net::LOAD_DO_NOT_SEND_COOKIES | |
| 135 net::LOAD_DO_NOT_SAVE_COOKIES); | 163 net::LOAD_DO_NOT_SAVE_COOKIES); |
| 136 | 164 |
| 137 std::string extra_headers; | 165 std::string extra_headers; |
| 138 BuildRequestHeaders(&extra_headers); | 166 BuildRequestHeaders(&extra_headers); |
| 139 url_fetcher_->SetExtraRequestHeaders(extra_headers); | 167 url_fetcher_->SetExtraRequestHeaders(extra_headers); |
| 140 | 168 |
| 141 std::string body; | 169 std::string body; |
| 142 BuildRequestBody(&body); | 170 BuildRequestBody(&body); |
| (...skipping 115 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 258 // Only REACHED_MAX_RETRIES is reported because the function will skip | 286 // Only REACHED_MAX_RETRIES is reported because the function will skip |
| 259 // reporting count and time when status is not SUCCESS. | 287 // reporting count and time when status is not SUCCESS. |
| 260 DCHECK(custom_request_handler_.get()); | 288 DCHECK(custom_request_handler_.get()); |
| 261 custom_request_handler_->ReportUMAs(status, 0, base::TimeDelta()); | 289 custom_request_handler_->ReportUMAs(status, 0, base::TimeDelta()); |
| 262 } | 290 } |
| 263 | 291 |
| 264 callback_.Run(status); | 292 callback_.Run(status); |
| 265 } | 293 } |
| 266 | 294 |
| 267 } // namespace gcm | 295 } // namespace gcm |
| OLD | NEW |