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

Side by Side Diff: content/renderer/render_view_impl.h

Issue 689163002: Clean up the page state saving mechanism. (Closed) Base URL: https://chromium.googlesource.com/chromium/src.git@master
Patch Set: Created 6 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
OLDNEW
1 // Copyright (c) 2012 The Chromium Authors. All rights reserved. 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 2 // Use of this source code is governed by a BSD-style license that can be
3 // found in the LICENSE file. 3 // found in the LICENSE file.
4 4
5 #ifndef CONTENT_RENDERER_RENDER_VIEW_IMPL_H_ 5 #ifndef CONTENT_RENDERER_RENDER_VIEW_IMPL_H_
6 #define CONTENT_RENDERER_RENDER_VIEW_IMPL_H_ 6 #define CONTENT_RENDERER_RENDER_VIEW_IMPL_H_
7 7
8 #include <deque> 8 #include <deque>
9 #include <map> 9 #include <map>
10 #include <set> 10 #include <set>
(...skipping 188 matching lines...) Expand 10 before | Expand all | Expand 10 after
199 int history_list_offset() const { return history_list_offset_; } 199 int history_list_offset() const { return history_list_offset_; }
200 200
201 const WebPreferences& webkit_preferences() const { 201 const WebPreferences& webkit_preferences() const {
202 return webkit_preferences_; 202 return webkit_preferences_;
203 } 203 }
204 204
205 const RendererPreferences& renderer_preferences() const { 205 const RendererPreferences& renderer_preferences() const {
206 return renderer_preferences_; 206 return renderer_preferences_;
207 } 207 }
208 208
209 void set_send_content_state_immediately(bool value) { 209 void set_page_state_sent_immediately(bool value) {
210 send_content_state_immediately_ = value; 210 page_state_sent_immediately_ = value;
211 } 211 }
212 212
213 MouseLockDispatcher* mouse_lock_dispatcher() { 213 MouseLockDispatcher* mouse_lock_dispatcher() {
214 return mouse_lock_dispatcher_; 214 return mouse_lock_dispatcher_;
215 } 215 }
216 216
217 HistoryController* history_controller() { 217 HistoryController* history_controller() {
218 return history_controller_.get(); 218 return history_controller_.get();
219 } 219 }
220 220
(...skipping 82 matching lines...) Expand 10 before | Expand all | Expand 10 after
303 // supported PPAPI plug-ins. 303 // supported PPAPI plug-ins.
304 bool HasIMETextFocus(); 304 bool HasIMETextFocus();
305 305
306 // Callback for use with GetWindowSnapshot. 306 // Callback for use with GetWindowSnapshot.
307 typedef base::Callback<void( 307 typedef base::Callback<void(
308 const gfx::Size&, const std::vector<unsigned char>&)> 308 const gfx::Size&, const std::vector<unsigned char>&)>
309 WindowSnapshotCallback; 309 WindowSnapshotCallback;
310 310
311 void GetWindowSnapshot(const WindowSnapshotCallback& callback); 311 void GetWindowSnapshot(const WindowSnapshotCallback& callback);
312 312
313 // Dispatches the current navigation state to the browser. Called on a 313 // Forces the current page state to be flushed to the browser.
314 // periodic timer so we don't send too many messages. 314 void ForcePageStateFlushForTesting();
315 void SyncNavigationState();
316 315
317 // Returns the length of the session history of this RenderView. Note that 316 // Returns the length of the session history of this RenderView. Note that
318 // this only coincides with the actual length of the session history if this 317 // this only coincides with the actual length of the session history if this
319 // RenderView is the currently active RenderView of a WebContents. 318 // RenderView is the currently active RenderView of a WebContents.
320 unsigned GetLocalSessionHistoryLengthForTesting() const; 319 unsigned GetLocalSessionHistoryLengthForTesting() const;
321 320
322 // Invokes OnSetFocus and marks the widget as active depending on the value 321 // Invokes OnSetFocus and marks the widget as active depending on the value
323 // of |enable|. This is used for layout tests that need to control the focus 322 // of |enable|. This is used for layout tests that need to control the focus
324 // synchronously from the renderer. 323 // synchronously from the renderer.
325 void SetFocusAndActivateForTesting(bool enable); 324 void SetFocusAndActivateForTesting(bool enable);
(...skipping 132 matching lines...) Expand 10 before | Expand all | Expand 10 after
458 gfx::Size GetSize() const override; 457 gfx::Size GetSize() const override;
459 WebPreferences& GetWebkitPreferences() override; 458 WebPreferences& GetWebkitPreferences() override;
460 void SetWebkitPreferences(const WebPreferences& preferences) override; 459 void SetWebkitPreferences(const WebPreferences& preferences) override;
461 blink::WebView* GetWebView() override; 460 blink::WebView* GetWebView() override;
462 blink::WebElement GetFocusedElement() const override; 461 blink::WebElement GetFocusedElement() const override;
463 bool IsEditableNode(const blink::WebNode& node) const override; 462 bool IsEditableNode(const blink::WebNode& node) const override;
464 bool NodeContainsPoint(const blink::WebNode& node, 463 bool NodeContainsPoint(const blink::WebNode& node,
465 const gfx::Point& point) const override; 464 const gfx::Point& point) const override;
466 bool ShouldDisplayScrollbars(int width, int height) const override; 465 bool ShouldDisplayScrollbars(int width, int height) const override;
467 int GetEnabledBindings() const override; 466 int GetEnabledBindings() const override;
468 bool GetContentStateImmediately() const override; 467 bool GetPageStateSentImmediately() const override;
469 blink::WebPageVisibilityState GetVisibilityState() const override; 468 blink::WebPageVisibilityState GetVisibilityState() const override;
470 void DidStartLoading() override; 469 void DidStartLoading() override;
471 void DidStopLoading() override; 470 void DidStopLoading() override;
472 void Repaint(const gfx::Size& size) override; 471 void Repaint(const gfx::Size& size) override;
473 void SetEditCommandForNextKeyEvent(const std::string& name, 472 void SetEditCommandForNextKeyEvent(const std::string& name,
474 const std::string& value) override; 473 const std::string& value) override;
475 void ClearEditCommands() override; 474 void ClearEditCommands() override;
476 SSLStatus GetSSLStatusOfFrame(blink::WebFrame* frame) const override; 475 SSLStatus GetSSLStatusOfFrame(blink::WebFrame* frame) const override;
477 const std::string& GetAcceptLanguages() const override; 476 const std::string& GetAcceptLanguages() const override;
478 #if defined(OS_ANDROID) 477 #if defined(OS_ANDROID)
(...skipping 142 matching lines...) Expand 10 before | Expand all | Expand 10 after
621 620
622 static bool IsReload(FrameMsg_Navigate_Type::Value navigation_type); 621 static bool IsReload(FrameMsg_Navigate_Type::Value navigation_type);
623 622
624 static Referrer GetReferrerFromRequest( 623 static Referrer GetReferrerFromRequest(
625 blink::WebFrame* frame, 624 blink::WebFrame* frame,
626 const blink::WebURLRequest& request); 625 const blink::WebURLRequest& request);
627 626
628 static WindowOpenDisposition NavigationPolicyToDisposition( 627 static WindowOpenDisposition NavigationPolicyToDisposition(
629 blink::WebNavigationPolicy policy); 628 blink::WebNavigationPolicy policy);
630 629
631 void UpdateSessionHistory(blink::WebFrame* frame);
632 void SendUpdateState(HistoryEntry* entry);
633
634 // Sends a message and runs a nested message loop. 630 // Sends a message and runs a nested message loop.
635 bool SendAndRunNestedMessageLoop(IPC::SyncMessage* message); 631 bool SendAndRunNestedMessageLoop(IPC::SyncMessage* message);
636 632
637 // IPC message handlers ------------------------------------------------------ 633 // IPC message handlers ------------------------------------------------------
638 // 634 //
639 // The documentation for these functions should be in 635 // The documentation for these functions should be in
640 // content/common/*_messages.h for the message that the function is handling. 636 // content/common/*_messages.h for the message that the function is handling.
641 void OnExecuteEditCommand(const std::string& name, const std::string& value); 637 void OnExecuteEditCommand(const std::string& name, const std::string& value);
642 void OnMoveCaret(const gfx::Point& point); 638 void OnMoveCaret(const gfx::Point& point);
643 void OnScrollFocusedEditableNodeIntoRect(const gfx::Rect& rect); 639 void OnScrollFocusedEditableNodeIntoRect(const gfx::Rect& rect);
(...skipping 129 matching lines...) Expand 10 before | Expand all | Expand 10 after
773 #endif 769 #endif
774 770
775 // Sends a reply to the current find operation handling if it was a 771 // Sends a reply to the current find operation handling if it was a
776 // synchronous find request. 772 // synchronous find request.
777 void SendFindReply(int request_id, 773 void SendFindReply(int request_id,
778 int match_count, 774 int match_count,
779 int ordinal, 775 int ordinal,
780 const blink::WebRect& selection_rect, 776 const blink::WebRect& selection_rect,
781 bool final_status_update); 777 bool final_status_update);
782 778
783 // Starts nav_state_sync_timer_ if it isn't already running. 779 // Marks the page state as being changed and in need of being sent to the
784 void StartNavStateSyncTimerIfNecessary(); 780 // browser. (It will be send on a delay, but that doesn't concern callers.)
Charlie Reis 2014/10/31 21:38:49 nit: send -> sent
Avi (use Gerrit) 2014/10/31 22:11:12 Done.
781 void MarkPageStateAsDirty();
782
783 // If there is a pending page state update that hasn't yet been sent to the
784 // browser, send it to the browser.
785 void FlushPageState();
785 786
786 #if defined(OS_POSIX) && !defined(OS_MACOSX) 787 #if defined(OS_POSIX) && !defined(OS_MACOSX)
787 void UpdateFontRenderingFromRendererPrefs(); 788 void UpdateFontRenderingFromRendererPrefs();
788 #else 789 #else
789 void UpdateFontRenderingFromRendererPrefs() {} 790 void UpdateFontRenderingFromRendererPrefs() {}
790 #endif 791 #endif
791 792
792 // Update the target url and tell the browser that the target URL has changed. 793 // Update the target url and tell the browser that the target URL has changed.
793 // If |url| is empty, show |fallback_url|. 794 // If |url| is empty, show |fallback_url|.
794 void UpdateTargetURL(const GURL& url, const GURL& fallback_url); 795 void UpdateTargetURL(const GURL& url, const GURL& fallback_url);
(...skipping 36 matching lines...) Expand 10 before | Expand all | Expand 10 after
831 // it in the same order in the .cc file as it was in the header. 832 // it in the same order in the .cc file as it was in the header.
832 // --------------------------------------------------------------------------- 833 // ---------------------------------------------------------------------------
833 834
834 // Settings ------------------------------------------------------------------ 835 // Settings ------------------------------------------------------------------
835 836
836 WebPreferences webkit_preferences_; 837 WebPreferences webkit_preferences_;
837 RendererPreferences renderer_preferences_; 838 RendererPreferences renderer_preferences_;
838 839
839 HostZoomLevels host_zoom_levels_; 840 HostZoomLevels host_zoom_levels_;
840 841
841 // Whether content state (such as form state, scroll position and page
842 // contents) should be sent to the browser immediately. This is normally
843 // false, but set to true by some tests.
844 bool send_content_state_immediately_;
845
846 // Bitwise-ORed set of extra bindings that have been enabled. See 842 // Bitwise-ORed set of extra bindings that have been enabled. See
847 // BindingsPolicy for details. 843 // BindingsPolicy for details.
848 int enabled_bindings_; 844 int enabled_bindings_;
849 845
850 // If true, we send IPC messages when |preferred_size_| changes. 846 // If true, we send IPC messages when |preferred_size_| changes.
851 bool send_preferred_size_changes_; 847 bool send_preferred_size_changes_;
852 848
853 // If non-empty, and |send_preferred_size_changes_| is true, disable drawing 849 // If non-empty, and |send_preferred_size_changes_| is true, disable drawing
854 // scroll bars on windows smaller than this size. Used for windows that the 850 // scroll bars on windows smaller than this size. Used for windows that the
855 // browser resizes to the size of the content, such as browser action popups. 851 // browser resizes to the size of the content, such as browser action popups.
(...skipping 24 matching lines...) Expand all
880 // PageGroupLoadDeferrer on the stack that interferes with swapping out. 876 // PageGroupLoadDeferrer on the stack that interferes with swapping out.
881 bool suppress_dialogs_until_swap_out_; 877 bool suppress_dialogs_until_swap_out_;
882 878
883 // Holds state pertaining to a navigation that we initiated. This is held by 879 // Holds state pertaining to a navigation that we initiated. This is held by
884 // the WebDataSource::ExtraData attribute. We use pending_navigation_state_ 880 // the WebDataSource::ExtraData attribute. We use pending_navigation_state_
885 // as a temporary holder for the state until the WebDataSource corresponding 881 // as a temporary holder for the state until the WebDataSource corresponding
886 // to the new navigation is created. See DidCreateDataSource. 882 // to the new navigation is created. See DidCreateDataSource.
887 // TODO(nasko): Move to RenderFrame, as this is per-frame state. 883 // TODO(nasko): Move to RenderFrame, as this is per-frame state.
888 scoped_ptr<FrameMsg_Navigate_Params> pending_navigation_params_; 884 scoped_ptr<FrameMsg_Navigate_Params> pending_navigation_params_;
889 885
890 // Timer used to delay the updating of nav state (see SyncNavigationState). 886 // Whether the page state (such as form state, scroll position and page
891 base::OneShotTimer<RenderViewImpl> nav_state_sync_timer_; 887 // contents) should be sent to the browser immediately. This is normally
888 // false, but is set to true by some tests.
889 bool page_state_sent_immediately_;
890
891 // Whether the page state is dirty (meaning that the browser does not have an
892 // up-to-date copy).
893 bool page_state_dirty_;
894
895 // Timer used to delay the sending of the page state (see
896 // MarkPageStateAsDirty).
897 base::OneShotTimer<RenderViewImpl> page_state_timer_;
892 898
893 // Page IDs ------------------------------------------------------------------ 899 // Page IDs ------------------------------------------------------------------
894 // See documentation in RenderView. 900 // See documentation in RenderView.
895 int32 page_id_; 901 int32 page_id_;
896 902
897 // Indicates the ID of the last page that we sent a FrameNavigate to the 903 // Indicates the ID of the last page that we sent a FrameNavigate to the
898 // browser for. This is used to determine if the most recent transition 904 // browser for. This is used to determine if the most recent transition
899 // generated a history entry (less than page_id_), or not (equal to or 905 // generated a history entry (less than page_id_), or not (equal to or
900 // greater than). Note that this will be greater than page_id_ if the user 906 // greater than). Note that this will be greater than page_id_ if the user
901 // goes back. 907 // goes back.
(...skipping 203 matching lines...) Expand 10 before | Expand all | Expand 10 after
1105 // use the Observer interface to filter IPC messages and receive frame change 1111 // use the Observer interface to filter IPC messages and receive frame change
1106 // notifications. 1112 // notifications.
1107 // --------------------------------------------------------------------------- 1113 // ---------------------------------------------------------------------------
1108 1114
1109 DISALLOW_COPY_AND_ASSIGN(RenderViewImpl); 1115 DISALLOW_COPY_AND_ASSIGN(RenderViewImpl);
1110 }; 1116 };
1111 1117
1112 } // namespace content 1118 } // namespace content
1113 1119
1114 #endif // CONTENT_RENDERER_RENDER_VIEW_IMPL_H_ 1120 #endif // CONTENT_RENDERER_RENDER_VIEW_IMPL_H_
OLDNEW

Powered by Google App Engine
This is Rietveld 408576698