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"
16 // Decides the navigation policy for a web state.
17 class WebStatePolicyDecider
{
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_
; }
39 // Designated constructor. Subscribes to |web_state|.
40 explicit WebStatePolicyDecider(WebState
* web_state
);
43 friend class WebStateImpl
;
45 // Resets the current web state.
48 // The web state to decide navigation policy for.
51 DISALLOW_COPY_AND_ASSIGN(WebStatePolicyDecider
);
55 #endif // IOS_WEB_PUBLIC_WEB_STATE_WEB_STATE_POLICY_DECIDER_H_