summaryrefslogtreecommitdiffstats
path: root/chrome/browser/managed_mode/managed_mode_resource_throttle.h
blob: acefa966d4fa067c95992bf09c5d8f1f1a5d01c6 (plain)
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
// Copyright (c) 2012 The Chromium Authors. All rights reserved.
// Use of this source code is governed by a BSD-style license that can be
// found in the LICENSE file.

#ifndef CHROME_BROWSER_MANAGED_MODE_MANAGED_MODE_RESOURCE_THROTTLE_H_
#define CHROME_BROWSER_MANAGED_MODE_MANAGED_MODE_RESOURCE_THROTTLE_H_

#include "base/compiler_specific.h"
#include "base/memory/weak_ptr.h"
#include "content/public/browser/resource_throttle.h"

class ManagedModeURLFilter;

namespace net {
class URLRequest;
}

// This class temporarily blocks network requests that aren't whitelisted,
// and allows resuming them later.
class ManagedModeResourceThrottle : public content::ResourceThrottle {
 public:
  ManagedModeResourceThrottle(const net::URLRequest* request,
                              int render_process_host_id,
                              int render_view_id,
                              bool is_main_frame);
  virtual ~ManagedModeResourceThrottle();

  // content::ResourceThrottle implementation:
  virtual void WillStartRequest(bool* defer) OVERRIDE;

 private:
  void OnInterstitialResult(bool continue_request);

  base::WeakPtrFactory<ManagedModeResourceThrottle> weak_ptr_factory_;
  const net::URLRequest* request_;
  int render_process_host_id_;
  int render_view_id_;
  bool is_main_frame_;
  const ManagedModeURLFilter* url_filter_;

  DISALLOW_COPY_AND_ASSIGN(ManagedModeResourceThrottle);
};

#endif  // CHROME_BROWSER_MANAGED_MODE_MANAGED_MODE_RESOURCE_THROTTLE_H_