OLD | NEW |
---|---|
(Empty) | |
1 // Copyright 2015 The Chromium Authors. All rights reserved. | |
2 // Use of this source code is governed by a BSD-style license that can be | |
3 // found in the LICENSE file. | |
4 | |
5 #include "extensions/browser/guest_view/web_view/web_ui/web_ui_url_fetcher.h" | |
6 | |
7 #include "content/public/browser/browser_context.h" | |
8 #include "content/public/common/url_fetcher.h" | |
Devlin
2015/04/24 17:50:59
Why is this include needed?
Xi Han
2015/04/24 18:28:54
Removed.
| |
9 #include "net/base/load_flags.h" | |
10 #include "net/url_request/url_fetcher.h" | |
11 | |
12 WebUIURLFetcher::WebUIURLFetcher(content::BrowserContext* context, | |
13 int render_process_id, | |
14 int render_view_id, | |
15 const GURL& url, | |
16 const WebUILoadFileCallback& callback) | |
17 : context_(context), | |
18 render_process_id_(render_process_id), | |
19 render_view_id_(render_view_id), | |
20 url_(url), | |
21 callback_(callback) { | |
22 } | |
23 | |
24 WebUIURLFetcher::~WebUIURLFetcher() { | |
25 } | |
26 | |
27 void WebUIURLFetcher::Start() { | |
28 fetcher_.reset(net::URLFetcher::Create(url_, net::URLFetcher::GET, this)); | |
29 fetcher_->SetRequestContext(context_->GetRequestContext()); | |
30 fetcher_->SetLoadFlags(net::LOAD_DO_NOT_SAVE_COOKIES); | |
31 | |
32 content::AssociateURLFetcherWithRenderFrame( | |
33 fetcher_.get(), url_, render_process_id_, render_view_id_); | |
34 fetcher_->Start(); | |
35 } | |
36 | |
37 void WebUIURLFetcher::OnURLFetchComplete(const net::URLFetcher* source) { | |
38 CHECK_EQ(fetcher_.get(), source); | |
39 | |
40 std::string data; | |
41 bool result = false; | |
42 if (fetcher_->GetStatus().status() == net::URLRequestStatus::SUCCESS) { | |
43 result = fetcher_->GetResponseAsString(&data); | |
44 DCHECK(result); | |
45 } | |
46 fetcher_.reset(); | |
47 auto callback_cache = callback_; | |
Devlin
2015/04/24 17:50:59
A quick comment on why we do this would be good.
/
Xi Han
2015/04/24 18:28:54
Done.
| |
48 callback_.Reset(); | |
49 callback_cache.Run(result, data); | |
50 } | |
OLD | NEW |