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

Side by Side Diff: components/data_reduction_proxy/content/browser/content_lofi_ui_service.cc

Issue 2250223002: Add InfoBar delegate for previews (Closed) Base URL: https://chromium.googlesource.com/chromium/src.git@master
Patch Set: rebase Created 4 years, 3 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
1 // Copyright 2015 The Chromium Authors. All rights reserved. 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 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 "components/data_reduction_proxy/content/browser/content_lofi_ui_servic e.h" 5 #include "components/data_reduction_proxy/content/browser/content_lofi_ui_servic e.h"
6 6
7 #include "base/bind.h" 7 #include "base/bind.h"
8 #include "base/location.h" 8 #include "base/location.h"
9 #include "base/single_thread_task_runner.h" 9 #include "base/single_thread_task_runner.h"
10 #include "content/public/browser/browser_thread.h" 10 #include "content/public/browser/browser_thread.h"
11 #include "content/public/browser/render_frame_host.h" 11 #include "content/public/browser/render_frame_host.h"
12 #include "content/public/browser/resource_request_info.h" 12 #include "content/public/browser/resource_request_info.h"
13 #include "content/public/browser/web_contents.h" 13 #include "content/public/browser/web_contents.h"
14 #include "net/url_request/url_request.h" 14 #include "net/url_request/url_request.h"
15 15
16 namespace data_reduction_proxy { 16 namespace data_reduction_proxy {
17 17
18 ContentLoFiUIService::ContentLoFiUIService( 18 ContentLoFiUIService::ContentLoFiUIService(
19 const scoped_refptr<base::SingleThreadTaskRunner>& ui_task_runner, 19 const scoped_refptr<base::SingleThreadTaskRunner>& ui_task_runner,
20 const OnLoFiResponseReceivedCallback& 20 const OnLoFiResponseReceivedCallback&
21 notify_lofi_response_received_callback) 21 notify_lofi_response_received_callback)
22 : ui_task_runner_(ui_task_runner), 22 : ui_task_runner_(ui_task_runner),
23 on_lofi_response_received_callback_( 23 on_lofi_response_received_callback_(
24 notify_lofi_response_received_callback) { 24 notify_lofi_response_received_callback) {
25 DCHECK(!on_lofi_response_received_callback_.is_null()); 25 DCHECK(!on_lofi_response_received_callback_.is_null());
26 } 26 }
27 27
28 ContentLoFiUIService::~ContentLoFiUIService() {} 28 ContentLoFiUIService::~ContentLoFiUIService() {}
29 29
30 void ContentLoFiUIService::OnLoFiReponseReceived(const net::URLRequest& request, 30 void ContentLoFiUIService::OnLoFiReponseReceived(
31 bool is_preview) { 31 const net::URLRequest& request) {
32 DCHECK_CURRENTLY_ON(content::BrowserThread::IO); 32 DCHECK_CURRENTLY_ON(content::BrowserThread::IO);
33 int render_process_id = -1; 33 int render_process_id = -1;
34 int render_frame_id = -1; 34 int render_frame_id = -1;
35 if (content::ResourceRequestInfo::GetRenderFrameForRequest( 35 if (content::ResourceRequestInfo::GetRenderFrameForRequest(
36 &request, &render_process_id, &render_frame_id)) { 36 &request, &render_process_id, &render_frame_id)) {
37 ui_task_runner_->PostTask( 37 ui_task_runner_->PostTask(
38 FROM_HERE, 38 FROM_HERE,
39 base::Bind(&ContentLoFiUIService::OnLoFiResponseReceivedOnUIThread, 39 base::Bind(&ContentLoFiUIService::OnLoFiResponseReceivedOnUIThread,
40 base::Unretained(this), render_process_id, render_frame_id, 40 base::Unretained(this), render_process_id, render_frame_id));
41 is_preview));
42 } 41 }
43 } 42 }
44 43
45 void ContentLoFiUIService::OnLoFiResponseReceivedOnUIThread( 44 void ContentLoFiUIService::OnLoFiResponseReceivedOnUIThread(
46 int render_process_id, 45 int render_process_id,
47 int render_frame_id, 46 int render_frame_id) {
48 bool is_preview) {
49 DCHECK(ui_task_runner_->BelongsToCurrentThread()); 47 DCHECK(ui_task_runner_->BelongsToCurrentThread());
50 content::RenderFrameHost* frame = 48 content::RenderFrameHost* frame =
51 content::RenderFrameHost::FromID(render_process_id, render_frame_id); 49 content::RenderFrameHost::FromID(render_process_id, render_frame_id);
52 if (frame) { 50 if (frame) {
53 DCHECK(!on_lofi_response_received_callback_.is_null()); 51 DCHECK(!on_lofi_response_received_callback_.is_null());
54 content::WebContents* web_contents = 52 content::WebContents* web_contents =
55 content::WebContents::FromRenderFrameHost(frame); 53 content::WebContents::FromRenderFrameHost(frame);
56 on_lofi_response_received_callback_.Run(web_contents, is_preview); 54 on_lofi_response_received_callback_.Run(web_contents);
57 } 55 }
58 } 56 }
59 57
60 } // namespace data_reduction_proxy 58 } // namespace data_reduction_proxy
OLDNEW

Powered by Google App Engine
This is Rietveld 408576698