Chromium Code Reviews
chromiumcodereview-hr@appspot.gserviceaccount.com (chromiumcodereview-hr) | Please choose your nickname with Settings | Help | Chromium Project | Gerrit Changes | Sign out
(43)

Side by Side Diff: extensions/browser/guest_view/web_view/web_ui/web_ui_url_fetcher.cc

Issue 1056533002: Implement <webview>.addContentScript/removeContentScript API [2] (Closed) Base URL: https://chromium.googlesource.com/chromium/src.git@webview_addremove_contentscripts_2
Patch Set: Clean up. Created 5 years, 8 months ago
Use n/p to move between diff chunks; N/P to move between comments. Draft comments are only viewable by you.
Jump to:
View unified diff | Download patch
OLDNEW
(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 }
OLDNEW

Powered by Google App Engine
This is Rietveld 408576698