Update To 11.40.268.0
[platform/framework/web/crosswalk.git] / src / chrome / browser / supervised_user / supervised_user_resource_throttle.h
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 CHROME_BROWSER_SUPERVISED_USER_SUPERVISED_USER_RESOURCE_THROTTLE_H_
6 #define CHROME_BROWSER_SUPERVISED_USER_SUPERVISED_USER_RESOURCE_THROTTLE_H_
7
8 #include "base/compiler_specific.h"
9 #include "base/memory/weak_ptr.h"
10 #include "chrome/browser/supervised_user/supervised_user_url_filter.h"
11 #include "chrome/browser/supervised_user/supervised_users.h"
12 #include "content/public/browser/resource_throttle.h"
13
14 namespace net {
15 class URLRequest;
16 }
17
18 class SupervisedUserResourceThrottle : public content::ResourceThrottle {
19  public:
20   SupervisedUserResourceThrottle(const net::URLRequest* request,
21                                  bool is_main_frame,
22                                  const SupervisedUserURLFilter* url_filter);
23   ~SupervisedUserResourceThrottle() override;
24
25   // content::ResourceThrottle implementation:
26   void WillStartRequest(bool* defer) override;
27
28   void WillRedirectRequest(const GURL& new_url, bool* defer) override;
29
30   const char* GetNameForLogging() const override;
31
32  private:
33   void ShowInterstitialIfNeeded(bool is_redirect, const GURL& url, bool* defer);
34   void ShowInterstitial(const GURL& url);
35   void OnCheckDone(const GURL& url,
36                    SupervisedUserURLFilter::FilteringBehavior behavior,
37                    SupervisedUserURLFilter::FilteringBehaviorSource source,
38                    bool uncertain);
39   void OnInterstitialResult(bool continue_request);
40
41   const net::URLRequest* request_;
42   bool is_main_frame_;
43   const SupervisedUserURLFilter* url_filter_;
44   bool deferred_;
45   SupervisedUserURLFilter::FilteringBehavior behavior_;
46   base::WeakPtrFactory<SupervisedUserResourceThrottle> weak_ptr_factory_;
47
48   DISALLOW_COPY_AND_ASSIGN(SupervisedUserResourceThrottle);
49 };
50
51 #endif  // CHROME_BROWSER_SUPERVISED_USER_SUPERVISED_USER_RESOURCE_THROTTLE_H_