OLD | NEW |
---|---|
(Empty) | |
1 // Copyright 2014 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 #ifndef COMPONENTS_DATA_REDUCTION_PROXY_CONTENT_BROWSER_DATA_REDUCTION_PROXY_UI_ MANAGER_H_ | |
6 #define COMPONENTS_DATA_REDUCTION_PROXY_CONTENT_BROWSER_DATA_REDUCTION_PROXY_UI_ MANAGER_H_ | |
7 | |
8 #include <vector> | |
9 | |
10 #include "base/callback.h" | |
11 #include "base/memory/ref_counted.h" | |
12 #include "base/time/time.h" | |
13 #include "url/gurl.h" | |
14 | |
15 namespace base { | |
16 class Time; | |
bengr
2014/12/29 18:45:42
Remove this forward declaration.
megjablon
2014/12/30 23:40:01
Done.
| |
17 class Thread; | |
bengr
2014/12/29 18:45:42
Why is this needed?
megjablon
2014/12/30 23:40:01
No longer needed. Removed.
| |
18 } | |
19 | |
20 namespace data_reduction_proxy { | |
21 | |
22 // Construction needs to happen on the main thread. | |
23 class DataReductionProxyUIManager | |
24 : public base::RefCountedThreadSafe<DataReductionProxyUIManager> { | |
25 public: | |
26 // Passed a boolean indicating whether or not it is OK to proceed with | |
27 // loading an URL. | |
28 typedef base::Callback<void(bool /*proceed*/)> UrlCheckCallback; | |
29 | |
30 // Structure used to pass parameters between the IO and UI thread when | |
31 // interacting with the blocking page. | |
32 struct BypassResource { | |
33 BypassResource(); | |
34 ~BypassResource(); | |
35 | |
36 GURL url; | |
37 bool is_subresource; | |
38 UrlCheckCallback callback; // This is called back on the IO thread. | |
39 int render_process_host_id; | |
40 int render_view_id; | |
41 }; | |
42 | |
43 // The data reduction proxy ui manager handles displaying blocking pages. | |
44 // After a page is loaded from the blocking page, another blocking page will | |
45 // not be shown for 5 minutes. | |
46 DataReductionProxyUIManager(); | |
47 | |
48 // Called on the UI thread to display an interstitial page. | |
49 // |url| is the url of the resource that matches a safe browsing list. | |
50 // If the request contained a chain of redirects, |url| is the last url | |
51 // in the chain, and |original_url| is the first one (the root of the | |
52 // chain). Otherwise, |original_url| = |url|. | |
53 virtual void DisplayBlockingPage(const BypassResource& resource); | |
54 | |
55 // The blocking page on the UI thread has completed. | |
56 void OnBlockingPageDone(const std::vector<BypassResource>& resources, | |
57 bool proceed); | |
58 | |
59 private: | |
60 // Ref counted classes have private destructors to avoid any code deleting the | |
61 // object accidentally while there are still references to it. | |
62 friend class base::RefCountedThreadSafe<DataReductionProxyUIManager>; | |
63 | |
64 virtual ~DataReductionProxyUIManager(); | |
65 | |
66 base::Time proceed_blocking_page_; | |
bengr
2014/12/29 18:45:42
Why is this a Time? Consider a more descriptive va
megjablon
2014/12/30 23:40:01
What other type do you suggest?
| |
67 | |
68 DISALLOW_COPY_AND_ASSIGN(DataReductionProxyUIManager); | |
69 }; | |
70 | |
71 } // namespace data_reduction_proxy | |
72 | |
73 #endif // COMPONENTS_DATA_REDUCTION_PROXY_CONTENT_BROWSER_DATA_REDUCTION_PROXY_ UI_MANAGER_H_ | |
OLD | NEW |