Chromium Code Reviews
chromiumcodereview-hr@appspot.gserviceaccount.com (chromiumcodereview-hr) | Please choose your nickname with Settings | Help | Chromium Project | Gerrit Changes | Sign out
(81)

Side by Side Diff: webkit/glue/webframe_impl.h

Issue 164225: Switch to WebFrame from the WebKit API.... (Closed) Base URL: svn://svn.chromium.org/chrome/trunk/src/
Patch Set: '' Created 11 years, 4 months ago
Use n/p to move between diff chunks; N/P to move between comments. Draft comments are only viewable by you.
Jump to:
View unified diff | Download patch | Annotate | Revision Log
« no previous file with comments | « webkit/glue/webframe.h ('k') | webkit/glue/webframe_impl.cc » ('j') | no next file with comments »
Toggle Intra-line Diffs ('i') | Expand Comments ('e') | Collapse Comments ('c') | Show Comments Hide Comments ('s')
OLDNEW
1 /* 1 /*
2 * Copyright (C) 2006 Apple Computer, Inc. All rights reserved. 2 * Copyright (C) 2006 Apple Computer, Inc. All rights reserved.
3 * 3 *
4 * Redistribution and use in source and binary forms, with or without 4 * Redistribution and use in source and binary forms, with or without
5 * modification, are permitted provided that the following conditions 5 * modification, are permitted provided that the following conditions
6 * are met: 6 * are met:
7 * 1. Redistributions of source code must retain the above copyright 7 * 1. Redistributions of source code must retain the above copyright
8 * notice, this list of conditions and the following disclaimer. 8 * notice, this list of conditions and the following disclaimer.
9 * 2. Redistributions in binary form must reproduce the above copyright 9 * 2. Redistributions in binary form must reproduce the above copyright
10 * notice, this list of conditions and the following disclaimer in the 10 * notice, this list of conditions and the following disclaimer in the
(...skipping 11 matching lines...) Expand all
22 * (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE 22 * (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE
23 * OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE. 23 * OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE.
24 */ 24 */
25 25
26 #ifndef WEBKIT_GLUE_WEBFRAME_IMPL_H_ 26 #ifndef WEBKIT_GLUE_WEBFRAME_IMPL_H_
27 #define WEBKIT_GLUE_WEBFRAME_IMPL_H_ 27 #define WEBKIT_GLUE_WEBFRAME_IMPL_H_
28 28
29 #include "base/scoped_ptr.h" 29 #include "base/scoped_ptr.h"
30 #include "base/task.h" 30 #include "base/task.h"
31 #include "skia/ext/platform_canvas.h" 31 #include "skia/ext/platform_canvas.h"
32 #include "webkit/api/public/WebFrame.h"
32 #include "webkit/glue/password_autocomplete_listener.h" 33 #include "webkit/glue/password_autocomplete_listener.h"
33 #include "webkit/glue/webframe.h"
34 #include "webkit/glue/webframeloaderclient_impl.h" 34 #include "webkit/glue/webframeloaderclient_impl.h"
35 35
36 MSVC_PUSH_WARNING_LEVEL(0); 36 MSVC_PUSH_WARNING_LEVEL(0);
37 #include "ResourceHandleClient.h" 37 #include "ResourceHandleClient.h"
38 #include "Frame.h" 38 #include "Frame.h"
39 #include "PlatformString.h" 39 #include "PlatformString.h"
40 MSVC_POP_WARNING(); 40 MSVC_POP_WARNING();
41 41
42 class ChromePrintContext; 42 class ChromePrintContext;
43 class WebDataSourceImpl; 43 class WebDataSourceImpl;
44 class WebPluginDelegate; 44 class WebPluginDelegate;
45 class WebView; 45 class WebView;
46 class WebViewImpl; 46 class WebViewImpl;
47 class WebTextInput;
48 class WebTextInputImpl;
49 47
50 namespace gfx { 48 namespace gfx {
51 class BitmapPlatformDevice; 49 class BitmapPlatformDevice;
52 } 50 }
53 51
54 namespace WebCore { 52 namespace WebCore {
55 class Frame; 53 class Frame;
56 class FrameView; 54 class FrameView;
57 class HistoryItem; 55 class HistoryItem;
58 class KURL; 56 class KURL;
59 class Node; 57 class Node;
60 class Range; 58 class Range;
61 class SubstituteData; 59 class SubstituteData;
62 struct WindowFeatures; 60 struct WindowFeatures;
63 } 61 }
64 62
65 // Implementation of WebFrame, note that this is a reference counted object. 63 // Implementation of WebFrame, note that this is a reference counted object.
66 class WebFrameImpl : public WebFrame, public base::RefCounted<WebFrameImpl> { 64 class WebFrameImpl : public WebKit::WebFrame,
65 public base::RefCounted<WebFrameImpl> {
67 public: 66 public:
68 WebFrameImpl(); 67 WebFrameImpl();
69 ~WebFrameImpl(); 68 ~WebFrameImpl();
70 69
71 static int live_object_count() { 70 static int live_object_count() {
72 return live_object_count_; 71 return live_object_count_;
73 } 72 }
74 73
75 // Called by the WebViewImpl to initialize its main frame: 74 // Called by the WebViewImpl to initialize its main frame:
76 void InitMainFrame(WebViewImpl* webview_impl); 75 void InitMainFrame(WebViewImpl* webview_impl);
77 76
78 // WebFrame 77 // WebFrame methods:
79 virtual void Reload(); 78 virtual WebKit::WebString name() const;
80 virtual void LoadRequest(const WebKit::WebURLRequest& request); 79 virtual WebKit::WebURL url() const;
81 virtual void LoadHistoryItem(const WebKit::WebHistoryItem& item); 80 virtual WebKit::WebURL favIconURL() const;
82 virtual void LoadData( 81 virtual WebKit::WebURL openSearchDescriptionURL() const;
83 const WebKit::WebData& data, 82 virtual WebKit::WebSize scrollOffset() const;
84 const WebKit::WebString& mime_type, 83 virtual WebKit::WebSize contentsSize() const;
85 const WebKit::WebString& text_encoding, 84 virtual int contentsPreferredWidth() const;
86 const WebKit::WebURL& base_url, 85 virtual bool hasVisibleContent() const;
87 const WebKit::WebURL& unreachable_url = WebKit::WebURL(), 86 virtual WebView* view() const;
88 bool replace = false); 87 virtual WebKit::WebFrame* opener() const;
89 virtual void LoadHTMLString( 88 virtual WebKit::WebFrame* parent() const;
90 const WebKit::WebData& data, 89 virtual WebKit::WebFrame* top() const;
91 const WebKit::WebURL& base_url, 90 virtual WebKit::WebFrame* firstChild() const;
92 const WebKit::WebURL& unreachable_url = WebKit::WebURL(), 91 virtual WebKit::WebFrame* lastChild() const;
93 bool replace = false); 92 virtual WebKit::WebFrame* nextSibling() const;
94 virtual void DispatchWillSendRequest(WebKit::WebURLRequest* request); 93 virtual WebKit::WebFrame* previousSibling() const;
95 virtual void CommitDocumentData(const char* data, size_t data_len); 94 virtual WebKit::WebFrame* traverseNext(bool wrap) const;
96 virtual void ExecuteScript(const WebKit::WebScriptSource& source); 95 virtual WebKit::WebFrame* traversePrevious(bool wrap) const;
97 virtual void ExecuteScriptInNewContext( 96 virtual WebKit::WebFrame* findChildByName(const WebKit::WebString& name) const ;
98 const WebKit::WebScriptSource* sources, int num_sources, 97 virtual WebKit::WebFrame* findChildByExpression(
98 const WebKit::WebString& xpath) const;
99 virtual void forms(WebKit::WebVector<WebKit::WebForm>&) const;
100 virtual WebKit::WebString securityOrigin() const;
101 virtual void grantUniversalAccess();
102 virtual NPObject* windowObject() const;
103 virtual void bindToWindowObject(
104 const WebKit::WebString& name, NPObject* object);
105 virtual void executeScript(const WebKit::WebScriptSource&);
106 virtual void executeScriptInNewContext(
107 const WebKit::WebScriptSource* sources, unsigned num_sources,
99 int extension_group); 108 int extension_group);
100 virtual void ExecuteScriptInNewWorld( 109 virtual void executeScriptInNewWorld(
101 const WebKit::WebScriptSource* sources, int num_sources, 110 const WebKit::WebScriptSource* sources, unsigned num_sources,
102 int extension_group); 111 int extension_group);
103 virtual bool InsertCSSStyles(const std::string& css); 112 virtual void addMessageToConsole(const WebKit::WebConsoleMessage&);
104 virtual WebKit::WebHistoryItem GetPreviousHistoryItem() const; 113 virtual void collectGarbage();
105 virtual WebKit::WebHistoryItem GetCurrentHistoryItem() const; 114 #if WEBKIT_USING_V8
106 virtual GURL GetURL() const; 115 virtual v8::Local<v8::Context> mainWorldScriptContext() const;
107 virtual GURL GetFavIconURL() const;
108 virtual GURL GetOSDDURL() const;
109 virtual int GetContentsPreferredWidth() const;
110 virtual WebKit::WebDataSource* GetDataSource() const;
111 virtual WebKit::WebDataSource* GetProvisionalDataSource() const;
112 virtual void StopLoading();
113 virtual bool IsLoading() const;
114 virtual WebFrame* GetOpener() const;
115 virtual WebFrame* GetParent() const;
116 virtual WebFrame* GetTop() const;
117 virtual WebFrame* GetChildFrame(const std::wstring& xpath) const;
118 virtual WebView* GetView() const;
119 virtual void GetForms(std::vector<WebKit::WebForm>* forms) const;
120 virtual std::string GetSecurityOrigin() const;
121
122 // This method calls createRuntimeObject (in KJS::Bindings::Instance), which
123 // increments the refcount of the NPObject passed in.
124 virtual void BindToWindowObject(const std::wstring& name, NPObject* object);
125 virtual void CallJSGC();
126
127 virtual void GrantUniversalAccess();
128
129 virtual NPObject* GetWindowNPObject();
130
131 #if USE(V8)
132 // Returns the V8 context for this frame, or an empty handle if there is
133 // none.
134 virtual v8::Local<v8::Context> GetMainWorldScriptContext();
135 #endif 116 #endif
136 117 virtual bool insertStyleText(const WebKit::WebString& style_text);
137 virtual void GetContentAsPlainText(int max_chars, std::wstring* text) const; 118 virtual void reload();
138 virtual bool Find( 119 virtual void loadRequest(const WebKit::WebURLRequest& request);
139 int request_id, 120 virtual void loadHistoryItem(const WebKit::WebHistoryItem& history_item);
140 const string16& search_text, 121 virtual void loadData(
141 const WebKit::WebFindOptions& options, 122 const WebKit::WebData& data, const WebKit::WebString& mime_type,
142 bool wrap_within_frame, 123 const WebKit::WebString& text_encoding, const WebKit::WebURL& base_url,
124 const WebKit::WebURL& unreachable_url, bool replace);
125 virtual void loadHTMLString(
126 const WebKit::WebData& html, const WebKit::WebURL& base_url,
127 const WebKit::WebURL& unreachable_url, bool replace);
128 virtual bool isLoading() const;
129 virtual void stopLoading();
130 virtual WebKit::WebDataSource* provisionalDataSource() const;
131 virtual WebKit::WebDataSource* dataSource() const;
132 virtual WebKit::WebHistoryItem previousHistoryItem() const;
133 virtual WebKit::WebHistoryItem currentHistoryItem() const;
134 virtual void enableViewSourceMode(bool enable);
135 virtual bool isViewSourceModeEnabled() const;
136 virtual void dispatchWillSendRequest(WebKit::WebURLRequest& request);
137 virtual void commitDocumentData(const char* data, size_t length);
138 virtual unsigned unloadListenerCount() const;
139 virtual void replaceSelection(const WebKit::WebString& text);
140 virtual void insertText(const WebKit::WebString& text);
141 virtual void setMarkedText(
142 const WebKit::WebString& text, unsigned location, unsigned length);
143 virtual void unmarkText();
144 virtual bool hasMarkedText() const;
145 virtual WebKit::WebRange markedRange() const;
146 virtual bool executeCommand(const WebKit::WebString& command);
147 virtual bool executeCommand(
148 const WebKit::WebString& command, const WebKit::WebString& value);
149 virtual bool isCommandEnabled(const WebKit::WebString& command) const;
150 virtual void enableContinuousSpellChecking(bool enable);
151 virtual bool isContinuousSpellCheckingEnabled() const;
152 virtual void selectAll();
153 virtual void clearSelection();
154 virtual bool hasSelection() const;
155 virtual WebKit::WebRange selectionRange() const;
156 virtual WebKit::WebString selectionAsText() const;
157 virtual WebKit::WebString selectionAsMarkup() const;
158 virtual int printBegin(const WebKit::WebSize& page_size);
159 virtual float printPage(int page_to_print, WebKit::WebCanvas* canvas);
160 virtual void printEnd();
161 virtual bool find(
162 int identifier, const WebKit::WebString& search_text,
163 const WebKit::WebFindOptions& options, bool wrap_within_frame,
143 WebKit::WebRect* selection_rect); 164 WebKit::WebRect* selection_rect);
144 virtual void StopFinding(bool clear_selection); 165 virtual void stopFinding(bool clear_selection);
145 virtual void ScopeStringMatches( 166 virtual void scopeStringMatches(
146 int request_id, 167 int identifier, const WebKit::WebString& search_text,
147 const string16& search_text, 168 const WebKit::WebFindOptions& options, bool reset);
148 const WebKit::WebFindOptions& options, 169 virtual void cancelPendingScopingEffort();
149 bool reset); 170 virtual void increaseMatchCount(int count, int identifier);
150 virtual void CancelPendingScopingEffort(); 171 virtual void reportFindInPageSelection(
151 virtual void ResetMatchCount(); 172 const WebKit::WebRect& selection_rect, int active_match_ordinal,
152 virtual bool Visible(); 173 int identifier);
153 virtual void SelectAll(); 174 virtual void resetMatchCount();
154 virtual void Copy(); 175 virtual WebKit::WebString contentAsText(size_t max_chars) const;
155 virtual void Cut(); 176 virtual WebKit::WebString contentAsMarkup() const;
156 virtual void Paste();
157 virtual void Replace(const std::wstring& text);
158 virtual void ToggleSpellCheck();
159 virtual bool SpellCheckEnabled();
160 virtual void Delete();
161 virtual void Undo();
162 virtual void Redo();
163 virtual void ClearSelection();
164 virtual bool HasSelection();
165 virtual std::string GetSelection(bool as_html);
166 virtual std::string GetFullPageHtml();
167
168 virtual void SetInViewSourceMode(bool enable);
169
170 virtual bool GetInViewSourceMode() const;
171
172 virtual void DidFail(const WebCore::ResourceError&, bool was_provisional);
173
174 virtual std::wstring GetName();
175
176 virtual WebTextInput* GetTextInput();
177
178 virtual bool ExecuteEditCommandByName(const std::string& name,
179 const std::string& value);
180 virtual bool IsEditCommandEnabled(const std::string& name);
181
182 virtual void AddMessageToConsole(const WebKit::WebConsoleMessage&);
183
184 virtual WebKit::WebSize ScrollOffset() const;
185
186 virtual int PrintBegin(const WebKit::WebSize& page_size);
187 virtual float PrintPage(int page, WebKit::WebCanvas* canvas);
188 virtual void PrintEnd();
189 177
190 PassRefPtr<WebCore::Frame> CreateChildFrame( 178 PassRefPtr<WebCore::Frame> CreateChildFrame(
191 const WebCore::FrameLoadRequest&, 179 const WebCore::FrameLoadRequest&,
192 WebCore::HTMLFrameOwnerElement* owner_element); 180 WebCore::HTMLFrameOwnerElement* owner_element);
193 181
194 // WebFrameImpl 182 // WebFrameImpl
195 void Layout(); 183 void Layout();
196 void Paint(skia::PlatformCanvas* canvas, const WebKit::WebRect& rect); 184 void Paint(skia::PlatformCanvas* canvas, const WebKit::WebRect& rect);
197 185
198 void CreateFrameView(); 186 void CreateFrameView();
(...skipping 33 matching lines...) Expand 10 before | Expand all | Expand 10 after
232 } 220 }
233 221
234 // When a Find operation ends, we want to set the selection to what was active 222 // When a Find operation ends, we want to set the selection to what was active
235 // and set focus to the first focusable node we find (starting with the first 223 // and set focus to the first focusable node we find (starting with the first
236 // node in the matched range and going up the inheritance chain). If we find 224 // node in the matched range and going up the inheritance chain). If we find
237 // nothing to focus we focus the first focusable node in the range. This 225 // nothing to focus we focus the first focusable node in the range. This
238 // allows us to set focus to a link (when we find text inside a link), which 226 // allows us to set focus to a link (when we find text inside a link), which
239 // allows us to navigate by pressing Enter after closing the Find box. 227 // allows us to navigate by pressing Enter after closing the Find box.
240 void SetFindEndstateFocusAndSelection(); 228 void SetFindEndstateFocusAndSelection();
241 229
230 void DidFail(const WebCore::ResourceError& error, bool was_provisional);
231
242 // Sets whether the WebFrameImpl allows its document to be scrolled. 232 // Sets whether the WebFrameImpl allows its document to be scrolled.
243 // If the parameter is true, allow the document to be scrolled. 233 // If the parameter is true, allow the document to be scrolled.
244 // Otherwise, disallow scrolling. 234 // Otherwise, disallow scrolling.
245 void SetAllowsScrolling(bool flag); 235 void SetAllowsScrolling(bool flag);
246 236
247 // Registers a listener for the specified user name input element. The 237 // Registers a listener for the specified user name input element. The
248 // listener will receive notifications for blur and when autocomplete should 238 // listener will receive notifications for blur and when autocomplete should
249 // be triggered. 239 // be triggered.
250 // The WebFrameImpl becomes the owner of the passed listener. 240 // The WebFrameImpl becomes the owner of the passed listener.
251 void RegisterPasswordListener( 241 void RegisterPasswordListener(
252 PassRefPtr<WebCore::HTMLInputElement> user_name_input_element, 242 PassRefPtr<WebCore::HTMLInputElement> user_name_input_element,
253 webkit_glue::PasswordAutocompleteListener* listener); 243 webkit_glue::PasswordAutocompleteListener* listener);
254 244
255 // Returns the password autocomplete listener associated with the passed 245 // Returns the password autocomplete listener associated with the passed
256 // user name input element, or NULL if none available. 246 // user name input element, or NULL if none available.
257 // Note that the returned listener is owner by the WebFrameImpl and should not 247 // Note that the returned listener is owner by the WebFrameImpl and should not
258 // be kept around as it is deleted when the page goes away. 248 // be kept around as it is deleted when the page goes away.
259 webkit_glue::PasswordAutocompleteListener* GetPasswordListener( 249 webkit_glue::PasswordAutocompleteListener* GetPasswordListener(
260 WebCore::HTMLInputElement* user_name_input_element); 250 WebCore::HTMLInputElement* user_name_input_element);
261 251
262 protected: 252 protected:
263 friend class WebFrameLoaderClient; 253 friend class WebFrameLoaderClient;
264 254
265 // Informs the WebFrame that the Frame is being closed, called by the 255 // Informs the WebFrame that the Frame is being closed, called by the
266 // WebFrameLoaderClient 256 // WebFrameLoaderClient
267 void Closing(); 257 void Closing();
268 258
269 // See WebFrame.h for details.
270 virtual void IncreaseMatchCount(int count, int request_id);
271 virtual void ReportFindInPageSelection(const WebKit::WebRect& selection_rect,
272 int active_match_ordinal,
273 int request_id);
274
275 // Used to check for leaks of this object. 259 // Used to check for leaks of this object.
276 static int live_object_count_; 260 static int live_object_count_;
277 261
278 WebFrameLoaderClient frame_loader_client_; 262 WebFrameLoaderClient frame_loader_client_;
279 263
280 // This is a factory for creating cancelable tasks for this frame that run 264 // This is a factory for creating cancelable tasks for this frame that run
281 // asynchronously in order to scope string matches during a find operation. 265 // asynchronously in order to scope string matches during a find operation.
282 ScopedRunnableMethodFactory<WebFrameImpl> scope_matches_factory_; 266 ScopedRunnableMethodFactory<WebFrameImpl> scope_matches_factory_;
283 267
284 // This is a weak pointer to our corresponding WebCore frame. A reference to 268 // This is a weak pointer to our corresponding WebCore frame. A reference to
285 // ourselves is held while frame_ is valid. See our Closing method. 269 // ourselves is held while frame_ is valid. See our Closing method.
286 WebCore::Frame* frame_; 270 WebCore::Frame* frame_;
287 271
288 // Plugins sometimes need to be notified when loads are complete so we keep 272 // Plugins sometimes need to be notified when loads are complete so we keep
289 // a pointer back to the appropriate plugin. 273 // a pointer back to the appropriate plugin.
290 WebPluginDelegate* plugin_delegate_; 274 WebPluginDelegate* plugin_delegate_;
291 275
292 // Handling requests from TextInputController on this frame.
293 scoped_ptr<WebTextInputImpl> webtextinput_impl_;
294
295 // A way for the main frame to keep track of which frame has an active 276 // A way for the main frame to keep track of which frame has an active
296 // match. Should be NULL for all other frames. 277 // match. Should be NULL for all other frames.
297 WebFrameImpl* active_match_frame_; 278 WebFrameImpl* active_match_frame_;
298 279
299 // The range of the active match for the current frame. 280 // The range of the active match for the current frame.
300 RefPtr<WebCore::Range> active_match_; 281 RefPtr<WebCore::Range> active_match_;
301 282
302 // The index of the active match. 283 // The index of the active match.
303 int active_match_index_; 284 int active_match_index_;
304 285
(...skipping 89 matching lines...) Expand 10 before | Expand all | Expand 10 after
394 // The input fields that are interested in edit events and their associated 375 // The input fields that are interested in edit events and their associated
395 // listeners. 376 // listeners.
396 typedef HashMap<RefPtr<WebCore::HTMLInputElement>, 377 typedef HashMap<RefPtr<WebCore::HTMLInputElement>,
397 webkit_glue::PasswordAutocompleteListener*> PasswordListenerMap; 378 webkit_glue::PasswordAutocompleteListener*> PasswordListenerMap;
398 PasswordListenerMap password_listeners_; 379 PasswordListenerMap password_listeners_;
399 380
400 DISALLOW_COPY_AND_ASSIGN(WebFrameImpl); 381 DISALLOW_COPY_AND_ASSIGN(WebFrameImpl);
401 }; 382 };
402 383
403 #endif // WEBKIT_GLUE_WEBFRAME_IMPL_H_ 384 #endif // WEBKIT_GLUE_WEBFRAME_IMPL_H_
OLDNEW
« no previous file with comments | « webkit/glue/webframe.h ('k') | webkit/glue/webframe_impl.cc » ('j') | no next file with comments »

Powered by Google App Engine
This is Rietveld 408576698