# Copyright (C) 2010, 2011 Apple Inc. All rights reserved.
#
# Redistribution and use in source and binary forms, with or without
# modification, are permitted provided that the following conditions
# are met:
# 1.  Redistributions of source code must retain the above copyright
#     notice, this list of conditions and the following disclaimer.
# 2.  Redistributions in binary form must reproduce the above copyright
#     notice, this list of conditions and the following disclaimer in the
#     documentation and/or other materials provided with the distribution.
#
# THIS SOFTWARE IS PROVIDED BY APPLE INC. AND ITS CONTRIBUTORS ``AS IS'' AND
# ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE IMPLIED
# WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE ARE
# DISCLAIMED. IN NO EVENT SHALL APPLE INC. OR ITS CONTRIBUTORS BE LIABLE FOR
# ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL
# DAMAGES (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR
# SERVICES; LOSS OF USE, DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER
# CAUSED AND ON ANY THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY,
# OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE
# OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE.

messages -> WebPageProxy {
    # UI messages
    CreateNewPage(WebCore::ResourceRequest request, WebCore::WindowFeatures windowFeatures, uint32_t modifiers, int32_t mouseButton) -> (uint64_t newPageID, WebKit::WebPageCreationParameters newPageParameters)
    ShowPage()
    ClosePage(bool stopResponsivenessTimer)
    RunJavaScriptAlert(uint64_t frameID, String message) -> ()
    RunJavaScriptConfirm(uint64_t frameID, String message) -> (bool result)
    RunJavaScriptPrompt(uint64_t frameID, String message, String defaultValue) -> (String result)
    ShouldInterruptJavaScript() -> (bool shouldInterupt)
    MouseDidMoveOverElement(WebKit::WebHitTestResult::Data hitTestResultData, uint32_t modifiers, WebKit::InjectedBundleUserMessageEncoder userData) Variadic
#if ENABLE(NETSCAPE_PLUGIN_API)
    UnavailablePluginButtonClicked(uint32_t pluginUnavailabilityReason, String mimeType, String pluginURLString, String pluginspageAttributeURLString, String frameURLString, String pageURLString)
#endif // ENABLE(NETSCAPE_PLUGIN_API)
#if ENABLE(WEBGL)
    WebGLPolicyForURL(String url) -> (uint32_t loadPolicy)
#endif // ENABLE(WEBGL)
    DidChangeViewportProperties(WebCore::ViewportAttributes attributes)
    DidReceiveEvent(uint32_t type, bool handled)
    StopResponsivenessTimer()
#if !PLATFORM(IOS)
    SetCursor(WebCore::Cursor cursor)
    SetCursorHiddenUntilMouseMoves(bool hiddenUntilMouseMoves)
#endif
    SetStatusText(String statusText)
    SetToolTip(String toolTip)
    SetFocus(bool focused)
    TakeFocus(uint32_t direction)
    FocusedFrameChanged(uint64_t frameID)
    FrameSetLargestFrameChanged(uint64_t frameID)
    SetRenderTreeSize(uint64_t treeSize)
    SetToolbarsAreVisible(bool toolbarsAreVisible)
    GetToolbarsAreVisible() -> (bool toolbarsAreVisible)
    SetMenuBarIsVisible(bool menuBarIsVisible);
    GetMenuBarIsVisible() -> (bool menuBarIsVisible);
    SetStatusBarIsVisible(bool statusBarIsVisible)
    GetStatusBarIsVisible() -> (bool statusBarIsVisible)
    SetIsResizable(bool isResizable)
    GetIsResizable() -> (bool isResizable)
    SetWindowFrame(WebCore::FloatRect windowFrame)
    GetWindowFrame() -> (WebCore::FloatRect windowFrame)
    ScreenToWindow(WebCore::IntPoint screenPoint) -> (WebCore::IntPoint windowPoint)
    WindowToScreen(WebCore::IntRect rect) -> (WebCore::IntRect screenFrame)
    RunBeforeUnloadConfirmPanel(String message, uint64_t frameID) -> (bool shouldClose)
    PageDidScroll()
    RunOpenPanel(uint64_t frameID, WebCore::FileChooserSettings parameters)
    PrintFrame(uint64_t frameID) -> ()
    RunModal()
    NotifyScrollerThumbIsVisibleInRect(WebCore::IntRect scrollerThumb)
    RecommendedScrollbarStyleDidChange(int32_t newStyle)
    DidChangeScrollbarsForMainFrame(bool hasHorizontalScrollbar, bool hasVerticalScrollbar)
    DidChangeScrollOffsetPinningForMainFrame(bool pinnedToLeftSide, bool pinnedToRightSide, bool pinnedToTopSide, bool pinnedToBottomSide)
    DidChangePageCount(unsigned pageCount);
#if ENABLE(NETSCAPE_PLUGIN_API)
    DidFailToInitializePlugin(String mimeType, String frameURLString, String pageURLString)
    DidBlockInsecurePluginVersion(String mimeType, String pluginURLString, String frameURLString, String pageURLString, bool replacementObscured)
#endif // ENABLE(NETSCAPE_PLUGIN_API)
    SetCanShortCircuitHorizontalWheelEvents(bool canShortCircuitHorizontalWheelEvents)

#if PLATFORM(EFL)
    HandleInputMethodKeydown() -> (bool handled)
#endif

#if USE(TILED_BACKING_STORE)
    PageDidRequestScroll(WebCore::IntPoint point)
    PageTransitionViewportReady()
#endif
#if USE(COORDINATED_GRAPHICS)
    DidFindZoomableArea(WebCore::IntPoint target, WebCore::IntRect area)
#endif

#if PLATFORM(EFL) || PLATFORM(IOS)
    DidChangeContentSize(WebCore::IntSize newSize)
#endif

#if ENABLE(TOUCH_EVENTS)
    NeedTouchEvents(bool needTouchEvents)
#endif

#if ENABLE(INPUT_TYPE_COLOR)
    ShowColorPicker(WebCore::Color initialColor, WebCore::IntRect elementRect);
    SetColorPickerColor(WebCore::Color color);
    EndColorPicker();
#endif

    # Policy messages
    DecidePolicyForResponseSync(uint64_t frameID, WebCore::ResourceResponse response, WebCore::ResourceRequest request, bool canShowMIMEType, uint64_t listenerID, WebKit::InjectedBundleUserMessageEncoder userData) -> (bool receivedPolicyAction, uint64_t policyAction, uint64_t downloadID) Variadic
    DecidePolicyForNavigationAction(uint64_t frameID, WebKit::NavigationActionData navigationActionData, uint64_t originatingFrameID, WebCore::ResourceRequest originalRequest, WebCore::ResourceRequest request, uint64_t listenerID, WebKit::InjectedBundleUserMessageEncoder userData) -> (bool receivedPolicyAction, uint64_t policyAction, uint64_t downloadID) Variadic
    DecidePolicyForNewWindowAction(uint64_t frameID, WebKit::NavigationActionData navigationActionData, WebCore::ResourceRequest request, String frameName, uint64_t listenerID, WebKit::InjectedBundleUserMessageEncoder userData) Variadic
    UnableToImplementPolicy(uint64_t frameID, WebCore::ResourceError error, WebKit::InjectedBundleUserMessageEncoder userData)  Variadic

    # Progress messages
    DidChangeProgress(double value)
    DidFinishProgress()
    DidStartProgress()

    # Frame lifetime messages
    DidCreateMainFrame(uint64_t frameID)
    DidCreateSubframe(uint64_t frameID)

    # Frame load messages
    DidCommitLoadForFrame(uint64_t frameID, String mimeType, uint32_t loadType, WebCore::CertificateInfo certificateInfo, WebKit::InjectedBundleUserMessageEncoder userData) Variadic
    DidFailLoadForFrame(uint64_t frameID, WebCore::ResourceError error, WebKit::InjectedBundleUserMessageEncoder userData) Variadic
    DidFailProvisionalLoadForFrame(uint64_t frameID, WebCore::ResourceError error, WebKit::InjectedBundleUserMessageEncoder userData) Variadic
    DidFinishDocumentLoadForFrame(uint64_t frameID, WebKit::InjectedBundleUserMessageEncoder userData) Variadic
    DidFinishLoadForFrame(uint64_t frameID, WebKit::InjectedBundleUserMessageEncoder userData) Variadic
    DidFirstLayoutForFrame(uint64_t frameID, WebKit::InjectedBundleUserMessageEncoder userData) Variadic
    DidFirstVisuallyNonEmptyLayoutForFrame(uint64_t frameID, WebKit::InjectedBundleUserMessageEncoder userData) Variadic
    DidLayout(uint32_t type, WebKit::InjectedBundleUserMessageEncoder userData) Variadic
    DidReceiveServerRedirectForProvisionalLoadForFrame(uint64_t frameID, String url, WebKit::InjectedBundleUserMessageEncoder userData) Variadic
    DidRemoveFrameFromHierarchy(uint64_t frameID, WebKit::InjectedBundleUserMessageEncoder userData) Variadic
    DidStartProvisionalLoadForFrame(uint64_t frameID, String url, String unreachableURL, WebKit::InjectedBundleUserMessageEncoder userData) Variadic
    DidReceiveTitleForFrame(uint64_t frameID, String title, WebKit::InjectedBundleUserMessageEncoder userData) Variadic
    DidDisplayInsecureContentForFrame(uint64_t frameID, WebKit::InjectedBundleUserMessageEncoder userData) Variadic
    DidRunInsecureContentForFrame(uint64_t frameID, WebKit::InjectedBundleUserMessageEncoder userData) Variadic
    DidDetectXSSForFrame(uint64_t frameID, WebKit::InjectedBundleUserMessageEncoder userData) Variadic
    DidSameDocumentNavigationForFrame(uint64_t frameID, uint32_t type, String url, WebKit::InjectedBundleUserMessageEncoder userData) Variadic

    FrameDidBecomeFrameSet(uint64_t frameID, bool value)

    # Forms messages
    WillSubmitForm(uint64_t frameID, uint64_t sourceFrameID, Vector<std::pair<String, String>> textFieldValues, uint64_t listenerID, WebKit::InjectedBundleUserMessageEncoder userData) Variadic

    # Callback messages
    VoidCallback(uint64_t callbackID)
    DataCallback(IPC::DataReference resultData, uint64_t callbackID)
    ImageCallback(WebKit::ShareableBitmap::Handle bitmapHandle, uint64_t callbackID)
    StringCallback(String resultString, uint64_t callbackID)
    ScriptValueCallback(IPC::DataReference resultData, uint64_t callbackID)
    ComputedPagesCallback(Vector<WebCore::IntRect> pageRects, double totalScaleFactorForPrinting, uint64_t callbackID)
    ValidateCommandCallback(String command, bool isEnabled, int32_t state, uint64_t callbackID)
#if PLATFORM(IOS)
    GestureCallback(WebCore::IntPoint point, uint32_t gestureType, uint32_t gestureState, uint32_t flags, uint64_t callbackID)
    TouchesCallback(WebCore::IntPoint point, uint32_t touches, uint64_t callbackID)
    AutocorrectionDataCallback(Vector<WebCore::FloatRect> textRects, String fontName, double fontSize, uint64_t traits, uint64_t callbackID)
    AutocorrectionContextCallback(String beforeText, String markedText, String selectedText, String afterText, uint64_t location, uint64_t length, uint64_t callbackID)
    InterpretKeyEvent(WebKit::EditorState state, bool isCharEvent) -> (bool handled)
    DidReceivePositionInformation(WebKit::InteractionInformationAtPosition information)
#endif
#if PLATFORM(GTK)
    PrintFinishedCallback(WebCore::ResourceError error, uint64_t callbackID)
#endif

    PageScaleFactorDidChange(double scaleFactor)
    PageZoomFactorDidChange(double zoomFactor)

#if PLATFORM(GTK)
    # Support for GTK+ platform keybindings
    GetEditorCommandsForKeyEvent(AtomicString eventType) -> (Vector<String> commandsList)

    # Support for connecting the Accessibility worlds of the UI and the Web processes
    BindAccessibilityTree(String plugID)

    SetInputMethodState(bool enabled);
#endif

    # BackForward messages
    BackForwardAddItem(uint64_t itemID)
    BackForwardGoToItem(uint64_t itemID) -> (WebKit::SandboxExtension::Handle sandboxExtensionHandle)
    BackForwardItemAtIndex(int32_t itemIndex) -> (uint64_t itemID)
    BackForwardBackListCount() -> (int32_t count)
    BackForwardForwardListCount() -> (int32_t count)
    BackForwardClear()
    WillGoToBackForwardListItem(uint64_t itemID, WebKit::InjectedBundleUserMessageEncoder userData) Variadic

    # Undo/Redo messages
    RegisterEditCommandForUndo(uint64_t commandID, uint32_t editAction)
    ClearAllEditCommands()
    CanUndoRedo(uint32_t action) -> (bool result)
    ExecuteUndoRedo(uint32_t action) -> (bool result)

    # Editor notifications
    EditorStateChanged(WebKit::EditorState editorState)

    # Find messages
    DidCountStringMatches(String string, uint32_t matchCount)
    SetFindIndicator(WebCore::FloatRect selectionRect, Vector<WebCore::FloatRect> textRects, float contentImageScaleFactor, WebKit::ShareableBitmap::Handle contentImageHandle, bool fadeOut, bool animate)
    DidFindString(String string, uint32_t matchCount)
    DidFailToFindString(String string)
    DidFindStringMatches(String string, Vector<Vector<WebCore::IntRect>> matches, int32_t firstIndexAfterSelection)
    DidGetImageForFindMatch(WebKit::ShareableBitmap::Handle contentImageHandle, uint32_t matchIndex)

    # PopupMenu messages
    ShowPopupMenu(WebCore::IntRect rect, uint64_t textDirection, Vector<WebKit::WebPopupItem> items, int32_t selectedIndex, WebKit::PlatformPopupMenuData data)
    HidePopupMenu()

#if ENABLE(CONTEXT_MENUS)
    # ContextMenu messages
    ShowContextMenu(WebCore::IntPoint menuLocation, WebKit::WebHitTestResult::Data hitTestResultData, Vector<WebKit::WebContextMenuItemData> items, WebKit::InjectedBundleUserMessageEncoder userData) Variadic
#endif

    # Authentication messages
    CanAuthenticateAgainstProtectionSpaceInFrame(uint64_t frameID, WebCore::ProtectionSpace protectionSpace) -> (bool canAuthenticate)
    DidReceiveAuthenticationChallenge(uint64_t frameID, WebCore::AuthenticationChallenge challenge, uint64_t challengeID)

    # Database messages
    ExceededDatabaseQuota(uint64_t frameID, String originIdentifier, String databaseName, String databaseDisplayName, uint64_t currentQuota, uint64_t currentOriginUsage, uint64_t currentDatabaseUsage, uint64_t expectedUsage) -> (uint64_t newQuota) Delayed

    # Geolocation messages
    RequestGeolocationPermissionForFrame(uint64_t geolocationID, uint64_t frameID, String originIdentifier)
    
    # Notification messages
    RequestNotificationPermission(uint64_t requestID, String originIdentifier)
    ShowNotification(String title, String body, String iconURL, String tag, String lang, String dir, String originIdentifier, uint64_t notificationID)
    CancelNotification(uint64_t notificationID)
    ClearNotifications(Vector<uint64_t> notificationIDs)
    DidDestroyNotification(uint64_t notificationID)

    # Spelling and grammar messages
#if USE(UNIFIED_TEXT_CHECKING)  
    CheckTextOfParagraph(String text, uint64_t checkingTypes) -> (Vector<WebCore::TextCheckingResult> results)
#endif
    CheckSpellingOfString(String text) -> (int32_t misspellingLocation, int32_t misspellingLength)
    CheckGrammarOfString(String text) -> (Vector<WebCore::GrammarDetail> results, int32_t badGrammarLocation, int32_t badGrammarLength)
    SpellingUIIsShowing() -> (bool isShowing)
    UpdateSpellingUIWithMisspelledWord(String misspelledWord)
    UpdateSpellingUIWithGrammarString(String badGrammarPhrase, WebCore::GrammarDetail grammarDetail)
    GetGuessesForWord(String word, String context) -> (Vector<String> guesses)
    LearnWord(String word);
    IgnoreWord(String word);
    RequestCheckingOfString(uint64_t requestID, WebCore::TextCheckingRequestData request)

    # Drag and drop messages
#if ENABLE(DRAG_SUPPORT)
    DidPerformDragControllerAction(WebCore::DragSession dragSession)
#endif
#if PLATFORM(MAC) && ENABLE(DRAG_SUPPORT)
    SetDragImage(WebCore::IntPoint clientPosition, WebKit::ShareableBitmap::Handle dragImage, bool linkDrag)
    SetPromisedData(String pasteboardName, WebKit::SharedMemory::Handle imageHandle, uint64_t imageSize, String filename, String extension, String title, String url, String visibleURL, WebKit::SharedMemory::Handle archiveHandle, uint64_t archiveSize)
#endif
#if PLATFORM(GTK) && ENABLE(DRAG_SUPPORT)
    StartDrag(WebCore::DragData dragData, WebKit::ShareableBitmap::Handle dragImage)
#endif

#if PLATFORM(MAC)
    # Dictionary support.
    DidPerformDictionaryLookup(WebKit::AttributedString text, WebKit::DictionaryPopupInfo dictionaryPopupInfo)

    # Keyboard input support messages
    InterpretQueuedKeyEvent(WebKit::EditorState state) -> (bool handled, Vector<WebCore::KeypressCommand> savedCommands)
    ExecuteSavedCommandBySelector(String selector) -> (bool handled)

    # Remote accessibility messages
    RegisterWebProcessAccessibilityToken(IPC::DataReference data)

    # Plug-in complex text input support messages
    PluginFocusOrWindowFocusChanged(uint64_t pluginComplexTextInputIdentifier, bool pluginHasFocusAndWindowHasFocus)
    SetPluginComplexTextInputState(uint64_t pluginComplexTextInputIdentifier, uint64_t complexTextInputState)

    # Speech messages
    GetIsSpeaking() -> (bool isSpeaking)
    Speak(String string)
    StopSpeaking()

    MakeFirstResponder()

    # Spotlight
    SearchWithSpotlight(String string)

    SearchTheWeb(String string)
#endif

#if USE(APPKIT)
    SubstitutionsPanelIsShowing() -> (bool isShowing)
#endif
#if !PLATFORM(IOS) && PLATFORM(MAC)
    # Autocorrection messages
    ShowCorrectionPanel(int32_t panelType, WebCore::FloatRect boundingBoxOfReplacedString, String replacedString, String replacementString, Vector<String> alternativeReplacementStrings)
    DismissCorrectionPanel(int32_t reason)
    DismissCorrectionPanelSoon(int32_t reason) -> (String result)
    RecordAutocorrectionResponse(int32_t responseType, String replacedString, String replacementString);
#endif

#if USE(DICTATION_ALTERNATIVES)
    ShowDictationAlternativeUI(WebCore::FloatRect boundingBoxOfDictatedText, uint64_t dictationContext)
    RemoveDictationAlternatives(uint64_t dictationContext)
    DictationAlternatives(uint64_t dictationContext) -> (Vector<String> alternatives)
#endif

#if PLUGIN_ARCHITECTURE(X11)
    # X11 windowed plugin messages
    CreatePluginContainer() -> (uint64_t windowID)
    WindowedPluginGeometryDidChange(WebCore::IntRect frameRect, WebCore::IntRect clipRect, uint64_t windowID)
    WindowedPluginVisibilityDidChange(bool isVisible, uint64_t windowID)
#endif

#if PLATFORM(IOS)
    MainDocumentDidReceiveMobileDocType();

    DidGetTapHighlightGeometries(uint64_t requestID, WebCore::Color color, Vector<WebCore::FloatQuad> geometries, WebCore::IntSize topLeftRadius, WebCore::IntSize topRightRadius, WebCore::IntSize bottomLeftRadius, WebCore::IntSize bottomRightRadius)
    DidChangeViewportArguments(WebCore::ViewportArguments viewportArguments)

    StartAssistingNode(WebCore::IntRect scrollRect, bool hasNextFocusable, bool hasPreviousFocusable)
    StopAssistingNode()
    NotifyRevealedSelection()
#endif

    # Search popup menus
    SaveRecentSearches(String name, Vector<String> searchItems)
    LoadRecentSearches(String name) -> (Vector<String> result)

#if USE(SOUP)
#if !ENABLE(CUSTOM_PROTOCOLS)
    # Soup custom URI request messages
    DidReceiveURIRequest(String uriString, uint64_t requestID);
#endif
#endif

    SavePDFToFileInDownloadsFolder(String suggestedFilename, String originatingURLString, IPC::DataReference data)

#if PLATFORM(MAC)
    SavePDFToTemporaryFolderAndOpenWithNativeApplication(String suggestedFilename, String originatingURLString, IPC::DataReference data, String pdfUUID)
    OpenPDFFromTemporaryFolderWithNativeApplication(String pdfUUID)
#endif

#if ENABLE(NETSCAPE_PLUGIN_API)
    FindPlugin(String mimeType, uint32_t processType, String urlString, String frameURLString, String pageURLString, bool allowOnlyApplicationPlugins) -> (uint64_t pluginProcessToken, String newMIMEType, uint32_t pluginLoadPolicy, String unavailabilityDescription)
#endif

    DidUpdateViewState()
    
    DidSaveToPageCache()
}
