Remove unused methods.
[chromium-blink-merge.git] / content / renderer / render_view_impl.h
blob8e34e1c78c4acfd99b496ae4b883ef6be411da33
1 // Copyright (c) 2012 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.
5 #ifndef CONTENT_RENDERER_RENDER_VIEW_IMPL_H_
6 #define CONTENT_RENDERER_RENDER_VIEW_IMPL_H_
8 #include <deque>
9 #include <map>
10 #include <set>
11 #include <string>
12 #include <vector>
14 #include "base/basictypes.h"
15 #include "base/gtest_prod_util.h"
16 #include "base/id_map.h"
17 #include "base/memory/linked_ptr.h"
18 #include "base/memory/weak_ptr.h"
19 #include "base/observer_list.h"
20 #include "base/process/process.h"
21 #include "base/strings/string16.h"
22 #include "base/timer/timer.h"
23 #include "build/build_config.h"
24 #include "cc/input/top_controls_state.h"
25 #include "cc/resources/shared_bitmap.h"
26 #include "content/common/content_export.h"
27 #include "content/common/drag_event_source_info.h"
28 #include "content/common/edit_command.h"
29 #include "content/common/gpu/client/webgraphicscontext3d_command_buffer_impl.h"
30 #include "content/common/navigation_gesture.h"
31 #include "content/common/view_message_enums.h"
32 #include "content/public/common/page_zoom.h"
33 #include "content/public/common/referrer.h"
34 #include "content/public/common/renderer_preferences.h"
35 #include "content/public/common/stop_find_action.h"
36 #include "content/public/common/top_controls_state.h"
37 #include "content/public/common/web_preferences.h"
38 #include "content/public/renderer/render_view.h"
39 #include "content/renderer/mouse_lock_dispatcher.h"
40 #include "content/renderer/render_frame_impl.h"
41 #include "content/renderer/render_widget.h"
42 #include "content/renderer/stats_collection_observer.h"
43 #include "ipc/ipc_platform_file.h"
44 #include "third_party/WebKit/public/platform/WebGraphicsContext3D.h"
45 #include "third_party/WebKit/public/web/WebAXObject.h"
46 #include "third_party/WebKit/public/web/WebConsoleMessage.h"
47 #include "third_party/WebKit/public/web/WebDataSource.h"
48 #include "third_party/WebKit/public/web/WebElement.h"
49 #include "third_party/WebKit/public/web/WebHistoryItem.h"
50 #include "third_party/WebKit/public/web/WebIconURL.h"
51 #include "third_party/WebKit/public/web/WebInputEvent.h"
52 #include "third_party/WebKit/public/web/WebNavigationType.h"
53 #include "third_party/WebKit/public/web/WebNode.h"
54 #include "third_party/WebKit/public/web/WebPageSerializerClient.h"
55 #include "third_party/WebKit/public/web/WebPageVisibilityState.h"
56 #include "third_party/WebKit/public/web/WebSecurityOrigin.h"
57 #include "third_party/WebKit/public/web/WebViewClient.h"
58 #include "ui/base/window_open_disposition.h"
59 #include "ui/surface/transport_dib.h"
61 #if defined(OS_ANDROID)
62 #include "content/renderer/android/content_detector.h"
63 #include "content/renderer/android/renderer_date_time_picker.h"
64 #include "third_party/WebKit/public/web/WebContentDetectionResult.h"
65 #endif
67 #if defined(COMPILER_MSVC)
68 // RenderViewImpl is a diamond-shaped hierarchy, with WebWidgetClient at the
69 // root. VS warns when we inherit the WebWidgetClient method implementations
70 // from RenderWidget. It's safe to ignore that warning.
71 #pragma warning(disable: 4250)
72 #endif
74 class PepperDeviceTest;
75 class SkBitmap;
76 struct PP_NetAddress_Private;
77 struct FrameMsg_Navigate_Params;
78 struct ViewMsg_PostMessage_Params;
79 struct ViewMsg_StopFinding_Params;
81 namespace base {
82 class CommandLine;
85 namespace blink {
86 class WebApplicationCacheHost;
87 class WebApplicationCacheHostClient;
88 class WebDOMMessageEvent;
89 class WebDataSource;
90 class WebDateTimeChooserCompletion;
91 class WebDragData;
92 class WebGestureEvent;
93 class WebIconURL;
94 class WebImage;
95 class WebPeerConnection00Handler;
96 class WebPeerConnection00HandlerClient;
97 class WebMouseEvent;
98 class WebPeerConnectionHandler;
99 class WebPeerConnectionHandlerClient;
100 class WebSocketStreamHandle;
101 class WebSpeechRecognizer;
102 class WebStorageNamespace;
103 class WebTouchEvent;
104 class WebURLRequest;
105 struct WebActiveWheelFlingParameters;
106 struct WebDateTimeChooserParams;
107 struct WebFileChooserParams;
108 struct WebFindOptions;
109 struct WebMediaPlayerAction;
110 struct WebPluginAction;
111 struct WebPoint;
112 struct WebWindowFeatures;
114 #if defined(OS_ANDROID)
115 class WebHitTestResult;
116 #endif
117 } // namespace blink
119 namespace ui {
120 struct SelectedFileInfo;
123 namespace content {
125 class BrowserPluginManager;
126 class DevToolsAgent;
127 class DocumentState;
128 class HistoryController;
129 class HistoryEntry;
130 class ImageResourceFetcher;
131 class MouseLockDispatcher;
132 class NavigationState;
133 class PepperPluginInstanceImpl;
134 class RenderViewImplTest;
135 class RenderViewObserver;
136 class RenderViewTest;
137 class RendererDateTimePicker;
138 class RendererWebColorChooserImpl;
139 class SpeechRecognitionDispatcher;
140 class WebPluginDelegateProxy;
141 struct DropData;
142 struct FaviconURL;
143 struct FileChooserParams;
144 struct RenderViewImplParams;
146 #if defined(OS_ANDROID)
147 class WebMediaPlayerProxyAndroid;
148 #endif
151 // RenderView is an object that manages a WebView object, and provides a
152 // communication interface with an embedding application process.
154 class CONTENT_EXPORT RenderViewImpl
155 : public RenderWidget,
156 NON_EXPORTED_BASE(public blink::WebViewClient),
157 NON_EXPORTED_BASE(public blink::WebPageSerializerClient),
158 public RenderView,
159 public base::SupportsWeakPtr<RenderViewImpl> {
160 public:
161 // Creates a new RenderView. |opener_id| is the routing ID of the RenderView
162 // responsible for creating this RenderView. Note that if the original opener
163 // has been closed, |window_was_created_with_opener| will be true and
164 // |opener_id| will be MSG_ROUTING_NONE. When |swapped_out| is true, the
165 // |proxy_routing_id| is specified, so a RenderFrameProxy can be created for
166 // this RenderView's main RenderFrame.
167 static RenderViewImpl* Create(int32 opener_id,
168 bool window_was_created_with_opener,
169 const RendererPreferences& renderer_prefs,
170 const WebPreferences& webkit_prefs,
171 int32 routing_id,
172 int32 main_frame_routing_id,
173 int32 surface_id,
174 int64 session_storage_namespace_id,
175 const base::string16& frame_name,
176 bool is_renderer_created,
177 bool swapped_out,
178 int32 proxy_routing_id,
179 bool hidden,
180 bool never_visible,
181 int32 next_page_id,
182 const blink::WebScreenInfo& screen_info);
184 // Used by content_layouttest_support to hook into the creation of
185 // RenderViewImpls.
186 static void InstallCreateHook(
187 RenderViewImpl* (*create_render_view_impl)(RenderViewImplParams*));
189 // Returns the RenderViewImpl containing the given WebView.
190 static RenderViewImpl* FromWebView(blink::WebView* webview);
192 // Returns the RenderViewImpl for the given routing ID.
193 static RenderViewImpl* FromRoutingID(int routing_id);
195 static size_t GetRenderViewCount();
197 // May return NULL when the view is closing.
198 blink::WebView* webview() const;
200 int history_list_offset() const { return history_list_offset_; }
202 const WebPreferences& webkit_preferences() const {
203 return webkit_preferences_;
206 const RendererPreferences& renderer_preferences() const {
207 return renderer_preferences_;
210 void set_send_content_state_immediately(bool value) {
211 send_content_state_immediately_ = value;
214 MouseLockDispatcher* mouse_lock_dispatcher() {
215 return mouse_lock_dispatcher_;
218 HistoryController* history_controller() {
219 return history_controller_.get();
222 // Lazily initialize this view's BrowserPluginManager and return it.
223 BrowserPluginManager* GetBrowserPluginManager();
225 // Functions to add and remove observers for this object.
226 void AddObserver(RenderViewObserver* observer);
227 void RemoveObserver(RenderViewObserver* observer);
229 // Returns the StatsCollectionObserver associated with this view, or NULL
230 // if one wasn't created;
231 StatsCollectionObserver* GetStatsCollectionObserver() {
232 return stats_collection_observer_.get();
235 // Adds the given file chooser request to the file_chooser_completion_ queue
236 // (see that var for more) and requests the chooser be displayed if there are
237 // no other waiting items in the queue.
239 // Returns true if the chooser was successfully scheduled. False means we
240 // didn't schedule anything.
241 bool ScheduleFileChooser(const FileChooserParams& params,
242 blink::WebFileChooserCompletion* completion);
244 #if defined(OS_ANDROID)
245 void DismissDateTimeDialog();
246 #endif
248 bool is_loading() const { return frames_in_progress_ != 0; }
250 void FrameDidStartLoading(blink::WebFrame* frame);
251 void FrameDidStopLoading(blink::WebFrame* frame);
253 // Plugin-related functions --------------------------------------------------
255 #if defined(ENABLE_PLUGINS)
256 // Get/set the plugin which will be used as to handle document find requests.
257 void set_plugin_find_handler(PepperPluginInstanceImpl* plugin) {
258 plugin_find_handler_ = plugin;
260 PepperPluginInstanceImpl* plugin_find_handler() {
261 return plugin_find_handler_;
264 PepperPluginInstanceImpl* focused_pepper_plugin() {
265 return focused_pepper_plugin_;
267 PepperPluginInstanceImpl* pepper_last_mouse_event_target() {
268 return pepper_last_mouse_event_target_;
270 void set_pepper_last_mouse_event_target(PepperPluginInstanceImpl* plugin) {
271 pepper_last_mouse_event_target_ = plugin;
274 #if defined(OS_MACOSX) || defined(OS_WIN)
275 // Informs the render view that the given plugin has gained or lost focus.
276 void PluginFocusChanged(bool focused, int plugin_id);
277 #endif
279 #if defined(OS_MACOSX)
280 // Starts plugin IME.
281 void StartPluginIme();
282 #endif
284 // Indicates that the given instance has been created.
285 void PepperInstanceCreated(PepperPluginInstanceImpl* instance);
287 // Indicates that the given instance is being destroyed. This is called from
288 // the destructor, so it's important that the instance is not dereferenced
289 // from this call.
290 void PepperInstanceDeleted(PepperPluginInstanceImpl* instance);
292 // Notification that the given plugin is focused or unfocused.
293 void PepperFocusChanged(PepperPluginInstanceImpl* instance, bool focused);
295 void RegisterPluginDelegate(WebPluginDelegateProxy* delegate);
296 void UnregisterPluginDelegate(WebPluginDelegateProxy* delegate);
297 #endif // ENABLE_PLUGINS
299 void TransferActiveWheelFlingAnimation(
300 const blink::WebActiveWheelFlingParameters& params);
302 // Returns true if the focused element is editable text from the perspective
303 // of IME support (also used for on-screen keyboard). Works correctly inside
304 // supported PPAPI plug-ins.
305 bool HasIMETextFocus();
307 // Callback for use with GetWindowSnapshot.
308 typedef base::Callback<void(
309 const gfx::Size&, const std::vector<unsigned char>&)>
310 WindowSnapshotCallback;
312 void GetWindowSnapshot(const WindowSnapshotCallback& callback);
314 // Dispatches the current navigation state to the browser. Called on a
315 // periodic timer so we don't send too many messages.
316 void SyncNavigationState();
318 // Returns the length of the session history of this RenderView. Note that
319 // this only coincides with the actual length of the session history if this
320 // RenderView is the currently active RenderView of a WebContents.
321 unsigned GetLocalSessionHistoryLengthForTesting() const;
323 // Invokes OnSetFocus and marks the widget as active depending on the value
324 // of |enable|. This is used for layout tests that need to control the focus
325 // synchronously from the renderer.
326 void SetFocusAndActivateForTesting(bool enable);
328 // Change the device scale factor and force the compositor to resize.
329 void SetDeviceScaleFactorForTesting(float factor);
331 // Change the device ICC color profile while running a layout test.
332 void SetDeviceColorProfileForTesting(const std::vector<char>& color_profile);
333 virtual void ResetDeviceColorProfileForTesting() OVERRIDE;
335 // Used to force the size of a window when running layout tests.
336 void ForceResizeForTesting(const gfx::Size& new_size);
338 void UseSynchronousResizeModeForTesting(bool enable);
340 // Control autoresize mode.
341 void EnableAutoResizeForTesting(const gfx::Size& min_size,
342 const gfx::Size& max_size);
343 void DisableAutoResizeForTesting(const gfx::Size& new_size);
345 // IPC::Listener implementation ----------------------------------------------
347 virtual bool OnMessageReceived(const IPC::Message& msg) OVERRIDE;
349 // blink::WebWidgetClient implementation ------------------------------------
351 // Most methods are handled by RenderWidget.
352 virtual void didFocus();
353 virtual void didBlur();
354 virtual void show(blink::WebNavigationPolicy policy);
355 virtual void runModal();
356 virtual bool enterFullScreen();
357 virtual void exitFullScreen();
358 virtual bool requestPointerLock();
359 virtual void requestPointerUnlock();
360 virtual bool isPointerLocked();
361 virtual void didHandleGestureEvent(const blink::WebGestureEvent& event,
362 bool event_cancelled) OVERRIDE;
363 virtual void initializeLayerTreeView() OVERRIDE;
365 // blink::WebViewClient implementation --------------------------------------
367 virtual blink::WebView* createView(blink::WebLocalFrame* creator,
368 const blink::WebURLRequest& request,
369 const blink::WebWindowFeatures& features,
370 const blink::WebString& frame_name,
371 blink::WebNavigationPolicy policy,
372 bool suppress_opener);
373 virtual blink::WebWidget* createPopupMenu(blink::WebPopupType popup_type);
374 virtual blink::WebStorageNamespace* createSessionStorageNamespace();
375 virtual void printPage(blink::WebLocalFrame* frame);
376 virtual bool enumerateChosenDirectory(
377 const blink::WebString& path,
378 blink::WebFileChooserCompletion* chooser_completion);
379 virtual void saveImageFromDataURL(const blink::WebString& data_url);
380 virtual void didCancelCompositionOnSelectionChange();
381 virtual bool handleCurrentKeyboardEvent();
382 virtual bool runFileChooser(
383 const blink::WebFileChooserParams& params,
384 blink::WebFileChooserCompletion* chooser_completion);
385 void SetValidationMessageDirection(base::string16* main_text,
386 blink::WebTextDirection main_text_hint,
387 base::string16* sub_text,
388 blink::WebTextDirection sub_text_hint);
389 virtual void showValidationMessage(const blink::WebRect& anchor_in_root_view,
390 const blink::WebString& main_text,
391 blink::WebTextDirection main_text_hint,
392 const blink::WebString& sub_text,
393 blink::WebTextDirection hint) OVERRIDE;
394 virtual void hideValidationMessage() OVERRIDE;
395 virtual void moveValidationMessage(
396 const blink::WebRect& anchor_in_root_view) OVERRIDE;
397 virtual void setStatusText(const blink::WebString& text);
398 virtual void setMouseOverURL(const blink::WebURL& url);
399 virtual void setKeyboardFocusURL(const blink::WebURL& url);
400 virtual void startDragging(blink::WebLocalFrame* frame,
401 const blink::WebDragData& data,
402 blink::WebDragOperationsMask mask,
403 const blink::WebImage& image,
404 const blink::WebPoint& imageOffset);
405 virtual bool acceptsLoadDrops();
406 virtual void focusNext();
407 virtual void focusPrevious();
408 virtual void focusedNodeChanged(const blink::WebNode& node);
409 virtual void didUpdateLayout();
410 #if defined(OS_ANDROID) || defined(TOOLKIT_VIEWS)
411 virtual bool didTapMultipleTargets(
412 const blink::WebGestureEvent& event,
413 const blink::WebVector<blink::WebRect>& target_rects);
414 #endif
415 virtual blink::WebString acceptLanguages();
416 virtual void navigateBackForwardSoon(int offset);
417 virtual int historyBackListCount();
418 virtual int historyForwardListCount();
419 virtual blink::WebSpeechRecognizer* speechRecognizer();
420 virtual void zoomLimitsChanged(double minimum_level, double maximum_level);
421 virtual void zoomLevelChanged();
422 virtual double zoomLevelToZoomFactor(double zoom_level) const;
423 virtual double zoomFactorToZoomLevel(double factor) const;
424 virtual void registerProtocolHandler(const blink::WebString& scheme,
425 const blink::WebURL& url,
426 const blink::WebString& title);
427 virtual void unregisterProtocolHandler(const blink::WebString& scheme,
428 const blink::WebURL& url);
429 virtual blink::WebPageVisibilityState visibilityState() const;
430 virtual blink::WebPushClient* webPushClient();
431 virtual void draggableRegionsChanged();
433 #if defined(OS_ANDROID)
434 virtual void scheduleContentIntent(const blink::WebURL& intent);
435 virtual void cancelScheduledContentIntents();
436 virtual blink::WebContentDetectionResult detectContentAround(
437 const blink::WebHitTestResult& touch_hit);
439 // Only used on Android since all other platforms implement
440 // date and time input fields using MULTIPLE_FIELDS_UI
441 virtual bool openDateTimeChooser(const blink::WebDateTimeChooserParams&,
442 blink::WebDateTimeChooserCompletion*);
443 virtual void didScrollWithKeyboard(const blink::WebSize& delta);
444 #endif
446 // blink::WebPageSerializerClient implementation ----------------------------
448 virtual void didSerializeDataForFrame(
449 const blink::WebURL& frame_url,
450 const blink::WebCString& data,
451 PageSerializationStatus status) OVERRIDE;
453 // RenderView implementation -------------------------------------------------
455 virtual bool Send(IPC::Message* message) OVERRIDE;
456 virtual RenderFrameImpl* GetMainRenderFrame() OVERRIDE;
457 virtual int GetRoutingID() const OVERRIDE;
458 virtual gfx::Size GetSize() const OVERRIDE;
459 virtual WebPreferences& GetWebkitPreferences() OVERRIDE;
460 virtual void SetWebkitPreferences(const WebPreferences& preferences) OVERRIDE;
461 virtual blink::WebView* GetWebView() OVERRIDE;
462 virtual blink::WebElement GetFocusedElement() const OVERRIDE;
463 virtual bool IsEditableNode(const blink::WebNode& node) const OVERRIDE;
464 virtual bool NodeContainsPoint(const blink::WebNode& node,
465 const gfx::Point& point) const OVERRIDE;
466 virtual bool ShouldDisplayScrollbars(int width, int height) const OVERRIDE;
467 virtual int GetEnabledBindings() const OVERRIDE;
468 virtual bool GetContentStateImmediately() const OVERRIDE;
469 virtual blink::WebPageVisibilityState GetVisibilityState() const OVERRIDE;
470 virtual void DidStartLoading() OVERRIDE;
471 virtual void DidStopLoading() OVERRIDE;
472 virtual void Repaint(const gfx::Size& size) OVERRIDE;
473 virtual void SetEditCommandForNextKeyEvent(const std::string& name,
474 const std::string& value) OVERRIDE;
475 virtual void ClearEditCommands() OVERRIDE;
476 virtual SSLStatus GetSSLStatusOfFrame(blink::WebFrame* frame) const OVERRIDE;
477 virtual const std::string& GetAcceptLanguages() const OVERRIDE;
478 #if defined(OS_ANDROID)
479 virtual void UpdateTopControlsState(TopControlsState constraints,
480 TopControlsState current,
481 bool animate) OVERRIDE;
482 #endif
483 bool uses_temporary_zoom_level() const { return uses_temporary_zoom_level_; }
485 // Please do not add your stuff randomly to the end here. If there is an
486 // appropriate section, add it there. If not, there are some random functions
487 // nearer to the top you can add it to.
489 // Cannot use std::set unfortunately since linked_ptr<> does not support
490 // operator<.
491 typedef std::vector<linked_ptr<ImageResourceFetcher> >
492 ImageResourceFetcherList;
494 protected:
495 // RenderWidget overrides:
496 virtual void OnClose() OVERRIDE;
497 virtual void Close() OVERRIDE;
498 virtual void OnResize(const ViewMsg_Resize_Params& params) OVERRIDE;
499 virtual void DidInitiatePaint() OVERRIDE;
500 virtual void DidFlushPaint() OVERRIDE;
501 virtual gfx::Vector2d GetScrollOffset() OVERRIDE;
502 virtual void DidHandleKeyEvent() OVERRIDE;
503 virtual bool WillHandleMouseEvent(
504 const blink::WebMouseEvent& event) OVERRIDE;
505 virtual bool WillHandleGestureEvent(
506 const blink::WebGestureEvent& event) OVERRIDE;
507 virtual void DidHandleMouseEvent(const blink::WebMouseEvent& event) OVERRIDE;
508 virtual void DidHandleTouchEvent(const blink::WebTouchEvent& event) OVERRIDE;
509 virtual bool HasTouchEventHandlersAt(const gfx::Point& point) const OVERRIDE;
510 virtual void OnSetFocus(bool enable) OVERRIDE;
511 virtual void OnWasHidden() OVERRIDE;
512 virtual void OnWasShown(bool needs_repainting,
513 const ui::LatencyInfo& latency_info) OVERRIDE;
514 virtual GURL GetURLForGraphicsContext3D() OVERRIDE;
515 virtual void OnImeSetComposition(
516 const base::string16& text,
517 const std::vector<blink::WebCompositionUnderline>& underlines,
518 int selection_start,
519 int selection_end) OVERRIDE;
520 virtual void OnImeConfirmComposition(const base::string16& text,
521 const gfx::Range& replacement_range,
522 bool keep_selection) OVERRIDE;
523 virtual void SetDeviceScaleFactor(float device_scale_factor) OVERRIDE;
524 virtual bool SetDeviceColorProfile(
525 const std::vector<char>& color_profile) OVERRIDE;
526 virtual void OnOrientationChange() OVERRIDE;
527 virtual ui::TextInputType GetTextInputType() OVERRIDE;
528 virtual void GetSelectionBounds(gfx::Rect* start, gfx::Rect* end) OVERRIDE;
529 #if defined(OS_MACOSX) || defined(USE_AURA)
530 virtual void GetCompositionCharacterBounds(
531 std::vector<gfx::Rect>* character_bounds) OVERRIDE;
532 virtual void GetCompositionRange(gfx::Range* range) OVERRIDE;
533 #endif
534 virtual bool CanComposeInline() OVERRIDE;
535 virtual void DidCommitCompositorFrame() OVERRIDE;
536 virtual void InstrumentWillBeginFrame(int frame_id) OVERRIDE;
537 virtual void InstrumentDidBeginFrame() OVERRIDE;
538 virtual void InstrumentDidCancelFrame() OVERRIDE;
539 virtual void InstrumentWillComposite() OVERRIDE;
541 protected:
542 explicit RenderViewImpl(RenderViewImplParams* params);
544 void Initialize(RenderViewImplParams* params);
545 virtual void SetScreenMetricsEmulationParameters(
546 float device_scale_factor,
547 const gfx::Point& root_layer_offset,
548 float root_layer_scale) OVERRIDE;
550 // Do not delete directly. This class is reference counted.
551 virtual ~RenderViewImpl();
553 private:
554 // For unit tests.
555 friend class PepperDeviceTest;
556 friend class RenderViewImplTest;
557 friend class RenderViewTest;
558 friend class RendererAccessibilityTest;
560 // TODO(nasko): Temporarily friend RenderFrameImpl, so we don't duplicate
561 // utility functions needed in both classes, while we move frame specific
562 // code away from this class.
563 friend class RenderFrameImpl;
565 FRIEND_TEST_ALL_PREFIXES(RenderViewImplTest, DecideNavigationPolicyForWebUI);
566 FRIEND_TEST_ALL_PREFIXES(RenderViewImplTest,
567 DidFailProvisionalLoadWithErrorForError);
568 FRIEND_TEST_ALL_PREFIXES(RenderViewImplTest,
569 DidFailProvisionalLoadWithErrorForCancellation);
570 FRIEND_TEST_ALL_PREFIXES(RenderViewImplTest,
571 DontIgnoreBackAfterNavEntryLimit);
572 FRIEND_TEST_ALL_PREFIXES(RenderViewImplTest, ImeComposition);
573 FRIEND_TEST_ALL_PREFIXES(RenderViewImplTest, InsertCharacters);
574 FRIEND_TEST_ALL_PREFIXES(RenderViewImplTest, JSBlockSentAfterPageLoad);
575 FRIEND_TEST_ALL_PREFIXES(RenderViewImplTest, LastCommittedUpdateState);
576 FRIEND_TEST_ALL_PREFIXES(RenderViewImplTest, OnHandleKeyboardEvent);
577 FRIEND_TEST_ALL_PREFIXES(RenderViewImplTest, OnImeTypeChanged);
578 FRIEND_TEST_ALL_PREFIXES(RenderViewImplTest, OnNavStateChanged);
579 FRIEND_TEST_ALL_PREFIXES(RenderViewImplTest, OnSetTextDirection);
580 FRIEND_TEST_ALL_PREFIXES(RenderViewImplTest, OnUpdateWebPreferences);
581 FRIEND_TEST_ALL_PREFIXES(RenderViewImplTest,
582 SetEditableSelectionAndComposition);
583 FRIEND_TEST_ALL_PREFIXES(RenderViewImplTest, StaleNavigationsIgnored);
584 FRIEND_TEST_ALL_PREFIXES(RenderViewImplTest, UpdateTargetURLWithInvalidURL);
585 FRIEND_TEST_ALL_PREFIXES(RenderViewImplTest,
586 GetCompositionCharacterBoundsTest);
587 FRIEND_TEST_ALL_PREFIXES(RenderViewImplTest, OnNavigationHttpPost);
588 FRIEND_TEST_ALL_PREFIXES(RenderViewImplTest,
589 DecideNavigationPolicyHandlesAllTopLevel);
590 #if defined(OS_MACOSX)
591 FRIEND_TEST_ALL_PREFIXES(RenderViewTest, MacTestCmdUp);
592 #endif
593 FRIEND_TEST_ALL_PREFIXES(RenderViewImplTest, SetHistoryLengthAndPrune);
594 FRIEND_TEST_ALL_PREFIXES(RenderViewImplTest, ZoomLimit);
595 FRIEND_TEST_ALL_PREFIXES(RenderViewImplTest, NavigateFrame);
596 FRIEND_TEST_ALL_PREFIXES(RenderViewImplTest, BasicRenderFrame);
597 FRIEND_TEST_ALL_PREFIXES(RenderViewImplTest, TextInputTypeWithPepper);
598 FRIEND_TEST_ALL_PREFIXES(RenderViewImplTest,
599 MessageOrderInDidChangeSelection);
600 FRIEND_TEST_ALL_PREFIXES(RenderViewImplTest, SendCandidateWindowEvents);
601 FRIEND_TEST_ALL_PREFIXES(SuppressErrorPageTest, Suppresses);
602 FRIEND_TEST_ALL_PREFIXES(SuppressErrorPageTest, DoesNotSuppress);
604 typedef std::map<GURL, double> HostZoomLevels;
606 enum ErrorPageType {
607 DNS_ERROR,
608 HTTP_404,
609 CONNECTION_ERROR,
612 // Old WebFrameClient implementations ----------------------------------------
614 // RenderViewImpl used to be a WebFrameClient, but now RenderFrameImpl is the
615 // WebFrameClient. However, many implementations of WebFrameClient methods
616 // still live here and are called from RenderFrameImpl. These implementations
617 // are to be moved to RenderFrameImpl <http://crbug.com/361761>.
619 void didCreateDataSource(blink::WebLocalFrame* frame,
620 blink::WebDataSource* datasource);
621 void didClearWindowObject(blink::WebLocalFrame* frame);
622 void didChangeIcon(blink::WebLocalFrame*, blink::WebIconURL::Type);
623 void didUpdateCurrentHistoryItem(blink::WebLocalFrame* frame);
624 void didChangeScrollOffset(blink::WebLocalFrame* frame);
626 static bool IsReload(const FrameMsg_Navigate_Params& params);
628 static Referrer GetReferrerFromRequest(
629 blink::WebFrame* frame,
630 const blink::WebURLRequest& request);
632 static WindowOpenDisposition NavigationPolicyToDisposition(
633 blink::WebNavigationPolicy policy);
635 void UpdateSessionHistory(blink::WebFrame* frame);
636 void SendUpdateState(HistoryEntry* entry);
638 // Sends a message and runs a nested message loop.
639 bool SendAndRunNestedMessageLoop(IPC::SyncMessage* message);
641 // IPC message handlers ------------------------------------------------------
643 // The documentation for these functions should be in
644 // content/common/*_messages.h for the message that the function is handling.
645 void OnExecuteEditCommand(const std::string& name, const std::string& value);
646 void OnMoveCaret(const gfx::Point& point);
647 void OnScrollFocusedEditableNodeIntoRect(const gfx::Rect& rect);
648 void OnSetEditCommandsForNextKeyEvent(const EditCommands& edit_commands);
649 void OnAllowBindings(int enabled_bindings_flags);
650 void OnAllowScriptToClose(bool script_can_close);
651 void OnCancelDownload(int32 download_id);
652 void OnClearFocusedElement();
653 void OnClosePage();
654 void OnShowContextMenu(ui::MenuSourceType source_type,
655 const gfx::Point& location);
656 void OnCopyImageAt(int x, int y);
657 void OnSaveImageAt(int x, int y);
658 void OnDeterminePageLanguage();
659 void OnDisableScrollbarsForSmallWindows(
660 const gfx::Size& disable_scrollbars_size_limit);
661 void OnDragSourceEnded(const gfx::Point& client_point,
662 const gfx::Point& screen_point,
663 blink::WebDragOperation drag_operation);
664 void OnDragSourceSystemDragEnded();
665 void OnDragTargetDrop(const gfx::Point& client_pt,
666 const gfx::Point& screen_pt,
667 int key_modifiers);
668 void OnDragTargetDragEnter(const DropData& drop_data,
669 const gfx::Point& client_pt,
670 const gfx::Point& screen_pt,
671 blink::WebDragOperationsMask operations_allowed,
672 int key_modifiers);
673 void OnDragTargetDragLeave();
674 void OnDragTargetDragOver(const gfx::Point& client_pt,
675 const gfx::Point& screen_pt,
676 blink::WebDragOperationsMask operations_allowed,
677 int key_modifiers);
678 void OnEnablePreferredSizeChangedMode();
679 void OnEnableAutoResize(const gfx::Size& min_size, const gfx::Size& max_size);
680 void OnDisableAutoResize(const gfx::Size& new_size);
681 void OnEnumerateDirectoryResponse(int id,
682 const std::vector<base::FilePath>& paths);
683 void OnFileChooserResponse(
684 const std::vector<ui::SelectedFileInfo>& files);
685 void OnFind(int request_id,
686 const base::string16&,
687 const blink::WebFindOptions&);
688 void OnGetAllSavableResourceLinksForCurrentPage(const GURL& page_url);
689 void OnGetSerializedHtmlDataForCurrentPageWithLocalLinks(
690 const std::vector<GURL>& links,
691 const std::vector<base::FilePath>& local_paths,
692 const base::FilePath& local_directory_name);
693 void OnMediaPlayerActionAt(const gfx::Point& location,
694 const blink::WebMediaPlayerAction& action);
695 void OnPluginActionAt(const gfx::Point& location,
696 const blink::WebPluginAction& action);
697 void OnMoveOrResizeStarted();
698 void OnPostMessageEvent(const ViewMsg_PostMessage_Params& params);
699 void OnReleaseDisambiguationPopupBitmap(const cc::SharedBitmapId& id);
700 void OnResetPageEncodingToDefault();
701 void OnSetActive(bool active);
702 void OnSetBackgroundOpaque(bool opaque);
703 void OnExitFullscreen();
704 void OnSetHistoryLengthAndPrune(int history_length, int32 minimum_page_id);
705 void OnSetInitialFocus(bool reverse);
706 void OnSetPageEncoding(const std::string& encoding_name);
707 void OnSetRendererPrefs(const RendererPreferences& renderer_prefs);
708 void OnSetWebUIProperty(const std::string& name, const std::string& value);
709 void OnSetZoomLevelForLoadingURL(const GURL& url, double zoom_level);
710 void OnSetZoomLevelForView(bool uses_temporary_zoom_level, double level);
711 void OnStopFinding(StopFindAction action);
712 void OnSuppressDialogsUntilSwapOut();
713 void OnThemeChanged();
714 void OnUpdateTargetURLAck();
715 void OnUpdateWebPreferences(const WebPreferences& prefs);
716 void OnZoom(PageZoom zoom);
717 void OnEnableViewSourceMode();
718 void OnWindowSnapshotCompleted(const int snapshot_id,
719 const gfx::Size& size, const std::vector<unsigned char>& png);
720 void OnForceRedraw(int request_id);
721 void OnSelectWordAroundCaret();
722 #if defined(OS_ANDROID)
723 void OnActivateNearestFindResult(int request_id, float x, float y);
724 void OnFindMatchRects(int current_version);
725 void OnUndoScrollFocusedEditableNodeIntoRect();
726 void OnUpdateTopControlsState(bool enable_hiding,
727 bool enable_showing,
728 bool animate);
729 void OnExtractSmartClipData(const gfx::Rect& rect);
730 #elif defined(OS_MACOSX)
731 void OnGetRenderedText();
732 void OnPluginImeCompositionCompleted(const base::string16& text,
733 int plugin_id);
734 void OnSetInLiveResize(bool in_live_resize);
735 void OnSetWindowVisibility(bool visible);
736 void OnWindowFrameChanged(const gfx::Rect& window_frame,
737 const gfx::Rect& view_frame);
738 #endif
740 // Adding a new message handler? Please add it in alphabetical order above
741 // and put it in the same position in the .cc file.
743 // Misc private functions ----------------------------------------------------
744 // Check whether the preferred size has changed.
745 void CheckPreferredSize();
747 // Called to get the WebPlugin to handle find requests in the document.
748 // Returns NULL if there is no such WebPlugin.
749 blink::WebPlugin* GetWebPluginForFind();
751 // Returns true if the |params| navigation is to an entry that has been
752 // cropped due to a recent navigation the browser did not know about.
753 bool IsBackForwardToStaleEntry(const FrameMsg_Navigate_Params& params,
754 bool is_reload);
756 // Make the given |frame| show an empty, unscriptable page.
757 // TODO(creis): Move this to RenderFrame.
758 void NavigateToSwappedOutURL(blink::WebFrame* frame);
760 // If we initiated a navigation, this function will populate |document_state|
761 // with the navigation information saved in OnNavigate().
762 void PopulateDocumentStateFromPending(DocumentState* document_state);
764 // Returns a new NavigationState populated with the navigation information
765 // saved in OnNavigate().
766 NavigationState* CreateNavigationStateFromPending();
768 // Processes the command-line flags --enable-viewport,
769 // --enable-fixed-layout[=w,h] and --enable-pinch.
770 void ProcessViewLayoutFlags(const base::CommandLine& command_line);
772 #if defined(OS_ANDROID)
773 // Launch an Android content intent with the given URL.
774 void LaunchAndroidContentIntent(const GURL& intent_url, size_t request_id);
775 #endif
777 // Sends a reply to the current find operation handling if it was a
778 // synchronous find request.
779 void SendFindReply(int request_id,
780 int match_count,
781 int ordinal,
782 const blink::WebRect& selection_rect,
783 bool final_status_update);
785 // Starts nav_state_sync_timer_ if it isn't already running.
786 void StartNavStateSyncTimerIfNecessary();
788 #if defined(OS_POSIX) && !defined(OS_MACOSX)
789 void UpdateFontRenderingFromRendererPrefs();
790 #else
791 void UpdateFontRenderingFromRendererPrefs() {}
792 #endif
794 // Update the target url and tell the browser that the target URL has changed.
795 // If |url| is empty, show |fallback_url|.
796 void UpdateTargetURL(const GURL& url, const GURL& fallback_url);
798 // Tells the browser what the new list of favicons for the webpage is.
799 void SendUpdateFaviconURL(const std::vector<FaviconURL>& urls);
801 // Invoked from DidStopLoading(). Sends the current list of loaded favicons to
802 // the browser.
803 void DidStopLoadingIcons();
805 // Coordinate conversion -----------------------------------------------------
807 gfx::RectF ClientRectToPhysicalWindowRect(const gfx::RectF& rect) const;
809 // RenderFrameImpl accessible state ------------------------------------------
810 // The following section is the set of methods that RenderFrameImpl needs
811 // to access RenderViewImpl state. The set of state variables are page-level
812 // specific, so they don't belong in RenderFrameImpl and should remain in
813 // this object.
814 ObserverList<RenderViewObserver>& observers() {
815 return observers_;
818 // TODO(nasko): Remove this method when we move to frame proxy objects, since
819 // the concept of swapped out will be eliminated.
820 void set_is_swapped_out(bool swapped_out) {
821 is_swapped_out_ = swapped_out;
824 NavigationGesture navigation_gesture() {
825 return navigation_gesture_;
827 void set_navigation_gesture(NavigationGesture gesture) {
828 navigation_gesture_ = gesture;
831 // ---------------------------------------------------------------------------
832 // ADDING NEW FUNCTIONS? Please keep private functions alphabetized and put
833 // it in the same order in the .cc file as it was in the header.
834 // ---------------------------------------------------------------------------
836 // Settings ------------------------------------------------------------------
838 WebPreferences webkit_preferences_;
839 RendererPreferences renderer_preferences_;
841 HostZoomLevels host_zoom_levels_;
843 // Whether content state (such as form state, scroll position and page
844 // contents) should be sent to the browser immediately. This is normally
845 // false, but set to true by some tests.
846 bool send_content_state_immediately_;
848 // Bitwise-ORed set of extra bindings that have been enabled. See
849 // BindingsPolicy for details.
850 int enabled_bindings_;
852 // If true, we send IPC messages when |preferred_size_| changes.
853 bool send_preferred_size_changes_;
855 // If non-empty, and |send_preferred_size_changes_| is true, disable drawing
856 // scroll bars on windows smaller than this size. Used for windows that the
857 // browser resizes to the size of the content, such as browser action popups.
858 // If a render view is set to the minimum size of its content, webkit may add
859 // scroll bars. This makes sense for fixed sized windows, but it does not
860 // make sense when the size of the view was chosen to fit the content.
861 // This setting ensures that no scroll bars are drawn. The size limit exists
862 // because if the view grows beyond a size known to the browser, scroll bars
863 // should be drawn.
864 gfx::Size disable_scrollbars_size_limit_;
866 // Loading state -------------------------------------------------------------
868 // The gesture that initiated the current navigation.
869 // TODO(nasko): Move to RenderFrame, as this is per-frame state.
870 NavigationGesture navigation_gesture_;
872 // Used for popups.
873 bool opened_by_user_gesture_;
875 // Whether this RenderView was created by a frame that was suppressing its
876 // opener. If so, we may want to load pages in a separate process. See
877 // decidePolicyForNavigation for details.
878 bool opener_suppressed_;
880 // Whether we must stop creating nested message loops for modal dialogs until
881 // OnSwapOut is called. This is necessary because modal dialogs have a
882 // PageGroupLoadDeferrer on the stack that interferes with swapping out.
883 bool suppress_dialogs_until_swap_out_;
885 // Holds state pertaining to a navigation that we initiated. This is held by
886 // the WebDataSource::ExtraData attribute. We use pending_navigation_state_
887 // as a temporary holder for the state until the WebDataSource corresponding
888 // to the new navigation is created. See DidCreateDataSource.
889 // TODO(nasko): Move to RenderFrame, as this is per-frame state.
890 scoped_ptr<FrameMsg_Navigate_Params> pending_navigation_params_;
892 // Timer used to delay the updating of nav state (see SyncNavigationState).
893 base::OneShotTimer<RenderViewImpl> nav_state_sync_timer_;
895 // Page IDs ------------------------------------------------------------------
896 // See documentation in RenderView.
897 int32 page_id_;
899 // Indicates the ID of the last page that we sent a FrameNavigate to the
900 // browser for. This is used to determine if the most recent transition
901 // generated a history entry (less than page_id_), or not (equal to or
902 // greater than). Note that this will be greater than page_id_ if the user
903 // goes back.
904 int32 last_page_id_sent_to_browser_;
906 // The next available page ID to use for this RenderView. These IDs are
907 // specific to a given RenderView and the frames within it.
908 int32 next_page_id_;
910 // The offset of the current item in the history list.
911 int history_list_offset_;
913 // The RenderView's current impression of the history length. This includes
914 // any items that have committed in this process, but because of cross-process
915 // navigations, the history may have some entries that were committed in other
916 // processes. We won't know about them until the next navigation in this
917 // process.
918 int history_list_length_;
920 // Counter to track how many frames have sent start notifications but not stop
921 // notifications. TODO(avi): Remove this once DidStartLoading/DidStopLoading
922 // are gone.
923 int frames_in_progress_;
925 // The list of page IDs for each history item this RenderView knows about.
926 // Some entries may be -1 if they were rendered by other processes or were
927 // restored from a previous session. This lets us detect attempts to
928 // navigate to stale entries that have been cropped from our history.
929 std::vector<int32> history_page_ids_;
931 // UI state ------------------------------------------------------------------
933 // The state of our target_url transmissions. When we receive a request to
934 // send a URL to the browser, we set this to TARGET_INFLIGHT until an ACK
935 // comes back - if a new request comes in before the ACK, we store the new
936 // URL in pending_target_url_ and set the status to TARGET_PENDING. If an
937 // ACK comes back and we are in TARGET_PENDING, we send the stored URL and
938 // revert to TARGET_INFLIGHT.
940 // We don't need a queue of URLs to send, as only the latest is useful.
941 enum {
942 TARGET_NONE,
943 TARGET_INFLIGHT, // We have a request in-flight, waiting for an ACK
944 TARGET_PENDING // INFLIGHT + we have a URL waiting to be sent
945 } target_url_status_;
947 // The URL we show the user in the status bar. We use this to determine if we
948 // want to send a new one (we do not need to send duplicates). It will be
949 // equal to either |mouse_over_url_| or |focus_url_|, depending on which was
950 // updated last.
951 GURL target_url_;
953 // The URL the user's mouse is hovering over.
954 GURL mouse_over_url_;
956 // The URL that has keyboard focus.
957 GURL focus_url_;
959 // The next target URL we want to send to the browser.
960 GURL pending_target_url_;
962 // Indicates whether this view overrides url-based zoom settings.
963 bool uses_temporary_zoom_level_;
965 #if defined(OS_ANDROID)
966 // Cache the old top controls state constraints. Used when updating
967 // current value only without altering the constraints.
968 cc::TopControlsState top_controls_constraints_;
969 #endif
971 // View ----------------------------------------------------------------------
973 // Cache the preferred size of the page in order to prevent sending the IPC
974 // when layout() recomputes but doesn't actually change sizes.
975 gfx::Size preferred_size_;
977 // Used to delay determining the preferred size (to avoid intermediate
978 // states for the sizes).
979 base::OneShotTimer<RenderViewImpl> check_preferred_size_timer_;
981 // Bookkeeping to suppress redundant scroll and focus requests for an already
982 // scrolled and focused editable node.
983 bool has_scrolled_focused_editable_node_into_rect_;
984 gfx::Rect rect_for_scrolled_focused_editable_node_;
986 // Helper objects ------------------------------------------------------------
988 scoped_ptr<RenderFrameImpl> main_render_frame_;
990 // The next group of objects all implement RenderViewObserver, so are deleted
991 // along with the RenderView automatically. This is why we just store
992 // weak references.
994 // The speech recognition dispatcher attached to this view, lazily
995 // initialized.
996 SpeechRecognitionDispatcher* speech_recognition_dispatcher_;
998 // BrowserPluginManager attached to this view; lazily initialized.
999 scoped_refptr<BrowserPluginManager> browser_plugin_manager_;
1001 DevToolsAgent* devtools_agent_;
1003 // Mouse Lock dispatcher attached to this view.
1004 MouseLockDispatcher* mouse_lock_dispatcher_;
1006 scoped_ptr<HistoryController> history_controller_;
1008 #if defined(OS_ANDROID)
1009 // Android Specific ---------------------------------------------------------
1011 // Expected id of the next content intent launched. Used to prevent scheduled
1012 // intents to be launched if aborted.
1013 size_t expected_content_intent_id_;
1015 // List of click-based content detectors.
1016 typedef std::vector< linked_ptr<ContentDetector> > ContentDetectorList;
1017 ContentDetectorList content_detectors_;
1019 // A date/time picker object for date and time related input elements.
1020 scoped_ptr<RendererDateTimePicker> date_time_picker_client_;
1021 #endif
1023 // Plugins -------------------------------------------------------------------
1025 // All the currently active plugin delegates for this RenderView; kept so
1026 // that we can enumerate them to send updates about things like window
1027 // location or tab focus and visibily. These are non-owning references.
1028 std::set<WebPluginDelegateProxy*> plugin_delegates_;
1030 #if defined(OS_WIN)
1031 // The ID of the focused NPAPI plug-in.
1032 int focused_plugin_id_;
1033 #endif
1035 #if defined(ENABLE_PLUGINS)
1036 PepperPluginInstanceImpl* plugin_find_handler_;
1038 typedef std::set<PepperPluginInstanceImpl*> PepperPluginSet;
1039 PepperPluginSet active_pepper_instances_;
1041 // TODO(jam): these belong on RenderFrame, once the browser knows which frame
1042 // is focused and sends the IPCs which use these to the correct frame. Until
1043 // then, we must store these on RenderView as that's the one place that knows
1044 // about all the RenderFrames for a page.
1046 // Whether or not the focus is on a PPAPI plugin
1047 PepperPluginInstanceImpl* focused_pepper_plugin_;
1049 // The plugin instance that received the last mouse event. It is set to NULL
1050 // if the last mouse event went to elements other than Pepper plugins.
1051 // |pepper_last_mouse_event_target_| is not owned by this class. We depend on
1052 // the RenderFrameImpl to NULL it out when it destructs.
1053 PepperPluginInstanceImpl* pepper_last_mouse_event_target_;
1054 #endif
1056 // Misc ----------------------------------------------------------------------
1058 // The current and pending file chooser completion objects. If the queue is
1059 // nonempty, the first item represents the currently running file chooser
1060 // callback, and the remaining elements are the other file chooser completion
1061 // still waiting to be run (in order).
1062 struct PendingFileChooser;
1063 std::deque< linked_ptr<PendingFileChooser> > file_chooser_completions_;
1065 // The current directory enumeration callback
1066 std::map<int, blink::WebFileChooserCompletion*> enumeration_completions_;
1067 int enumeration_completion_id_;
1069 // The SessionStorage namespace that we're assigned to has an ID, and that ID
1070 // is passed to us upon creation. WebKit asks for this ID upon first use and
1071 // uses it whenever asking the browser process to allocate new storage areas.
1072 int64 session_storage_namespace_id_;
1074 // Stores edit commands associated to the next key event.
1075 // Shall be cleared as soon as the next key event is processed.
1076 EditCommands edit_commands_;
1078 // All the registered observers. We expect this list to be small, so vector
1079 // is fine.
1080 ObserverList<RenderViewObserver> observers_;
1082 // Wraps the |webwidget_| as a MouseLockDispatcher::LockTarget interface.
1083 scoped_ptr<MouseLockDispatcher::LockTarget> webwidget_mouse_lock_target_;
1085 // State associated with the GetWindowSnapshot function.
1086 int next_snapshot_id_;
1087 typedef std::map<int, WindowSnapshotCallback> PendingSnapshotMap;
1088 PendingSnapshotMap pending_snapshots_;
1090 // This field stores drag/drop related info for the event that is currently
1091 // being handled. If the current event results in starting a drag/drop
1092 // session, this info is sent to the browser along with other drag/drop info.
1093 DragEventSourceInfo possible_drag_event_info_;
1095 // NOTE: stats_collection_observer_ should be the last members because their
1096 // constructors call the AddObservers method of RenderViewImpl.
1097 scoped_ptr<StatsCollectionObserver> stats_collection_observer_;
1099 typedef std::map<cc::SharedBitmapId, cc::SharedBitmap*> BitmapMap;
1100 BitmapMap disambiguation_bitmaps_;
1102 // ---------------------------------------------------------------------------
1103 // ADDING NEW DATA? Please see if it fits appropriately in one of the above
1104 // sections rather than throwing it randomly at the end. If you're adding a
1105 // bunch of stuff, you should probably create a helper class and put your
1106 // data and methods on that to avoid bloating RenderView more. You can
1107 // use the Observer interface to filter IPC messages and receive frame change
1108 // notifications.
1109 // ---------------------------------------------------------------------------
1111 DISALLOW_COPY_AND_ASSIGN(RenderViewImpl);
1114 } // namespace content
1116 #endif // CONTENT_RENDERER_RENDER_VIEW_IMPL_H_