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

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

Issue 341030: Moves webview_impl.cc, webframe_impl.cc and webframeloaderclient_impl.cc into... (Closed) Base URL: svn://svn.chromium.org/chrome/trunk/src/
Patch Set: '' Created 11 years, 1 month 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/webkitclient_impl.cc ('k') | webkit/glue/webview_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
(Empty)
1 // Copyright (c) 2009 The Chromium Authors. All rights reserved.
2 // Use of this source code is governed by a BSD-style license that can be
3 // found in the LICENSE file.
4
5 #ifndef WEBKIT_GLUE_WEBVIEW_IMPL_H_
6 #define WEBKIT_GLUE_WEBVIEW_IMPL_H_
7
8 #include <wtf/OwnPtr.h>
9 #include <wtf/RefCounted.h>
10
11 #include "webkit/api/public/WebPoint.h"
12 #include "webkit/api/public/WebSize.h"
13 #include "webkit/api/public/WebString.h"
14 #include "webkit/api/public/WebView.h"
15 #include "webkit/api/src/BackForwardListClientImpl.h"
16 #include "webkit/api/src/ChromeClientImpl.h"
17 #include "webkit/api/src/ContextMenuClientImpl.h"
18 #include "webkit/api/src/DragClientImpl.h"
19 #include "webkit/api/src/EditorClientImpl.h"
20 #include "webkit/api/src/InspectorClientImpl.h"
21 #include "webkit/api/src/NotificationPresenterImpl.h"
22 #include "webkit/glue/webframe_impl.h"
23
24 namespace WebCore {
25 class ChromiumDataObject;
26 class Frame;
27 class HistoryItem;
28 class HitTestResult;
29 class KeyboardEvent;
30 class Page;
31 class PlatformKeyboardEvent;
32 class PopupContainer;
33 class Range;
34 class RenderTheme;
35 class Widget;
36 }
37
38 namespace WebKit {
39 class ContextMenuClientImpl;
40 class WebAccessibilityObject;
41 class WebKeyboardEvent;
42 class WebMouseEvent;
43 class WebMouseWheelEvent;
44 class WebSettingsImpl;
45 }
46
47 namespace webkit_glue {
48 class ImageResourceFetcher;
49 }
50
51 class AutocompletePopupMenuClient;
52 class WebHistoryItemImpl;
53 class WebDevToolsAgentImpl;
54
55 class WebViewImpl : public WebKit::WebView, public RefCounted<WebViewImpl> {
56 public:
57 // WebWidget methods:
58 virtual void close();
59 virtual WebKit::WebSize size() { return size_; }
60 virtual void resize(const WebKit::WebSize& new_size);
61 virtual void layout();
62 virtual void paint(WebKit::WebCanvas* canvas,
63 const WebKit::WebRect& rect);
64 virtual bool handleInputEvent(const WebKit::WebInputEvent& input_event);
65 virtual void mouseCaptureLost();
66 virtual void setFocus(bool enable);
67 virtual bool handleCompositionEvent(WebKit::WebCompositionCommand command,
68 int cursor_position,
69 int target_start,
70 int target_end,
71 const WebKit::WebString& text);
72 virtual bool queryCompositionStatus(bool* enabled,
73 WebKit::WebRect* caret_rect);
74 virtual void setTextDirection(WebKit::WebTextDirection direction);
75
76 // WebView methods:
77 virtual void initializeMainFrame(WebKit::WebFrameClient*);
78 virtual WebKit::WebSettings* settings();
79 virtual WebKit::WebString pageEncoding() const;
80 virtual void setPageEncoding(const WebKit::WebString& encoding);
81 virtual bool isTransparent() const;
82 virtual void setIsTransparent(bool value);
83 virtual bool tabsToLinks() const;
84 virtual void setTabsToLinks(bool value);
85 virtual bool tabKeyCyclesThroughElements() const;
86 virtual void setTabKeyCyclesThroughElements(bool value);
87 virtual bool isActive() const;
88 virtual void setIsActive(bool value);
89 virtual bool dispatchBeforeUnloadEvent();
90 virtual void dispatchUnloadEvent();
91 virtual WebKit::WebFrame* mainFrame();
92 virtual WebKit::WebFrame* findFrameByName(
93 const WebKit::WebString& name, WebKit::WebFrame* relative_to_frame);
94 virtual WebKit::WebFrame* focusedFrame();
95 virtual void setFocusedFrame(WebKit::WebFrame* frame);
96 virtual void setInitialFocus(bool reverse);
97 virtual void clearFocusedNode();
98 virtual void zoomIn(bool text_only);
99 virtual void zoomOut(bool text_only);
100 virtual void zoomDefault();
101 virtual void performMediaPlayerAction(
102 const WebKit::WebMediaPlayerAction& action,
103 const WebKit::WebPoint& location);
104 virtual void copyImageAt(const WebKit::WebPoint& point);
105 virtual void dragSourceEndedAt(
106 const WebKit::WebPoint& client_point,
107 const WebKit::WebPoint& screen_point,
108 WebKit::WebDragOperation operation);
109 virtual void dragSourceMovedTo(
110 const WebKit::WebPoint& client_point,
111 const WebKit::WebPoint& screen_point);
112 virtual void dragSourceSystemDragEnded();
113 virtual WebKit::WebDragOperation dragTargetDragEnter(
114 const WebKit::WebDragData& drag_data, int identity,
115 const WebKit::WebPoint& client_point,
116 const WebKit::WebPoint& screen_point,
117 WebKit::WebDragOperationsMask operations_allowed);
118 virtual WebKit::WebDragOperation dragTargetDragOver(
119 const WebKit::WebPoint& client_point,
120 const WebKit::WebPoint& screen_point,
121 WebKit::WebDragOperationsMask operations_allowed);
122 virtual void dragTargetDragLeave();
123 virtual void dragTargetDrop(
124 const WebKit::WebPoint& client_point,
125 const WebKit::WebPoint& screen_point);
126 virtual int dragIdentity();
127 virtual bool setDropEffect(bool accept);
128 virtual void inspectElementAt(const WebKit::WebPoint& point);
129 virtual WebKit::WebString inspectorSettings() const;
130 virtual void setInspectorSettings(const WebKit::WebString& settings);
131 virtual WebKit::WebDevToolsAgent* devToolsAgent();
132 virtual WebKit::WebAccessibilityObject accessibilityObject();
133 virtual void applyAutofillSuggestions(
134 const WebKit::WebNode&,
135 const WebKit::WebVector<WebKit::WebString>& suggestions,
136 int defaultSuggestionIndex);
137 virtual void hideAutofillPopup();
138
139 // WebViewImpl
140
141 void SetIgnoreInputEvents(bool new_value);
142 WebDevToolsAgentImpl* GetWebDevToolsAgentImpl();
143
144 const WebKit::WebPoint& last_mouse_down_point() const {
145 return last_mouse_down_point_;
146 }
147
148 WebCore::Frame* GetFocusedWebCoreFrame();
149
150 // Returns the currently focused Node or NULL if no node has focus.
151 WebCore::Node* GetFocusedNode();
152
153 static WebViewImpl* FromPage(WebCore::Page* page);
154
155 WebKit::WebViewClient* client() {
156 return client_;
157 }
158
159 // Returns the page object associated with this view. This may be NULL when
160 // the page is shutting down, but will be valid at all other times.
161 WebCore::Page* page() const {
162 return page_.get();
163 }
164
165 WebCore::RenderTheme* theme() const;
166
167 // Returns the main frame associated with this view. This may be NULL when
168 // the page is shutting down, but will be valid at all other times.
169 WebFrameImpl* main_frame() {
170 return page_.get() ? WebFrameImpl::FromFrame(page_->mainFrame()) : NULL;
171 }
172
173 // History related methods:
174 void SetCurrentHistoryItem(WebCore::HistoryItem* item);
175 WebCore::HistoryItem* GetPreviousHistoryItem();
176 void ObserveNewNavigation();
177
178 // Event related methods:
179 void MouseMove(const WebKit::WebMouseEvent& mouse_event);
180 void MouseLeave(const WebKit::WebMouseEvent& mouse_event);
181 void MouseDown(const WebKit::WebMouseEvent& mouse_event);
182 void MouseUp(const WebKit::WebMouseEvent& mouse_event);
183 void MouseContextMenu(const WebKit::WebMouseEvent& mouse_event);
184 void MouseDoubleClick(const WebKit::WebMouseEvent& mouse_event);
185 void MouseWheel(const WebKit::WebMouseWheelEvent& wheel_event);
186 bool KeyEvent(const WebKit::WebKeyboardEvent& key_event);
187 bool CharEvent(const WebKit::WebKeyboardEvent& key_event);
188
189 // Handles context menu events orignated via the the keyboard. These
190 // include the VK_APPS virtual key and the Shift+F10 combine.
191 // Code is based on the Webkit function
192 // bool WebView::handleContextMenuEvent(WPARAM wParam, LPARAM lParam) in
193 // webkit\webkit\win\WebView.cpp. The only significant change in this
194 // function is the code to convert from a Keyboard event to the Right
195 // Mouse button down event.
196 bool SendContextMenuEvent(const WebKit::WebKeyboardEvent& event);
197
198 // Notifies the WebView that a load has been committed.
199 // is_new_navigation will be true if a new session history item should be
200 // created for that load.
201 void DidCommitLoad(bool* is_new_navigation);
202
203 bool context_menu_allowed() const {
204 return context_menu_allowed_;
205 }
206
207 // Set the disposition for how this webview is to be initially shown.
208 void set_initial_navigation_policy(WebKit::WebNavigationPolicy policy) {
209 initial_navigation_policy_ = policy;
210 }
211 WebKit::WebNavigationPolicy initial_navigation_policy() const {
212 return initial_navigation_policy_;
213 }
214
215 // Determines whether a page should e.g. be opened in a background tab.
216 // Returns false if it has no opinion, in which case it doesn't set *policy.
217 static bool NavigationPolicyFromMouseEvent(
218 unsigned short button,
219 bool ctrl,
220 bool shift,
221 bool alt,
222 bool meta,
223 WebKit::WebNavigationPolicy* policy);
224
225 // Start a system drag and drop operation.
226 void StartDragging(
227 const WebKit::WebPoint& event_pos,
228 const WebKit::WebDragData& drag_data,
229 WebKit::WebDragOperationsMask drag_source_operation_mask);
230
231 // Hides the autocomplete popup if it is showing.
232 void HideAutoCompletePopup();
233 void AutoCompletePopupDidHide();
234
235 #if ENABLE(NOTIFICATIONS)
236 // Returns the provider of desktop notifications.
237 WebKit::NotificationPresenterImpl* GetNotificationPresenter();
238 #endif
239
240 // Tries to scroll a frame or any parent of a frame. Returns true if the view
241 // was scrolled.
242 bool PropagateScroll(WebCore::ScrollDirection scroll_direction,
243 WebCore::ScrollGranularity scroll_granularity);
244
245 protected:
246 friend class WebKit::WebView; // So WebView::Create can call our constructor
247 friend class WTF::RefCounted<WebViewImpl>;
248
249 WebViewImpl(WebKit::WebViewClient* client);
250 ~WebViewImpl();
251
252 void ModifySelection(uint32 message,
253 WebCore::Frame* frame,
254 const WebCore::PlatformKeyboardEvent& e);
255
256 WebKit::WebViewClient* client_;
257
258 WebKit::BackForwardListClientImpl back_forward_list_client_impl_;
259 WebKit::ChromeClientImpl chrome_client_impl_;
260 WebKit::ContextMenuClientImpl context_menu_client_impl_;
261 WebKit::DragClientImpl drag_client_impl_;
262 WebKit::EditorClientImpl editor_client_impl_;
263 WebKit::InspectorClientImpl inspector_client_impl_;
264
265 WebKit::WebSize size_;
266
267 WebKit::WebPoint last_mouse_position_;
268 OwnPtr<WebCore::Page> page_;
269
270 // This flag is set when a new navigation is detected. It is used to satisfy
271 // the corresponding argument to WebFrameClient::didCommitProvisionalLoad.
272 bool observed_new_navigation_;
273 #ifndef NDEBUG
274 // Used to assert that the new navigation we observed is the same navigation
275 // when we make use of observed_new_navigation_.
276 const WebCore::DocumentLoader* new_navigation_loader_;
277 #endif
278
279 // An object that can be used to manipulate page_->settings() without linking
280 // against WebCore. This is lazily allocated the first time GetWebSettings()
281 // is called.
282 OwnPtr<WebKit::WebSettingsImpl> web_settings_;
283
284 // A copy of the web drop data object we received from the browser.
285 RefPtr<WebCore::ChromiumDataObject> current_drag_data_;
286
287 private:
288 // Returns true if the event was actually processed.
289 bool KeyEventDefault(const WebKit::WebKeyboardEvent& event);
290
291 // Returns true if the autocomple has consumed the event.
292 bool AutocompleteHandleKeyEvent(const WebKit::WebKeyboardEvent& event);
293
294 // Repaints the autofill popup. Should be called when the suggestions have
295 // changed. Note that this should only be called when the autofill popup is
296 // showing.
297 void RefreshAutofillPopup();
298
299 // Returns true if the view was scrolled.
300 bool ScrollViewWithKeyboard(int key_code, int modifiers);
301
302 // Converts |pos| from window coordinates to contents coordinates and gets
303 // the HitTestResult for it.
304 WebCore::HitTestResult HitTestResultForWindowPos(
305 const WebCore::IntPoint& pos);
306
307 // The point relative to the client area where the mouse was last pressed
308 // down. This is used by the drag client to determine what was under the
309 // mouse when the drag was initiated. We need to track this here in
310 // WebViewImpl since DragClient::startDrag does not pass the position the
311 // mouse was at when the drag was initiated, only the current point, which
312 // can be misleading as it is usually not over the element the user actually
313 // dragged by the time a drag is initiated.
314 WebKit::WebPoint last_mouse_down_point_;
315
316 // Keeps track of the current text zoom level. 0 means no zoom, positive
317 // values mean larger text, negative numbers mean smaller.
318 int zoom_level_;
319
320 bool context_menu_allowed_;
321
322 bool doing_drag_and_drop_;
323
324 bool ignore_input_events_;
325
326 // Webkit expects keyPress events to be suppressed if the associated keyDown
327 // event was handled. Safari implements this behavior by peeking out the
328 // associated WM_CHAR event if the keydown was handled. We emulate
329 // this behavior by setting this flag if the keyDown was handled.
330 bool suppress_next_keypress_event_;
331
332 // The policy for how this webview is to be initially shown.
333 WebKit::WebNavigationPolicy initial_navigation_policy_;
334
335 // Represents whether or not this object should process incoming IME events.
336 bool ime_accept_events_;
337
338 // True while dispatching system drag and drop events to drag/drop targets
339 // within this WebView.
340 bool drag_target_dispatch_;
341
342 // Valid when drag_target_dispatch_ is true; the identity of the drag data
343 // copied from the WebDropData object sent from the browser process.
344 int32 drag_identity_;
345
346 // Valid when drag_target_dispatch_ is true. Used to override the default
347 // browser drop effect with the effects "none" or "copy".
348 enum DragTargetDropEffect {
349 DROP_EFFECT_DEFAULT = -1,
350 DROP_EFFECT_NONE,
351 DROP_EFFECT_COPY
352 } drop_effect_;
353
354 // The available drag operations (copy, move link...) allowed by the source.
355 WebKit::WebDragOperation operations_allowed_;
356
357 // The current drag operation as negotiated by the source and destination.
358 // When not equal to DragOperationNone, the drag data can be dropped onto the
359 // current drop target in this WebView (the drop target can accept the drop).
360 WebKit::WebDragOperation drag_operation_;
361
362 // The autocomplete popup. Kept around and reused every-time new suggestions
363 // should be shown.
364 RefPtr<WebCore::PopupContainer> autocomplete_popup_;
365
366 // Whether the autocomplete popup is currently showing.
367 bool autocomplete_popup_showing_;
368
369 // The autocomplete client.
370 OwnPtr<AutocompletePopupMenuClient> autocomplete_popup_client_;
371
372 OwnPtr<WebDevToolsAgentImpl> devtools_agent_;
373
374 // Whether the webview is rendering transparently.
375 bool is_transparent_;
376
377 // Whether the user can press tab to focus links.
378 bool tabs_to_links_;
379
380 // Inspector settings.
381 WebKit::WebString inspector_settings_;
382
383 #if ENABLE(NOTIFICATIONS)
384 // The provider of desktop notifications;
385 WebKit::NotificationPresenterImpl notification_presenter_;
386 #endif
387
388 // HACK: current_input_event is for ChromeClientImpl::show(), until we can fix
389 // WebKit to pass enough information up into ChromeClient::show() so we can
390 // decide if the window.open event was caused by a middle-mouse click
391 public:
392 static const WebKit::WebInputEvent* current_input_event() {
393 return g_current_input_event;
394 }
395 private:
396 static const WebKit::WebInputEvent* g_current_input_event;
397
398 DISALLOW_COPY_AND_ASSIGN(WebViewImpl);
399 };
400
401 #endif // WEBKIT_GLUE_WEBVIEW_IMPL_H_
OLDNEW
« no previous file with comments | « webkit/glue/webkitclient_impl.cc ('k') | webkit/glue/webview_impl.cc » ('j') | no next file with comments »

Powered by Google App Engine
This is Rietveld 408576698