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

Side by Side Diff: components/data_reduction_proxy/content/browser/data_reduction_proxy_resource_throttle.h

Issue 684223003: Data Reduction Proxy Interstitials (Closed) Base URL: https://chromium.googlesource.com/chromium/src.git@master
Patch Set: Rebase 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
(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_RES OURCE_THROTTLE_H_
6 #define COMPONENTS_DATA_REDUCTION_PROXY_CONTENT_BROWSER_DATA_REDUCTION_PROXY_RES OURCE_THROTTLE_H_
7
8 #include "base/memory/ref_counted.h"
9 #include "base/memory/weak_ptr.h"
10 #include "components/data_reduction_proxy/content/browser/data_reduction_proxy_u i_manager.h"
11 #include "content/public/browser/resource_throttle.h"
12 #include "content/public/common/resource_type.h"
13 #include "url/gurl.h"
14
15 namespace net {
16 class URLRequest;
17 }
18
19 namespace data_reduction_proxy {
20
21 class DataReductionProxyParams;
22 class DataReductionProxyUIManager;
23 class DataReductionProxyUIService;
24
25 // Gets notified at various points during the process of loading a resource.
26 // Defers the resource load when the Data Reduction Proxy is not going to be
27 // used. Resumes or cancels a deferred resource load via the ResourceController.
28 //
29 // Displays a warning if the Data Reduction Proxy returns a response that
30 // triggers a bypass, when the proxy will not be used for a request because it
31 // isn't configured (a previous bypass), when the proxy is supposed to be used,
32 // but there is a connection error. Will not warn when the Data Reduction Proxy
33 // is bypassed by local rules, or when the url scheme is not proxied by the Data
34 // Reduction Proxy.
35 //
36 // This class is useful, e.g., for users that wish to be warned when
37 // configurations that are able to go through the Data Reduction Proxy are
38 // bypassed.
39 class DataReductionProxyResourceThrottle
40 : public content::ResourceThrottle,
41 public base::SupportsWeakPtr<DataReductionProxyResourceThrottle> {
42 public:
43 // Constructs a DataReductionProxyResourceThrottle object with the given
44 // request, resource type, ui service, and params.
45 DataReductionProxyResourceThrottle(
46 const net::URLRequest* request,
47 content::ResourceType resource_type,
48 const DataReductionProxyUIService* ui_service,
49 const DataReductionProxyParams* params);
50
51 virtual ~DataReductionProxyResourceThrottle();
52
53 // Overrides content::ResourceThrottle.
54 void WillStartUsingNetwork(bool* defer) override;
55 void WillRedirectRequest(const GURL& new_url, bool* defer) override;
56 void WillProcessResponse(bool* defer) override;
57 const char* GetNameForLogging() const override;
58
59 private:
60 enum State {
61 NOT_BYPASSED, // A warning has not been shown yet for this request.
62 LOCAL_BYPASS, // The request was bypassed by local bypass rules.
63 REMOTE_BYPASS, // The request was bypassed by the Data Reduction Proxy.
64 };
65
66 // Starts displaying the Data Reduction Proxy blocking page if it is not
67 // prerendering. Must only be called on the UI thread. Takes a bypass
68 // resource, which is a structure used to pass parameters between the IO and
69 // UI thread, and shows a DataReductionBlockingPage for the resource using
70 // the given ui_manager.
71 static void StartDisplayingBlockingPage(
72 scoped_refptr<DataReductionProxyUIManager> ui_manager,
73 const DataReductionProxyUIManager::BypassResource& resource);
74
75 // Creates a bypass resource and calls StartDisplayingBlockingPage on the UI
76 // thread. Sets defer to true. A bypass resource is a structure used to pass
77 // parameters between the IO and UI thread when interacting with the
78 // interstitial. Virtual for testing.
79 virtual void DisplayBlockingPage(bool* defer);
80
81 // Called on the IO thread when the user has decided to proceed with the
82 // current request, or go back.
83 void OnBlockingPageComplete(bool proceed);
84
85 // The bypass state of this.
86 State state_;
87
88 // Must outlive |this|.
89 const net::URLRequest* request_;
90
91 // Holds the UI manager that shows interstitials. Must outlive |this|.
92 const DataReductionProxyUIService* ui_service_;
93
94 // Must outlive |this|.
95 const DataReductionProxyParams* params_;
96
97 const bool is_subresource_;
98
99 DISALLOW_COPY_AND_ASSIGN(DataReductionProxyResourceThrottle);
100 };
101
102 } // namespace data_reduction_proxy
103
104 #endif // COMPONENTS_DATA_REDUCTION_PROXY_CONTENT_BROWSER_DATA_REDUCTION_PROXY_ RESOURCE_THROTTLE_H_
OLDNEW

Powered by Google App Engine
This is Rietveld 408576698