Home | History | Annotate | Download | only in src
      1 /*
      2  * Copyright (C) 2009 Google Inc. All rights reserved.
      3  * Copyright (C) 2010 Nokia Corporation and/or its subsidiary(-ies).
      4  *
      5  * Redistribution and use in source and binary forms, with or without
      6  * modification, are permitted provided that the following conditions are
      7  * met:
      8  *
      9  *     * Redistributions of source code must retain the above copyright
     10  * notice, this list of conditions and the following disclaimer.
     11  *     * Redistributions in binary form must reproduce the above
     12  * copyright notice, this list of conditions and the following disclaimer
     13  * in the documentation and/or other materials provided with the
     14  * distribution.
     15  *     * Neither the name of Google Inc. nor the names of its
     16  * contributors may be used to endorse or promote products derived from
     17  * this software without specific prior written permission.
     18  *
     19  * THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS
     20  * "AS IS" AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT
     21  * LIMITED TO, THE IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR
     22  * A PARTICULAR PURPOSE ARE DISCLAIMED. IN NO EVENT SHALL THE COPYRIGHT
     23  * OWNER OR CONTRIBUTORS BE LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL,
     24  * SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT
     25  * LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; LOSS OF USE,
     26  * DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND ON ANY
     27  * THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT
     28  * (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE
     29  * OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE.
     30  */
     31 
     32 #ifndef ChromeClientImpl_h
     33 #define ChromeClientImpl_h
     34 
     35 #include "ChromeClientChromium.h"
     36 #include "PopupMenu.h"
     37 #include "SearchPopupMenu.h"
     38 
     39 namespace WebCore {
     40 class AccessibilityObject;
     41 class Element;
     42 class FileChooser;
     43 class PopupContainer;
     44 class PopupMenuClient;
     45 class RenderBox;
     46 class SecurityOrigin;
     47 struct WindowFeatures;
     48 }
     49 
     50 namespace WebKit {
     51 class WebViewImpl;
     52 struct WebCursorInfo;
     53 struct WebPopupMenuInfo;
     54 
     55 // Handles window-level notifications from WebCore on behalf of a WebView.
     56 class ChromeClientImpl : public WebCore::ChromeClientChromium {
     57 public:
     58     explicit ChromeClientImpl(WebViewImpl* webView);
     59     virtual ~ChromeClientImpl();
     60 
     61     virtual void* webView() const;
     62 
     63     // ChromeClient methods:
     64     virtual void chromeDestroyed();
     65     virtual void setWindowRect(const WebCore::FloatRect&);
     66     virtual WebCore::FloatRect windowRect();
     67     virtual WebCore::FloatRect pageRect();
     68     virtual float scaleFactor();
     69     virtual void focus();
     70     virtual void unfocus();
     71     virtual bool canTakeFocus(WebCore::FocusDirection);
     72     virtual void takeFocus(WebCore::FocusDirection);
     73     virtual void focusedNodeChanged(WebCore::Node*);
     74     virtual void focusedFrameChanged(WebCore::Frame*);
     75     virtual WebCore::Page* createWindow(
     76         WebCore::Frame*, const WebCore::FrameLoadRequest&, const WebCore::WindowFeatures&, const WebCore::NavigationAction&);
     77     virtual void show();
     78     virtual bool canRunModal();
     79     virtual void runModal();
     80     virtual void setToolbarsVisible(bool);
     81     virtual bool toolbarsVisible();
     82     virtual void setStatusbarVisible(bool);
     83     virtual bool statusbarVisible();
     84     virtual void setScrollbarsVisible(bool);
     85     virtual bool scrollbarsVisible();
     86     virtual void setMenubarVisible(bool);
     87     virtual bool menubarVisible();
     88     virtual void setResizable(bool);
     89     virtual void addMessageToConsole(
     90         WebCore::MessageSource, WebCore::MessageType, WebCore::MessageLevel,
     91         const WTF::String& message, unsigned lineNumber,
     92         const WTF::String& sourceID);
     93     virtual bool canRunBeforeUnloadConfirmPanel();
     94     virtual bool runBeforeUnloadConfirmPanel(
     95         const WTF::String& message, WebCore::Frame*);
     96     virtual void closeWindowSoon();
     97     virtual void runJavaScriptAlert(WebCore::Frame*, const WTF::String&);
     98     virtual bool runJavaScriptConfirm(WebCore::Frame*, const WTF::String&);
     99     virtual bool runJavaScriptPrompt(
    100         WebCore::Frame*, const WTF::String& message,
    101         const WTF::String& defaultValue, WTF::String& result);
    102     virtual void setStatusbarText(const WTF::String& message);
    103     virtual bool shouldInterruptJavaScript();
    104     virtual WebCore::KeyboardUIMode keyboardUIMode();
    105     virtual WebCore::IntRect windowResizerRect() const;
    106 #if ENABLE(REGISTER_PROTOCOL_HANDLER)
    107     virtual void registerProtocolHandler(const String& scheme, const String& baseURL, const String& url, const String& title);
    108 #endif
    109     virtual void invalidateWindow(const WebCore::IntRect&, bool);
    110     virtual void invalidateContentsAndWindow(const WebCore::IntRect&, bool);
    111     virtual void invalidateContentsForSlowScroll(const WebCore::IntRect&, bool);
    112 #if ENABLE(REQUEST_ANIMATION_FRAME)
    113     virtual void scheduleAnimation();
    114 #endif
    115     virtual void scroll(
    116         const WebCore::IntSize& scrollDelta, const WebCore::IntRect& rectToScroll,
    117         const WebCore::IntRect& clipRect);
    118     virtual WebCore::IntPoint screenToWindow(const WebCore::IntPoint&) const;
    119     virtual WebCore::IntRect windowToScreen(const WebCore::IntRect&) const;
    120     virtual PlatformPageClient platformPageClient() const { return 0; }
    121     virtual void contentsSizeChanged(WebCore::Frame*, const WebCore::IntSize&) const;
    122     virtual void scrollRectIntoView(
    123         const WebCore::IntRect&, const WebCore::ScrollView*) const { }
    124     virtual void scrollbarsModeDidChange() const;
    125     virtual void mouseDidMoveOverElement(
    126         const WebCore::HitTestResult& result, unsigned modifierFlags);
    127     virtual void setToolTip(const WTF::String& tooltipText, WebCore::TextDirection);
    128     virtual void print(WebCore::Frame*);
    129     virtual void exceededDatabaseQuota(
    130         WebCore::Frame*, const WTF::String& databaseName);
    131 #if ENABLE(OFFLINE_WEB_APPLICATIONS)
    132     virtual void reachedMaxAppCacheSize(int64_t spaceNeeded);
    133     virtual void reachedApplicationCacheOriginQuota(WebCore::SecurityOrigin*);
    134 #endif
    135 #if ENABLE(NOTIFICATIONS)
    136     virtual WebCore::NotificationPresenter* notificationPresenter() const;
    137 #endif
    138     virtual void requestGeolocationPermissionForFrame(WebCore::Frame*, WebCore::Geolocation*);
    139     virtual void cancelGeolocationPermissionRequestForFrame(WebCore::Frame*, WebCore::Geolocation*);
    140     virtual void runOpenPanel(WebCore::Frame*, PassRefPtr<WebCore::FileChooser>);
    141     virtual void chooseIconForFiles(const Vector<WTF::String>&, WebCore::FileChooser*);
    142 #if ENABLE(DIRECTORY_UPLOAD)
    143     virtual void enumerateChosenDirectory(const WTF::String&, WebCore::FileChooser*);
    144 #endif
    145     virtual void setCursor(const WebCore::Cursor&);
    146     virtual void formStateDidChange(const WebCore::Node*);
    147 #if ENABLE(TOUCH_EVENTS)
    148     // FIXME: All touch events are forwarded regardless of whether or not they are needed.
    149     virtual void needTouchEvents(bool needTouchEvents) { }
    150 #endif
    151 
    152 #if USE(ACCELERATED_COMPOSITING)
    153     // Pass 0 as the GraphicsLayer to detatch the root layer.
    154     virtual void attachRootGraphicsLayer(WebCore::Frame*, WebCore::GraphicsLayer*);
    155 
    156     // Sets a flag to specify that the next time content is drawn to the window,
    157     // the changes appear on the screen in synchrony with updates to GraphicsLayers.
    158     virtual void setNeedsOneShotDrawingSynchronization() { }
    159 
    160     // Sets a flag to specify that the view needs to be updated, so we need
    161     // to do an eager layout before the drawing.
    162     virtual void scheduleCompositingLayerSync();
    163 
    164     virtual CompositingTriggerFlags allowedCompositingTriggers() const;
    165 #endif
    166 
    167     virtual bool supportsFullscreenForNode(const WebCore::Node*);
    168     virtual void enterFullscreenForNode(WebCore::Node*);
    169     virtual void exitFullscreenForNode(WebCore::Node*);
    170 
    171 #if ENABLE(FULLSCREEN_API)
    172     virtual bool supportsFullScreenForElement(const WebCore::Element*, bool withKeyboard);
    173     virtual void enterFullScreenForElement(WebCore::Element*);
    174     virtual void exitFullScreenForElement(WebCore::Element*);
    175     virtual void fullScreenRendererChanged(WebCore::RenderBox*);
    176 #endif
    177 
    178     // ChromeClientChromium methods:
    179     virtual void popupOpened(WebCore::PopupContainer* popupContainer,
    180                              const WebCore::IntRect& bounds,
    181                              bool handleExternally);
    182     virtual void popupClosed(WebCore::PopupContainer* popupContainer);
    183     virtual void postAccessibilityNotification(WebCore::AccessibilityObject*, WebCore::AXObjectCache::AXNotification);
    184 
    185     // ChromeClientImpl:
    186     void setCursorForPlugin(const WebCursorInfo&);
    187 
    188     virtual bool selectItemWritingDirectionIsNatural();
    189     virtual bool selectItemAlignmentFollowsMenuWritingDirection();
    190     virtual PassRefPtr<WebCore::PopupMenu> createPopupMenu(WebCore::PopupMenuClient*) const;
    191     virtual PassRefPtr<WebCore::SearchPopupMenu> createSearchPopupMenu(WebCore::PopupMenuClient*) const;
    192 
    193 #if ENABLE(CONTEXT_MENUS)
    194     virtual void showContextMenu() { }
    195 #endif
    196 
    197     virtual void willRunModalDialogDuringPageDismissal(const DialogType&) const;
    198 
    199 private:
    200     void getPopupMenuInfo(WebCore::PopupContainer*, WebPopupMenuInfo*);
    201     void setCursor(const WebCursorInfo&);
    202 
    203     WebViewImpl* m_webView;  // weak pointer
    204     bool m_toolbarsVisible;
    205     bool m_statusbarVisible;
    206     bool m_scrollbarsVisible;
    207     bool m_menubarVisible;
    208     bool m_resizable;
    209 };
    210 
    211 } // namespace WebKit
    212 
    213 #endif
    214