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

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: Fix a test. 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"
9 #include "net/base/load_flags.h"
10
11 WebUIURLFetcher::WebUIURLFetcher(content::BrowserContext* context,
12 const WebUILoadFileCallback& callback)
13 : context_(context), callback_(callback) {
14 }
15
16 WebUIURLFetcher::~WebUIURLFetcher() {
17 }
18
19 void WebUIURLFetcher::Start(int render_process_id,
20 int render_view_id,
21 const GURL& url) {
22 fetcher_.reset(net::URLFetcher::Create(url, net::URLFetcher::GET, this));
23 fetcher_->SetRequestContext(context_->GetRequestContext());
24 fetcher_->SetLoadFlags(net::LOAD_DO_NOT_SAVE_COOKIES);
25
26 content::AssociateURLFetcherWithRenderFrame(
27 fetcher_.get(), url, render_process_id, render_view_id);
28 fetcher_->Start();
29 }
30
31 void WebUIURLFetcher::OnURLFetchComplete(const net::URLFetcher* source) {
32 CHECK_EQ(fetcher_.get(), source);
33
34 std::string data;
35 bool result = false;
36 if (fetcher_->GetStatus().status() == net::URLRequestStatus::SUCCESS) {
37 result = fetcher_->GetResponseAsString(&data);
38 DCHECK(result);
39 }
40 fetcher_.reset();
41 callback_.Run(result, data);
42 callback_.Reset();
43 }
OLDNEW

Powered by Google App Engine
This is Rietveld 408576698