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

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

Issue 830503004: Data Reduction Proxy blocking page and resources (Closed) Base URL: https://chromium.googlesource.com/chromium/src.git@interstitalStep1
Patch Set: Rebase and crash fixes Created 5 years, 11 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 (c) 2012 The Chromium Authors. All rights reserved. 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 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/data_reduction_proxy_u i_manager.h" 5 #include "components/data_reduction_proxy/content/browser/data_reduction_proxy_u i_manager.h"
6 6
7 #include <vector> 7 #include <vector>
8 8
9 #include "base/bind.h" 9 #include "base/bind.h"
10 #include "base/time/time.h" 10 #include "base/time/time.h"
11 #include "components/data_reduction_proxy/content/browser/data_reduction_proxy_b locking_page.h"
11 #include "content/public/browser/render_view_host.h" 12 #include "content/public/browser/render_view_host.h"
12 #include "content/public/browser/web_contents.h" 13 #include "content/public/browser/web_contents.h"
13 14
14 namespace data_reduction_proxy { 15 namespace data_reduction_proxy {
15 16
16 namespace { 17 namespace {
17 18
18 // Once the blocking page is shown, it is not displayed for another five 19 // Once the blocking page is shown, it is not displayed for another five
19 // minutes. 20 // minutes.
20 const int kBlockingPageDelayInMinutes = 5; 21 const int kBlockingPageDelayInMinutes = 5;
(...skipping 42 matching lines...) Expand 10 before | Expand all | Expand 10 after
63 if (base::Time::Now() - blocking_page_last_shown_ < 64 if (base::Time::Now() - blocking_page_last_shown_ <
64 base::TimeDelta::FromMinutes(kBlockingPageDelayInMinutes)) { 65 base::TimeDelta::FromMinutes(kBlockingPageDelayInMinutes)) {
65 if (!resource.callback.is_null()) 66 if (!resource.callback.is_null())
66 io_task_runner_->PostTask(FROM_HERE, base::Bind(resource.callback, true)); 67 io_task_runner_->PostTask(FROM_HERE, base::Bind(resource.callback, true));
67 return; 68 return;
68 } 69 }
69 70
70 if (IsTabClosed(resource)) { 71 if (IsTabClosed(resource)) {
71 // The tab is gone and there was not a chance to show the interstitial. 72 // The tab is gone and there was not a chance to show the interstitial.
72 // Just act as if "Don't Proceed" were chosen. 73 // Just act as if "Don't Proceed" were chosen.
74 std::vector<BypassResource> resources;
75 resources.push_back(resource);
73 io_task_runner_->PostTask( 76 io_task_runner_->PostTask(
74 FROM_HERE, 77 FROM_HERE,
75 base::Bind(&DataReductionProxyUIManager::OnBlockingPageDone, 78 base::Bind(&DataReductionProxyUIManager::OnBlockingPageDone,
76 this, resource, false)); 79 this, resources, false));
77 return; 80 return;
78 } 81 }
79 82
80 // TODO(megjablon): Show blocking page. For now, continue on to the page. 83 ShowBlockingPage(resource);
81 io_task_runner_->PostTask( 84 }
82 FROM_HERE, 85
83 base::Bind(&DataReductionProxyUIManager::OnBlockingPageDone, 86 void DataReductionProxyUIManager::ShowBlockingPage(
84 this, resource, true)); 87 const BypassResource& resource) {
88 DataReductionProxyBlockingPage::ShowBlockingPage(
89 this, io_task_runner_, resource);
85 } 90 }
86 91
87 void DataReductionProxyUIManager::OnBlockingPageDone( 92 void DataReductionProxyUIManager::OnBlockingPageDone(
88 const BypassResource& resource, 93 const std::vector<BypassResource>& resources,
89 bool proceed) { 94 bool proceed) {
90 DCHECK(io_task_runner_->BelongsToCurrentThread()); 95 DCHECK(io_task_runner_->BelongsToCurrentThread());
91 if (!resource.callback.is_null()) 96 for (std::vector<BypassResource>::const_iterator iter = resources.begin();
92 resource.callback.Run(proceed); 97 iter != resources.end(); ++iter) {
98 const BypassResource& resource = *iter;
99 if (!resource.callback.is_null())
100 resource.callback.Run(proceed);
101 }
93 if (proceed) 102 if (proceed)
94 blocking_page_last_shown_ = base::Time::Now(); 103 blocking_page_last_shown_ = base::Time::Now();
95 } 104 }
96 105
97 } // namespace data_reduction_proxy 106 } // namespace data_reduction_proxy
OLDNEW

Powered by Google App Engine
This is Rietveld 408576698