Roll src/third_party/WebKit d9c6159:8139f33 (svn 201974:201975)
[chromium-blink-merge.git] / ios / web / public / web_state / web_state_policy_decider.h
blob158fb8275e23bd815aeb70b292e03498799cc600
1 // Copyright 2015 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.
5 #ifndef IOS_WEB_PUBLIC_WEB_STATE_WEB_STATE_POLICY_DECIDER_H_
6 #define IOS_WEB_PUBLIC_WEB_STATE_WEB_STATE_POLICY_DECIDER_H_
8 #import <Foundation/Foundation.h>
10 #include "base/macros.h"
12 namespace web {
14 class WebState;
16 // Decides the navigation policy for a web state.
17 class WebStatePolicyDecider {
18 public:
19 // Removes self as a policy decider of |web_state_|.
20 virtual ~WebStatePolicyDecider();
22 // Asks the decider whether the navigation corresponding to |request| should
23 // be allowed to continue. Defaults to true if not overriden.
24 virtual bool ShouldAllowRequest(NSURLRequest* request);
26 // Asks the decider whether the navigation corresponding to |response| should
27 // be allowed to continue. Defaults to true if not overriden.
28 virtual bool ShouldAllowResponse(NSURLResponse* response);
30 // Notifies the policy decider that the web state is being destroyed.
31 // Gives subclasses a chance to cleanup.
32 // The policy decider must not be destroyed while in this call, as removing
33 // while iterating is not supported.
34 virtual void WebStateDestroyed() {}
36 WebState* web_state() const { return web_state_; }
38 protected:
39 // Designated constructor. Subscribes to |web_state|.
40 explicit WebStatePolicyDecider(WebState* web_state);
42 private:
43 friend class WebStateImpl;
45 // Resets the current web state.
46 void ResetWebState();
48 // The web state to decide navigation policy for.
49 WebState* web_state_;
51 DISALLOW_COPY_AND_ASSIGN(WebStatePolicyDecider);
55 #endif // IOS_WEB_PUBLIC_WEB_STATE_WEB_STATE_POLICY_DECIDER_H_