OLD | NEW |
---|---|
(Empty) | |
1 // Copyright (c) 2012 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 "components/data_reduction_proxy/content/browser/data_reduction_proxy_u i_manager.h" | |
6 | |
7 #include "base/bind.h" | |
8 #include "base/bind_helpers.h" | |
bengr
2014/12/29 18:45:42
Why is this needed?
megjablon
2014/12/30 23:40:00
Removed.
| |
9 #include "base/threading/thread.h" | |
bengr
2014/12/29 18:45:42
Why is this needed?
megjablon
2014/12/30 23:40:01
Removed.
| |
10 #include "content/public/browser/browser_thread.h" | |
11 #include "content/public/browser/render_view_host.h" | |
12 #include "content/public/browser/web_contents.h" | |
13 #include "net/url_request/url_request_context.h" | |
bengr
2014/12/29 18:45:42
Why is this needed?
megjablon
2014/12/30 23:40:00
Removed.
| |
14 #include "net/url_request/url_request_context_getter.h" | |
bengr
2014/12/29 18:45:42
Why is this needed?
megjablon
2014/12/30 23:40:00
Removed.
| |
15 | |
16 namespace data_reduction_proxy { | |
17 | |
18 DataReductionProxyUIManager::BypassResource::BypassResource() | |
19 : is_subresource(false), | |
20 render_process_host_id(-1), | |
21 render_view_id(-1) { | |
22 } | |
23 | |
24 DataReductionProxyUIManager::BypassResource::~BypassResource() { | |
25 } | |
26 | |
27 DataReductionProxyUIManager::DataReductionProxyUIManager() { | |
28 } | |
29 | |
30 DataReductionProxyUIManager::~DataReductionProxyUIManager() { | |
31 } | |
32 | |
33 void DataReductionProxyUIManager::OnBlockingPageDone( | |
bengr
2014/12/29 18:45:42
This needs a test, that checks that the callbacks
megjablon
2014/12/30 23:40:00
Done.
| |
34 const std::vector<BypassResource>& resources, | |
35 bool proceed) { | |
36 DCHECK(content::BrowserThread::CurrentlyOn(content::BrowserThread::IO)); | |
37 for (std::vector<BypassResource>::const_iterator iter = resources.begin(); | |
38 iter != resources.end(); ++iter) { | |
39 const BypassResource& resource = *iter; | |
40 if (!resource.callback.is_null()) | |
41 resource.callback.Run(proceed); | |
42 | |
43 if (proceed) | |
44 proceed_blocking_page_ = base::Time::Now(); | |
bengr
2014/12/29 18:45:42
#include "base/time/time.h"
megjablon
2014/12/30 23:40:00
Done.
| |
45 } | |
46 } | |
47 | |
48 void DataReductionProxyUIManager::DisplayBlockingPage( | |
bengr
2014/12/29 18:45:42
This needs tests. You should cover what happens if
megjablon
2014/12/30 23:40:00
Done.
| |
49 const BypassResource& resource) { | |
50 DCHECK(content::BrowserThread::CurrentlyOn(content::BrowserThread::UI)); | |
51 // Check if the user has already ignored our warning for this render_view | |
52 // and domain. | |
53 if (base::Time::Now() - proceed_blocking_page_ < | |
54 base::TimeDelta::FromMinutes(5)) { | |
bengr
2014/12/29 18:45:42
define 5 as a constant at the top of the file and
megjablon
2014/12/30 23:40:00
Done.
| |
55 if (!resource.callback.is_null()) { | |
56 content::BrowserThread::PostTask(content::BrowserThread::IO, FROM_HERE, | |
57 base::Bind(resource.callback, true)); | |
58 } | |
59 return; | |
60 } | |
61 | |
62 // The tab might have been closed. | |
63 content::RenderViewHost* render_view_host = | |
64 content::RenderViewHost::FromID(resource.render_process_host_id, | |
65 resource.render_view_id); | |
66 content::WebContents* web_contents = NULL; | |
bengr
2014/12/29 18:45:42
nullptr
megjablon
2014/12/30 23:40:00
Done.
| |
67 if (render_view_host) | |
68 web_contents = content::WebContents::FromRenderViewHost(render_view_host); | |
69 | |
70 if (!web_contents) { | |
71 // The tab is gone and we did not have a chance at showing the interstitial. | |
72 // Just act as if "Don't Proceed" were chosen. | |
73 std::vector<BypassResource> resources; | |
74 resources.push_back(resource); | |
75 content::BrowserThread::PostTask( | |
76 content::BrowserThread::IO, FROM_HERE, | |
77 base::Bind(&DataReductionProxyUIManager::OnBlockingPageDone, | |
78 this, resources, false)); | |
79 return; | |
80 } | |
81 | |
82 // TODO(megjablon): Show blocking page. For now, continue on to the page. | |
83 LOG(WARNING) << "BLOCKING PAGE!"; | |
bengr
2014/12/29 18:45:42
Remove.
megjablon
2014/12/30 23:40:01
Done.
| |
84 std::vector<BypassResource> resources; | |
bengr
2014/12/29 18:45:42
#include <vector>
megjablon
2014/12/30 23:40:00
Done.
| |
85 resources.push_back(resource); | |
86 content::BrowserThread::PostTask( | |
87 content::BrowserThread::IO, FROM_HERE, | |
88 base::Bind(&DataReductionProxyUIManager::OnBlockingPageDone, | |
89 this, resources, true)); | |
90 } | |
91 | |
92 } // namespace data_reduction_proxy | |
OLD | NEW |