| 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 "content/renderer/fetchers/manifest_fetcher.h" | 5 #include "content/renderer/fetchers/manifest_fetcher.h" |
| 6 | 6 |
| 7 #include "base/bind.h" | 7 #include "base/bind.h" |
| 8 #include "base/logging.h" | 8 #include "base/logging.h" |
| 9 #include "content/public/renderer/associated_resource_fetcher.h" | 9 #include "content/public/renderer/associated_resource_fetcher.h" |
| 10 #include "third_party/WebKit/public/platform/WebURLRequest.h" | 10 #include "third_party/WebKit/public/platform/WebURLRequest.h" |
| 11 #include "third_party/WebKit/public/web/WebAssociatedURLLoaderOptions.h" | 11 #include "third_party/WebKit/public/web/WebAssociatedURLLoaderOptions.h" |
| 12 #include "third_party/WebKit/public/web/WebFrame.h" | 12 #include "third_party/WebKit/public/web/WebLocalFrame.h" |
| 13 | 13 |
| 14 namespace content { | 14 namespace content { |
| 15 | 15 |
| 16 ManifestFetcher::ManifestFetcher(const GURL& url) | 16 ManifestFetcher::ManifestFetcher(const GURL& url) |
| 17 : completed_(false) { | 17 : completed_(false) { |
| 18 fetcher_.reset(AssociatedResourceFetcher::Create(url)); | 18 fetcher_.reset(AssociatedResourceFetcher::Create(url)); |
| 19 } | 19 } |
| 20 | 20 |
| 21 ManifestFetcher::~ManifestFetcher() { | 21 ManifestFetcher::~ManifestFetcher() { |
| 22 if (!completed_) | 22 if (!completed_) |
| 23 Cancel(); | 23 Cancel(); |
| 24 } | 24 } |
| 25 | 25 |
| 26 void ManifestFetcher::Start(blink::WebFrame* frame, | 26 void ManifestFetcher::Start(blink::WebLocalFrame* frame, |
| 27 bool use_credentials, | 27 bool use_credentials, |
| 28 const Callback& callback) { | 28 const Callback& callback) { |
| 29 callback_ = callback; | 29 callback_ = callback; |
| 30 | 30 |
| 31 blink::WebAssociatedURLLoaderOptions options; | 31 blink::WebAssociatedURLLoaderOptions options; |
| 32 // See https://w3c.github.io/manifest/. Use "include" when use_credentials is | 32 // See https://w3c.github.io/manifest/. Use "include" when use_credentials is |
| 33 // true, and "omit" otherwise. | 33 // true, and "omit" otherwise. |
| 34 options.fetch_credentials_mode = | 34 options.fetch_credentials_mode = |
| 35 use_credentials ? blink::WebURLRequest::kFetchCredentialsModeInclude | 35 use_credentials ? blink::WebURLRequest::kFetchCredentialsModeInclude |
| 36 : blink::WebURLRequest::kFetchCredentialsModeOmit; | 36 : blink::WebURLRequest::kFetchCredentialsModeOmit; |
| (...skipping 13 matching lines...) Expand all Loading... |
| 50 | 50 |
| 51 void ManifestFetcher::OnLoadComplete(const blink::WebURLResponse& response, | 51 void ManifestFetcher::OnLoadComplete(const blink::WebURLResponse& response, |
| 52 const std::string& data) { | 52 const std::string& data) { |
| 53 DCHECK(!completed_); | 53 DCHECK(!completed_); |
| 54 completed_ = true; | 54 completed_ = true; |
| 55 | 55 |
| 56 Callback callback = callback_; | 56 Callback callback = callback_; |
| 57 callback.Run(response, data); | 57 callback.Run(response, data); |
| 58 } | 58 } |
| 59 | 59 |
| 60 } // namespace content | 60 } // namespace content |
| OLD | NEW |