| 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 "chrome/browser/search/one_google_bar/one_google_bar_fetcher_impl.h" | 5 #include "chrome/browser/search/one_google_bar/one_google_bar_fetcher_impl.h" |
| 6 | 6 |
| 7 #include <string> | 7 #include <string> |
| 8 #include <utility> | 8 #include <utility> |
| 9 | 9 |
| 10 #include "base/callback.h" | 10 #include "base/callback.h" |
| (...skipping 17 matching lines...) Expand all Loading... |
| 28 #include "net/http/http_status_code.h" | 28 #include "net/http/http_status_code.h" |
| 29 #include "net/url_request/url_fetcher.h" | 29 #include "net/url_request/url_fetcher.h" |
| 30 #include "net/url_request/url_fetcher_delegate.h" | 30 #include "net/url_request/url_fetcher_delegate.h" |
| 31 | 31 |
| 32 namespace { | 32 namespace { |
| 33 | 33 |
| 34 const char kApiUrl[] = "https://onegoogle-pa.googleapis.com/v1/getbar"; | 34 const char kApiUrl[] = "https://onegoogle-pa.googleapis.com/v1/getbar"; |
| 35 | 35 |
| 36 const char kApiKeyFormat[] = "?key=%s"; | 36 const char kApiKeyFormat[] = "?key=%s"; |
| 37 | 37 |
| 38 const char kApiScope[] = "https://www.googleapis.com/auth/onegoogle.readonly"; | 38 const char kApiScope[] = "https://www.googleapis.com/auth/onegoogle.api"; |
| 39 const char kAuthorizationRequestHeaderFormat[] = "Bearer %s"; | 39 const char kAuthorizationRequestHeaderFormat[] = "Bearer %s"; |
| 40 | 40 |
| 41 const char kResponsePreamble[] = ")]}'"; | 41 const char kResponsePreamble[] = ")]}'"; |
| 42 | 42 |
| 43 // This namespace contains helpers to extract SafeHtml-wrapped strings (see | 43 // This namespace contains helpers to extract SafeHtml-wrapped strings (see |
| 44 // https://github.com/google/safe-html-types) from the response json. If there | 44 // https://github.com/google/safe-html-types) from the response json. If there |
| 45 // is ever a C++ version of the SafeHtml types, we should consider using that | 45 // is ever a C++ version of the SafeHtml types, we should consider using that |
| 46 // instead of these custom functions. | 46 // instead of these custom functions. |
| 47 namespace safe_html { | 47 namespace safe_html { |
| 48 | 48 |
| (...skipping 316 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 365 Respond(base::nullopt); | 365 Respond(base::nullopt); |
| 366 } | 366 } |
| 367 | 367 |
| 368 void OneGoogleBarFetcherImpl::Respond( | 368 void OneGoogleBarFetcherImpl::Respond( |
| 369 const base::Optional<OneGoogleBarData>& data) { | 369 const base::Optional<OneGoogleBarData>& data) { |
| 370 for (auto& callback : callbacks_) { | 370 for (auto& callback : callbacks_) { |
| 371 std::move(callback).Run(data); | 371 std::move(callback).Run(data); |
| 372 } | 372 } |
| 373 callbacks_.clear(); | 373 callbacks_.clear(); |
| 374 } | 374 } |
| OLD | NEW |