WebPageClient.h 15 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137138139140141142143144145146147148149150151152153154155156157158159160161162163164165166167168169170171172173174175176177178179180181182183184185186187188189190191192193194195196197198199200201202203204205206207208209210211212213214215216217218219220221222223224225226227228229230231232233234235236237238239240241242243244245246247248249250251252253254255256257258259260261262263264265266267268269270271272273274275276277278279280281282283284285
  1. /*
  2. * Copyright (C) 2009, 2010, 2011, 2012 Research In Motion Limited. All rights reserved.
  3. *
  4. * This library is free software; you can redistribute it and/or
  5. * modify it under the terms of the GNU Lesser General Public
  6. * License as published by the Free Software Foundation; either
  7. * version 2 of the License, or (at your option) any later version.
  8. *
  9. * This library is distributed in the hope that it will be useful,
  10. * but WITHOUT ANY WARRANTY; without even the implied warranty of
  11. * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU
  12. * Lesser General Public License for more details.
  13. *
  14. * You should have received a copy of the GNU Lesser General Public
  15. * License along with this library; if not, write to the Free Software
  16. * Foundation, Inc., 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301 USA
  17. */
  18. #ifndef WebPageClient_h
  19. #define WebPageClient_h
  20. #include "BlackBerryGlobal.h"
  21. #include <BlackBerryPlatformCursor.h>
  22. #include <BlackBerryPlatformInputEvents.h>
  23. #include <BlackBerryPlatformNavigationType.h>
  24. #include <BlackBerryPlatformPrimitives.h>
  25. #include <BlackBerryPlatformString.h>
  26. #include <imf/events.h>
  27. #include <interaction/ScrollViewBase.h>
  28. #include <vector>
  29. template<typename T> class ScopeArray;
  30. template<typename T> class SharedArray;
  31. typedef void* WebFrame;
  32. namespace BlackBerry {
  33. namespace Platform {
  34. class FilterStream;
  35. class GeoTrackerListener;
  36. class IntRectRegion;
  37. class NetworkRequest;
  38. class NetworkStreamFactory;
  39. struct SelectionDetails;
  40. class ViewportAccessor;
  41. class WebUserMediaRequest;
  42. namespace Graphics {
  43. class Window;
  44. }
  45. }
  46. namespace WebKit {
  47. class WebPage;
  48. class BLACKBERRY_EXPORT WebPageClient {
  49. public:
  50. virtual ~WebPageClient() { }
  51. enum WindowStyleFlag {
  52. FlagWindowHasMenuBar = 0x00000001,
  53. FlagWindowHasToolBar = 0x00000002,
  54. FlagWindowHasLocationBar = 0x00000004,
  55. FlagWindowHasStatusBar = 0x00000008,
  56. FlagWindowHasScrollBar = 0x00000010,
  57. FlagWindowIsResizable = 0x00000020,
  58. FlagWindowIsFullScreen = 0x00000040,
  59. FlagWindowIsDialog = 0x00000080,
  60. FlagWindowDefault = 0xFFFFFFFF,
  61. };
  62. enum AlertType {
  63. MediaOK = 0,
  64. MediaDecodeError,
  65. MediaMetaDataError,
  66. MediaMetaDataTimeoutError,
  67. MediaNoMetaDataError,
  68. MediaVideoReceiveError,
  69. MediaAudioReceiveError,
  70. MediaInvalidError,
  71. };
  72. enum SaveCredentialType {
  73. SaveCredentialNeverForThisSite = 0,
  74. SaveCredentialNotNow,
  75. SaveCredentialYes
  76. };
  77. virtual int getInstanceId() const = 0;
  78. virtual void notifyLoadStarted() = 0;
  79. virtual void notifyLoadCommitted(const unsigned short* originalUrl, unsigned originalUrlLength, const unsigned short* finalUrl, unsigned finalUrlLength, const unsigned short* networkToken, unsigned networkTokenLength) = 0;
  80. virtual void notifyLoadFailedBeforeCommit(const unsigned short* originalUrl, unsigned originalUrlLength, const unsigned short* finalUrl, unsigned finalUrlLength, const unsigned short* networkToken, unsigned networkTokenLength) = 0;
  81. virtual void notifyLoadToAnchor(const unsigned short* url, unsigned urlLength, const unsigned short* networkToken, unsigned networkTokenLength) = 0;
  82. virtual void notifyLoadProgress(int percentage) = 0;
  83. virtual void notifyLoadReadyToRender(bool pageIsVisuallyNonEmpty) = 0;
  84. virtual void notifyFirstVisuallyNonEmptyLayout() = 0;
  85. virtual void notifyLoadFinished(int status) = 0;
  86. virtual void notifyClientRedirect(const unsigned short* originalUrl, unsigned originalUrlLength, const unsigned short* finalUrl, unsigned finalUrlLength) = 0;
  87. virtual void notifyFrameDetached(const WebFrame) = 0;
  88. virtual void notifyRunLayoutTestsFinished() = 0;
  89. virtual void notifyInRegionScrollableAreasChanged(const std::vector<Platform::ScrollViewBase*>&) = 0;
  90. virtual void notifyDocumentOnLoad(bool) = 0;
  91. virtual void notifyWindowObjectCleared() = 0;
  92. virtual void addMessageToConsole(const unsigned short* message, unsigned messageLength, const unsigned short* source, unsigned sourceLength, unsigned lineNumber, unsigned columnNumber) = 0;
  93. virtual int showAlertDialog(AlertType) = 0;
  94. virtual BlackBerry::Platform::String serializePageCacheState() const = 0;
  95. virtual void deserializePageCacheState(const BlackBerry::Platform::String& state) = 0;
  96. virtual void runJavaScriptAlert(const unsigned short* message, unsigned messageLength, const char* origin, unsigned originLength) = 0;
  97. virtual bool runJavaScriptConfirm(const unsigned short* message, unsigned messageLength, const char* origin, unsigned originLength) = 0;
  98. virtual bool runJavaScriptPrompt(const unsigned short* message, unsigned messageLength, const unsigned short* defaultValue, unsigned defaultValueLength, const char* origin, unsigned originLength, BlackBerry::Platform::String& result) = 0;
  99. virtual bool runBeforeUnloadConfirmPanel(const unsigned short* message, unsigned messageLength, const char* origin, unsigned originLength) = 0;
  100. virtual bool shouldInterruptJavaScript() = 0;
  101. virtual void contentsSizeChanged() = 0;
  102. virtual void scrollChanged() = 0;
  103. virtual void scaleChanged() = 0;
  104. virtual void updateInteractionViews() = 0;
  105. virtual void requestUpdateViewport(int width, int height) = 0;
  106. virtual void setPageTitle(const unsigned short* title, unsigned titleLength) = 0;
  107. virtual Platform::Graphics::Window* window() const = 0;
  108. virtual void postToSurface(const Platform::IntRect&) = 0;
  109. virtual void notifyPixelContentRendered(const Platform::IntRect&) = 0;
  110. virtual void inputFocusGained(int64_t inputStyle, Platform::VirtualKeyboardType, Platform::VirtualKeyboardEnterKeyType) = 0;
  111. virtual void inputFocusLost() = 0;
  112. virtual void inputTextChanged() = 0;
  113. virtual void inputSelectionChanged(unsigned selectionStart, unsigned selectionEnd) = 0;
  114. virtual void inputLearnText(wchar_t* text, int length) = 0;
  115. virtual void showFormControls(bool visible, bool previousActive = false, bool nextActive = false) = 0;
  116. virtual void showVirtualKeyboard(bool) = 0;
  117. virtual void requestSpellingCheckingOptions(imf_sp_text_t&, const BlackBerry::Platform::IntRect& documentCaretRect, const BlackBerry::Platform::IntSize& screenOffset, const bool shouldMoveDialog) = 0;
  118. virtual int32_t checkSpellingOfStringAsync(wchar_t* text, const unsigned length) = 0;
  119. virtual void notifySelectionDetailsChanged(const BlackBerry::Platform::SelectionDetails&) = 0;
  120. virtual void cancelSelectionVisuals() = 0;
  121. virtual void notifySelectionHandlesReversed() = 0;
  122. virtual void notifyCaretChanged(const Platform::IntRect& documentCaretRect, bool userTouchTriggered, bool isSingleLineInput = false, const Platform::IntRect& singleLineDocumentBoundingBox = Platform::IntRect(), bool textFieldIsEmpty = false) = 0;
  123. virtual void notifySelectionScrollView(Platform::ScrollViewBase*) = 0;
  124. virtual void cursorChanged(Platform::CursorType, const char* url, const Platform::IntPoint& hotSpotInImage) = 0;
  125. virtual void requestGlobalLocalServicePermission(Platform::GeoTrackerListener*, const BlackBerry::Platform::String& origin) = 0;
  126. virtual void requestGeolocationPermission(Platform::GeoTrackerListener*, const BlackBerry::Platform::String& origin) = 0;
  127. virtual void cancelGeolocationPermission() = 0;
  128. virtual Platform::NetworkStreamFactory* networkStreamFactory() = 0;
  129. virtual void handleStringPattern(const unsigned short* pattern, unsigned length) = 0;
  130. virtual void handleExternalLink(const Platform::NetworkRequest&, const unsigned short* context, unsigned contextLength, bool isClientRedirect) = 0;
  131. virtual void resetBackForwardList(unsigned listSize, unsigned currentIndex) = 0;
  132. virtual void openPopupList(bool multiple, int size, const ScopeArray<BlackBerry::Platform::String>& labels, const bool* enableds, const int* itemType, const bool* selecteds) = 0;
  133. virtual bool chooseFilenames(bool allowMultiple, const SharedArray<BlackBerry::Platform::String>& acceptTypes, const SharedArray<BlackBerry::Platform::String>& initialFiles, const BlackBerry::Platform::String& capture, SharedArray<BlackBerry::Platform::String>& chosenFiles) = 0;
  134. virtual WebPage* createWindow(int x, int y, int width, int height, unsigned flags, const BlackBerry::Platform::String& url, const BlackBerry::Platform::String& windowName, const BlackBerry::Platform::String& openerFrameUrl, bool userGesture) = 0;
  135. virtual void scheduleCloseWindow() = 0;
  136. // Database interface.
  137. virtual unsigned long long databaseQuota(const BlackBerry::Platform::String& origin, const BlackBerry::Platform::String& databaseName, unsigned long long originUsage, unsigned long long currentQuota, unsigned long long estimatedSize) = 0;
  138. virtual void setIconForUrl(const BlackBerry::Platform::String& originalPageUrl, const BlackBerry::Platform::String& finalPageUrl, const BlackBerry::Platform::String& iconUrl) = 0;
  139. virtual void setFavicon(const BlackBerry::Platform::String& dataInBase64, const BlackBerry::Platform::String& url) = 0;
  140. virtual void setLargeIcon(const BlackBerry::Platform::String& iconUrl) = 0;
  141. virtual void setWebAppCapable() = 0;
  142. virtual void setSearchProviderDetails(const BlackBerry::Platform::String& title, const BlackBerry::Platform::String& documentUrl) = 0;
  143. virtual void setAlternateFeedDetails(const BlackBerry::Platform::String& title, const BlackBerry::Platform::String& feedUrl) = 0;
  144. virtual BlackBerry::Platform::String getErrorPage(int errorCode, const BlackBerry::Platform::String& errorMessage, const BlackBerry::Platform::String& url) = 0;
  145. virtual void willDeferLoading() = 0;
  146. virtual void didResumeLoading() = 0;
  147. // Headers is a list of alternating key and value.
  148. virtual void setMetaHeaders(const ScopeArray<BlackBerry::Platform::String>& headers, unsigned headersSize) = 0;
  149. virtual void needMoreData() = 0;
  150. virtual void handleWebInspectorMessageToFrontend(int id, const char* message, int length) = 0;
  151. virtual BlackBerry::Platform::ViewportAccessor* userInterfaceViewportAccessor() const = 0;
  152. virtual void animateToScaleAndDocumentScrollPosition(double finalScale, const Platform::FloatPoint& finalDocumentScrollPosition, bool shouldConstrainScrollingToContentEdge) = 0;
  153. virtual void setPreventsScreenIdleDimming(bool noDimming) = 0;
  154. virtual bool authenticationChallenge(const unsigned short* realm, unsigned realmLength, BlackBerry::Platform::String& username, BlackBerry::Platform::String& password, BlackBerry::Platform::String& requestURL, bool isProxy) = 0;
  155. virtual SaveCredentialType notifyShouldSaveCredential(bool isNew) = 0;
  156. virtual void syncProxyCredential(const BlackBerry::Platform::String& username, const BlackBerry::Platform::String& password) = 0;
  157. virtual void notifyPopupAutofillDialog(const std::vector<BlackBerry::Platform::String>&) = 0;
  158. virtual void notifyDismissAutofillDialog() = 0;
  159. virtual bool shouldPluginEnterFullScreen() = 0;
  160. virtual void didPluginEnterFullScreen() = 0;
  161. virtual void didPluginExitFullScreen() = 0;
  162. virtual void onPluginStartBackgroundPlay() = 0;
  163. virtual void onPluginStopBackgroundPlay() = 0;
  164. virtual bool lockOrientation(bool landscape) = 0;
  165. virtual void unlockOrientation() = 0;
  166. virtual bool isActive() const = 0;
  167. virtual bool isVisible() const = 0;
  168. virtual void setToolTip(const BlackBerry::Platform::String&) = 0;
  169. virtual void setStatus(const BlackBerry::Platform::String&) = 0;
  170. virtual bool acceptNavigationRequest(const Platform::NetworkRequest&, Platform::NavigationType) = 0;
  171. virtual void cursorEventModeChanged(Platform::CursorEventMode) = 0;
  172. virtual void touchEventModeChanged(Platform::TouchEventMode) = 0;
  173. virtual bool downloadAllowed(const BlackBerry::Platform::String& url) = 0;
  174. virtual void downloadRequested(Platform::FilterStream*, const BlackBerry::Platform::String& suggestedFilename) = 0;
  175. virtual int fullscreenStart() = 0;
  176. virtual int fullscreenStart(const char* contextName, Platform::Graphics::Window*, const BlackBerry::Platform::IntRect& windowScreenRect) = 0;
  177. virtual int fullscreenStop() = 0;
  178. virtual int fullscreenSetWindowRect(const BlackBerry::Platform::IntRect& newWindowScreenRect) = 0;
  179. virtual void populateCustomHeaders(Platform::NetworkRequest&) = 0;
  180. virtual void notifyWillUpdateApplicationCache() = 0;
  181. virtual void notifyDidLoadFromApplicationCache() = 0;
  182. virtual void clearCookies() = 0;
  183. virtual void clearCache() = 0;
  184. virtual bool hasKeyboardFocus() = 0;
  185. virtual bool createPopupWebView(const Platform::IntRect&) = 0;
  186. virtual void closePopupWebView() = 0;
  187. virtual void addSearchProvider(const Platform::String&) = 0;
  188. virtual int isSearchProviderInstalled(const Platform::String&) = 0;
  189. // Match with ChromeClient::CustomHandlersState.
  190. enum ProtocolHandlersState {
  191. ProtocolHandlersNew,
  192. ProtocolHandlersRegistered,
  193. ProtocolHandlersDeclined
  194. };
  195. virtual void registerProtocolHandler(const BlackBerry::Platform::String& /*scheme*/, const BlackBerry::Platform::String& /*baseURL*/, const BlackBerry::Platform::String& /*url*/, const BlackBerry::Platform::String& /*title*/) = 0;
  196. virtual ProtocolHandlersState isProtocolHandlerRegistered(const BlackBerry::Platform::String& /*scheme*/, const BlackBerry::Platform::String& /*baseURL*/, const BlackBerry::Platform::String& /*url*/) = 0;
  197. virtual void unregisterProtocolHandler(const BlackBerry::Platform::String& /*scheme*/, const BlackBerry::Platform::String& /*baseURL*/, const BlackBerry::Platform::String& /*url*/) = 0;
  198. virtual void requestUserMedia(const Platform::WebUserMediaRequest&) = 0;
  199. virtual void cancelUserMediaRequest(const Platform::WebUserMediaRequest&) = 0;
  200. virtual void updateFindStringResult(int numMatches, int currentIndex) = 0;
  201. // Match with NotificationClient::Permission.
  202. enum Permission {
  203. PermissionAllowed, // User has allowed notifications
  204. PermissionNotAllowed, // User has not yet allowed
  205. PermissionDenied // User has explicitly denied permission
  206. };
  207. virtual void requestNotificationPermission(const BlackBerry::Platform::String& /*requestId*/, const BlackBerry::Platform::String& /*origin*/) = 0;
  208. virtual Permission checkNotificationPermission(const BlackBerry::Platform::String& /*origin*/) = 0;
  209. virtual void showNotification(const BlackBerry::Platform::String& /*notificationId*/, const BlackBerry::Platform::String& /*title*/, const BlackBerry::Platform::String& /*body*/, const BlackBerry::Platform::String& /*iconUrl*/, const BlackBerry::Platform::String& /*tag*/, const BlackBerry::Platform::String& /*origin*/) = 0;
  210. virtual void cancelNotification(const BlackBerry::Platform::String& /*id*/) = 0;
  211. virtual void clearNotifications(const std::vector<BlackBerry::Platform::String>& /*notificationIds*/) = 0;
  212. virtual void notificationDestroyed(const BlackBerry::Platform::String& /*notificationId*/) = 0;
  213. virtual void startSelectionScroll() = 0;
  214. virtual void stopExpandingSelection() = 0;
  215. virtual void suppressCaretChangeNotification(bool shouldClearState) = 0;
  216. };
  217. } // namespace WebKit
  218. } // namespace BlackBerry
  219. #endif // WebPageClient_h