1/*
2 * Copyright (C) 2014 Apple Inc. All rights reserved.
3 *
4 * Redistribution and use in source and binary forms, with or without
5 * modification, are permitted provided that the following conditions
6 * are met:
7 * 1. Redistributions of source code must retain the above copyright
8 *    notice, this list of conditions and the following disclaimer.
9 * 2. Redistributions in binary form must reproduce the above copyright
10 *    notice, this list of conditions and the following disclaimer in the
11 *    documentation and/or other materials provided with the distribution.
12 *
13 * THIS SOFTWARE IS PROVIDED BY APPLE INC. AND ITS CONTRIBUTORS ``AS IS''
14 * AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO,
15 * THE IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR
16 * PURPOSE ARE DISCLAIMED. IN NO EVENT SHALL APPLE INC. OR ITS CONTRIBUTORS
17 * BE LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR
18 * CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF
19 * SUBSTITUTE GOODS OR SERVICES; LOSS OF USE, DATA, OR PROFITS; OR BUSINESS
20 * INTERRUPTION) HOWEVER CAUSED AND ON ANY THEORY OF LIABILITY, WHETHER IN
21 * CONTRACT, STRICT LIABILITY, OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE)
22 * ARISING IN ANY WAY OUT OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF
23 * THE POSSIBILITY OF SUCH DAMAGE.
24 */
25
26#import <WebKit/WKFoundation.h>
27
28#if WK_API_ENABLED
29
30#if TARGET_OS_IPHONE
31#import <Foundation/Foundation.h>
32#else
33#import <AppKit/AppKit.h>
34#endif
35
36@class WKFrameInfo;
37
38/*! @enum WKNavigationType
39 @abstract The type of action triggering a navigation.
40 @constant WKNavigationTypeLinkActivated    A link with an href attribute was activated by the user.
41 @constant WKNavigationTypeFormSubmitted    A form was submitted.
42 @constant WKNavigationTypeBackForward      An item from the back-forward list was requested.
43 @constant WKNavigationTypeReload           The webpage was reloaded.
44 @constant WKNavigationTypeFormResubmitted  A form was resubmitted (for example by going back, going forward, or reloading).
45 @constant WKNavigationTypeOther            Navigation is taking place for some other reason.
46 */
47typedef NS_ENUM(NSInteger, WKNavigationType) {
48    WKNavigationTypeLinkActivated,
49    WKNavigationTypeFormSubmitted,
50    WKNavigationTypeBackForward,
51    WKNavigationTypeReload,
52    WKNavigationTypeFormResubmitted,
53    WKNavigationTypeOther = -1,
54} WK_ENUM_AVAILABLE(10_10, 8_0);
55
56/*!
57A WKNavigationAction object contains information about an action that may cause a navigation, used for making policy decisions.
58 */
59WK_CLASS_AVAILABLE(10_10, 8_0)
60@interface WKNavigationAction : NSObject
61
62/*! @abstract The frame requesting the navigation.
63 */
64@property (nonatomic, readonly, copy) WKFrameInfo *sourceFrame;
65
66/*! @abstract The target frame, or nil if this is a new window navigation.
67 */
68@property (nonatomic, readonly, copy) WKFrameInfo *targetFrame;
69
70/*! @abstract The type of action that triggered the navigation.
71 @discussion The value is one of the constants of the enumerated type WKNavigationType.
72 */
73@property (nonatomic, readonly) WKNavigationType navigationType;
74
75/*! @abstract The navigation's request.
76 */
77@property (nonatomic, readonly, copy) NSURLRequest *request;
78
79#if !TARGET_OS_IPHONE
80
81/*! @abstract The modifier keys that were in effect when the navigation was requested.
82 */
83@property (nonatomic, readonly) NSEventModifierFlags modifierFlags;
84
85/*! @abstract The number of the mouse button causing the navigation to be requested.
86 */
87@property (nonatomic, readonly) NSInteger buttonNumber;
88
89#endif
90
91@end
92
93#endif
94