0
|
1 |
/*
|
|
2 |
* Copyright (C) 2006, 2007, 2008, 2009 Apple Inc. All rights reserved.
|
|
3 |
* Copyright (C) 2008, 2009 Torch Mobile Inc. All rights reserved. (http://www.torchmobile.com/)
|
|
4 |
*
|
|
5 |
* Redistribution and use in source and binary forms, with or without
|
|
6 |
* modification, are permitted provided that the following conditions
|
|
7 |
* are met:
|
|
8 |
*
|
|
9 |
* 1. Redistributions of source code must retain the above copyright
|
|
10 |
* notice, this list of conditions and the following disclaimer.
|
|
11 |
* 2. Redistributions in binary form must reproduce the above copyright
|
|
12 |
* notice, this list of conditions and the following disclaimer in the
|
|
13 |
* documentation and/or other materials provided with the distribution.
|
|
14 |
* 3. Neither the name of Apple Computer, Inc. ("Apple") nor the names of
|
|
15 |
* its contributors may be used to endorse or promote products derived
|
|
16 |
* from this software without specific prior written permission.
|
|
17 |
*
|
|
18 |
* THIS SOFTWARE IS PROVIDED BY APPLE AND ITS CONTRIBUTORS "AS IS" AND ANY
|
|
19 |
* EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE IMPLIED
|
|
20 |
* WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE ARE
|
|
21 |
* DISCLAIMED. IN NO EVENT SHALL APPLE OR ITS CONTRIBUTORS BE LIABLE FOR ANY
|
|
22 |
* DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES
|
|
23 |
* (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES;
|
|
24 |
* LOSS OF USE, DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND
|
|
25 |
* ON ANY THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT
|
|
26 |
* (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE OF
|
|
27 |
* THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE.
|
|
28 |
*/
|
|
29 |
|
|
30 |
#ifndef PolicyChecker_h
|
|
31 |
#define PolicyChecker_h
|
|
32 |
|
|
33 |
#include "FrameLoaderTypes.h"
|
|
34 |
#include "PlatformString.h"
|
|
35 |
#include "PolicyCallback.h"
|
|
36 |
#include "ResourceRequest.h"
|
|
37 |
#include <wtf/PassRefPtr.h>
|
|
38 |
|
|
39 |
namespace WebCore {
|
|
40 |
|
|
41 |
class DocumentLoader;
|
|
42 |
class FormState;
|
|
43 |
class Frame;
|
|
44 |
class NavigationAction;
|
|
45 |
class ResourceError;
|
|
46 |
class ResourceResponse;
|
|
47 |
|
|
48 |
class PolicyChecker : public Noncopyable {
|
|
49 |
public:
|
|
50 |
PolicyChecker(Frame*);
|
|
51 |
|
|
52 |
void checkNavigationPolicy(const ResourceRequest&, DocumentLoader*, PassRefPtr<FormState>, NavigationPolicyDecisionFunction, void* argument);
|
|
53 |
void checkNavigationPolicy(const ResourceRequest&, NavigationPolicyDecisionFunction, void* argument);
|
|
54 |
void checkNewWindowPolicy(const NavigationAction&, NewWindowPolicyDecisionFunction, const ResourceRequest&, PassRefPtr<FormState>, const String& frameName, void* argument);
|
|
55 |
void checkContentPolicy(const String& MIMEType, ContentPolicyDecisionFunction, void* argument);
|
|
56 |
|
|
57 |
// FIXME: These are different. They could use better names.
|
|
58 |
void cancelCheck();
|
|
59 |
void stopCheck();
|
|
60 |
|
|
61 |
void cannotShowMIMEType(const ResourceResponse&);
|
|
62 |
|
|
63 |
FrameLoadType loadType() const { return m_loadType; }
|
|
64 |
void setLoadType(FrameLoadType loadType) { m_loadType = loadType; }
|
|
65 |
|
|
66 |
bool delegateIsDecidingNavigationPolicy() const { return m_delegateIsDecidingNavigationPolicy; }
|
|
67 |
bool delegateIsHandlingUnimplementablePolicy() const { return m_delegateIsHandlingUnimplementablePolicy; }
|
|
68 |
|
|
69 |
// FIXME: This function is a cheat. Basically, this is just an asynchronouc callback
|
|
70 |
// from the FrameLoaderClient, but this callback uses the policy types and so has to
|
|
71 |
// live on this object. In the long term, we should create a type for non-policy
|
|
72 |
// callbacks from the FrameLoaderClient and remove this vestige. I just don't have
|
|
73 |
// the heart to hack on all the platforms to make that happen right now.
|
|
74 |
void continueLoadAfterWillSubmitForm(PolicyAction);
|
|
75 |
|
|
76 |
private:
|
|
77 |
void continueAfterNavigationPolicy(PolicyAction);
|
|
78 |
void continueAfterNewWindowPolicy(PolicyAction);
|
|
79 |
void continueAfterContentPolicy(PolicyAction);
|
|
80 |
|
|
81 |
void handleUnimplementablePolicy(const ResourceError&);
|
|
82 |
|
|
83 |
Frame* m_frame;
|
|
84 |
|
|
85 |
bool m_delegateIsDecidingNavigationPolicy;
|
|
86 |
bool m_delegateIsHandlingUnimplementablePolicy;
|
|
87 |
|
|
88 |
// This identifies the type of navigation action which prompted this load. Note
|
|
89 |
// that WebKit conveys this value as the WebActionNavigationTypeKey value
|
|
90 |
// on navigation action delegate callbacks.
|
|
91 |
FrameLoadType m_loadType;
|
|
92 |
PolicyCallback m_callback;
|
|
93 |
};
|
|
94 |
|
|
95 |
} // namespace WebCore
|
|
96 |
|
|
97 |
#endif // PolicyChecker_h
|