| OLD | NEW |
| (Empty) |
| 1 /* | |
| 2 * Copyright (C) 2011, 2012 Google 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 are | |
| 6 * met: | |
| 7 * | |
| 8 * * Redistributions of source code must retain the above copyright | |
| 9 * notice, this list of conditions and the following disclaimer. | |
| 10 * * Redistributions in binary form must reproduce the above | |
| 11 * copyright notice, this list of conditions and the following disclaimer | |
| 12 * in the documentation and/or other materials provided with the | |
| 13 * distribution. | |
| 14 * * Neither the name of Google Inc. nor the names of its | |
| 15 * contributors may be used to endorse or promote products derived from | |
| 16 * this software without specific prior written permission. | |
| 17 * | |
| 18 * THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS | |
| 19 * "AS IS" AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT | |
| 20 * LIMITED TO, THE IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR | |
| 21 * A PARTICULAR PURPOSE ARE DISCLAIMED. IN NO EVENT SHALL THE COPYRIGHT | |
| 22 * OWNER OR CONTRIBUTORS BE LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL, | |
| 23 * SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT | |
| 24 * LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; LOSS OF USE, | |
| 25 * DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND ON ANY | |
| 26 * THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT | |
| 27 * (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE | |
| 28 * OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE. | |
| 29 */ | |
| 30 | |
| 31 #ifndef SKY_ENGINE_PUBLIC_WEB_WEBFRAMECLIENT_H_ | |
| 32 #define SKY_ENGINE_PUBLIC_WEB_WEBFRAMECLIENT_H_ | |
| 33 | |
| 34 #include "../platform/WebColor.h" | |
| 35 #include "sky/engine/public/platform/WebCommon.h" | |
| 36 #include "sky/engine/public/platform/WebURLError.h" | |
| 37 #include "sky/engine/public/platform/WebURLRequest.h" | |
| 38 #include "sky/engine/public/web/WebFrame.h" | |
| 39 #include "sky/engine/public/web/WebNavigationPolicy.h" | |
| 40 #include "sky/engine/public/web/WebNavigationType.h" | |
| 41 #include "sky/engine/public/web/WebTextDirection.h" | |
| 42 | |
| 43 typedef struct _Dart_Isolate* Dart_Isolate; | |
| 44 | |
| 45 namespace mojo { | |
| 46 class View; | |
| 47 } | |
| 48 | |
| 49 namespace blink { | |
| 50 | |
| 51 class WebCachedURLRequest; | |
| 52 class WebInputEvent; | |
| 53 class WebNode; | |
| 54 class WebString; | |
| 55 class WebURL; | |
| 56 class WebURLLoader; | |
| 57 class WebURLResponse; | |
| 58 struct WebConsoleMessage; | |
| 59 struct WebRect; | |
| 60 struct WebSize; | |
| 61 struct WebURLError; | |
| 62 | |
| 63 class WebFrameClient { | |
| 64 public: | |
| 65 // General notifications ----------------------------------------------- | |
| 66 | |
| 67 // A child frame was created in this frame. This is called when the frame | |
| 68 // is created and initialized. Takes the name of the new frame, the parent | |
| 69 // frame and returns a new WebFrame. The WebFrame is considered in-use | |
| 70 // until frameDetached() is called on it. | |
| 71 // Note: If you override this, you should almost certainly be overriding | |
| 72 // frameDetached(). | |
| 73 virtual mojo::View* createChildFrame() { return nullptr; } | |
| 74 | |
| 75 // This frame has been detached from the view, but has not been closed yet. | |
| 76 // TODO(mpcomplete): reuse these. | |
| 77 virtual void frameDetached(WebFrame*) { } | |
| 78 | |
| 79 // This frame has become focused.. | |
| 80 virtual void frameFocused() { } | |
| 81 | |
| 82 // This frame is about to be closed. This is called after frameDetached, | |
| 83 // when the document is being unloaded, due to new one committing. | |
| 84 virtual void willClose(WebFrame*) { } | |
| 85 | |
| 86 // FIXME(sky): remove. | |
| 87 // Called when a watched CSS selector matches or stops matching. | |
| 88 virtual void didMatchCSS(WebLocalFrame*, const WebVector<WebString>& newlyMa
tchingSelectors, const WebVector<WebString>& stoppedMatchingSelectors) { } | |
| 89 | |
| 90 virtual void didCreateIsolate(WebLocalFrame*, Dart_Isolate isolate) {} | |
| 91 | |
| 92 // Console messages ---------------------------------------------------- | |
| 93 | |
| 94 // Whether or not we should report a detailed message for the given source. | |
| 95 virtual bool shouldReportDetailedMessageForSource(const WebString& source) {
return false; } | |
| 96 | |
| 97 // A new message was added to the console. | |
| 98 virtual void didAddMessageToConsole(const WebConsoleMessage&, const WebStrin
g& sourceName, unsigned sourceLine, const WebString& stackTrace) { } | |
| 99 | |
| 100 | |
| 101 // Load commands ------------------------------------------------------- | |
| 102 | |
| 103 // The client should handle the navigation externally. | |
| 104 virtual void loadURLExternally( | |
| 105 WebLocalFrame*, const WebURLRequest&, WebNavigationPolicy, const WebStri
ng& downloadName) { } | |
| 106 | |
| 107 | |
| 108 // Navigational queries ------------------------------------------------ | |
| 109 | |
| 110 // The client may choose to alter the navigation policy. Otherwise, | |
| 111 // defaultPolicy should just be returned. | |
| 112 | |
| 113 struct NavigationPolicyInfo { | |
| 114 WebLocalFrame* frame; | |
| 115 const WebURLRequest& urlRequest; | |
| 116 WebNavigationType navigationType; | |
| 117 WebNavigationPolicy defaultPolicy; | |
| 118 bool isTransitionNavigation; | |
| 119 | |
| 120 NavigationPolicyInfo(const WebURLRequest& urlRequest) | |
| 121 : frame(0) | |
| 122 , urlRequest(urlRequest) | |
| 123 , navigationType(WebNavigationTypeOther) | |
| 124 , defaultPolicy(WebNavigationPolicyIgnore) | |
| 125 , isTransitionNavigation(false) { } | |
| 126 }; | |
| 127 | |
| 128 virtual WebNavigationPolicy decidePolicyForNavigation(const NavigationPolicy
Info& info) | |
| 129 { | |
| 130 return info.defaultPolicy; | |
| 131 } | |
| 132 | |
| 133 | |
| 134 // Navigational notifications ------------------------------------------ | |
| 135 | |
| 136 // These notifications bracket any loading that occurs in the WebFrame. | |
| 137 virtual void didStartLoading(bool toDifferentDocument) { } | |
| 138 virtual void didStopLoading() { } | |
| 139 | |
| 140 // Notification that some progress was made loading the current frame. | |
| 141 // loadProgress is a value between 0 (nothing loaded) and 1.0 (frame fully | |
| 142 // loaded). | |
| 143 virtual void didChangeLoadProgress(double loadProgress) { } | |
| 144 | |
| 145 // The document element has been created. | |
| 146 virtual void didCreateDocumentElement(WebLocalFrame*) { } | |
| 147 | |
| 148 // The page title is available. | |
| 149 virtual void didReceiveTitle(WebLocalFrame* frame, const WebString& title, W
ebTextDirection direction) { } | |
| 150 | |
| 151 // The 'load' event was dispatched. | |
| 152 virtual void didHandleOnloadEvents(WebLocalFrame*) { } | |
| 153 | |
| 154 // The frame's document or one of its subresources failed to load. | |
| 155 virtual void didFailLoad(WebLocalFrame*, const WebURLError&) { } | |
| 156 | |
| 157 // The frame's manifest has changed. | |
| 158 virtual void didChangeManifest(WebLocalFrame*) { } | |
| 159 | |
| 160 | |
| 161 // Transition navigations ----------------------------------------------- | |
| 162 | |
| 163 // Provides serialized markup of transition elements for use in the followin
g navigation. | |
| 164 virtual void addNavigationTransitionData(const WebString& allowedDestination
Origin, const WebString& selector, const WebString& markup) { } | |
| 165 | |
| 166 // Editing ------------------------------------------------------------- | |
| 167 | |
| 168 // These methods allow the client to intercept and overrule editing | |
| 169 // operations. | |
| 170 virtual void didChangeSelection(bool isSelectionEmpty) { } | |
| 171 | |
| 172 // Low-level resource notifications ------------------------------------ | |
| 173 | |
| 174 // An element will request a resource. | |
| 175 virtual void willRequestResource(WebLocalFrame*, const WebCachedURLRequest&)
{ } | |
| 176 | |
| 177 // A request is about to be sent out, and the client may modify it. Request | |
| 178 // is writable, and changes to the URL, for example, will change the request | |
| 179 // made. If this request is the result of a redirect, then redirectResponse | |
| 180 // will be non-null and contain the response that triggered the redirect. | |
| 181 virtual void willSendRequest( | |
| 182 WebLocalFrame*, unsigned identifier, WebURLRequest&, | |
| 183 const WebURLResponse& redirectResponse) { } | |
| 184 | |
| 185 // Response headers have been received for the resource request given | |
| 186 // by identifier. | |
| 187 virtual void didReceiveResponse( | |
| 188 WebLocalFrame*, unsigned identifier, const WebURLResponse&) { } | |
| 189 | |
| 190 virtual void didChangeResourcePriority( | |
| 191 WebLocalFrame* webFrame, unsigned identifier, const WebURLRequest::Prior
ity& priority, int) { } | |
| 192 | |
| 193 // The resource request given by identifier succeeded. | |
| 194 virtual void didFinishResourceLoad( | |
| 195 WebLocalFrame*, unsigned identifier) { } | |
| 196 | |
| 197 // The specified request was satified from WebCore's memory cache. | |
| 198 virtual void didLoadResourceFromMemoryCache( | |
| 199 WebLocalFrame*, const WebURLRequest&, const WebURLResponse&) { } | |
| 200 | |
| 201 | |
| 202 // Geometry notifications ---------------------------------------------- | |
| 203 | |
| 204 // The main frame scrolled. | |
| 205 virtual void didChangeScrollOffset(WebLocalFrame*) { } | |
| 206 | |
| 207 | |
| 208 // Find-in-page notifications ------------------------------------------ | |
| 209 | |
| 210 // Notifies how many matches have been found so far, for a given | |
| 211 // identifier. |finalUpdate| specifies whether this is the last update | |
| 212 // (all frames have completed scoping). | |
| 213 virtual void reportFindInPageMatchCount( | |
| 214 int identifier, int count, bool finalUpdate) { } | |
| 215 | |
| 216 // Notifies what tick-mark rect is currently selected. The given | |
| 217 // identifier lets the client know which request this message belongs | |
| 218 // to, so that it can choose to ignore the message if it has moved on | |
| 219 // to other things. The selection rect is expected to have coordinates | |
| 220 // relative to the top left corner of the web page area and represent | |
| 221 // where on the screen the selection rect is currently located. | |
| 222 virtual void reportFindInPageSelection( | |
| 223 int identifier, int activeMatchOrdinal, const WebRect& selection) { } | |
| 224 | |
| 225 | |
| 226 // WebGL ------------------------------------------------------ | |
| 227 | |
| 228 // Notifies the client that a WebGL context was lost on this page with the | |
| 229 // given reason (one of the GL_ARB_robustness status codes; see | |
| 230 // Extensions3D.h in WebCore/platform/graphics). | |
| 231 virtual void didLoseWebGLContext(WebLocalFrame*, int) { } | |
| 232 | |
| 233 protected: | |
| 234 virtual ~WebFrameClient() { } | |
| 235 }; | |
| 236 | |
| 237 } // namespace blink | |
| 238 | |
| 239 #endif // SKY_ENGINE_PUBLIC_WEB_WEBFRAMECLIENT_H_ | |
| OLD | NEW |