clamy | 5f34220 | 2015-03-18 13:47:56 | [diff] [blame] | 1 | // Copyright 2015 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 CONTENT_RENDERER_NAVIGATION_STATE_IMPL_H_ |
| 6 | #define CONTENT_RENDERER_NAVIGATION_STATE_IMPL_H_ |
| 7 | |
| 8 | #include <string> |
| 9 | |
avi | 1023d01 | 2015-12-25 02:39:14 | [diff] [blame] | 10 | #include "base/macros.h" |
clamy | 5f34220 | 2015-03-18 13:47:56 | [diff] [blame] | 11 | #include "content/common/navigation_params.h" |
| 12 | #include "content/public/renderer/navigation_state.h" |
| 13 | |
| 14 | namespace content { |
| 15 | |
| 16 | class CONTENT_EXPORT NavigationStateImpl : public NavigationState { |
| 17 | public: |
| 18 | ~NavigationStateImpl() override; |
| 19 | |
| 20 | static NavigationStateImpl* CreateBrowserInitiated( |
| 21 | const CommonNavigationParams& common_params, |
arthursonzogni | 2dbfc509 | 2018-02-27 20:42:09 | [diff] [blame^] | 22 | const RequestNavigationParams& request_params, |
| 23 | base::TimeTicks time_commit_requested); |
clamy | 5f34220 | 2015-03-18 13:47:56 | [diff] [blame] | 24 | |
| 25 | static NavigationStateImpl* CreateContentInitiated(); |
| 26 | |
| 27 | // NavigationState implementation. |
| 28 | ui::PageTransition GetTransitionType() override; |
eugenebut | cf731b5 | 2017-03-17 17:36:34 | [diff] [blame] | 29 | bool WasWithinSameDocument() override; |
clamy | 5f34220 | 2015-03-18 13:47:56 | [diff] [blame] | 30 | bool IsContentInitiated() override; |
| 31 | |
| 32 | const CommonNavigationParams& common_params() const { return common_params_; } |
clamy | 57b4b8e | 2015-03-24 13:32:11 | [diff] [blame] | 33 | const RequestNavigationParams& request_params() const { |
| 34 | return request_params_; |
clamy | 5f34220 | 2015-03-18 13:47:56 | [diff] [blame] | 35 | } |
| 36 | bool request_committed() const { return request_committed_; } |
| 37 | void set_request_committed(bool value) { request_committed_ = value; } |
eugenebut | cf731b5 | 2017-03-17 17:36:34 | [diff] [blame] | 38 | void set_was_within_same_document(bool value) { |
| 39 | was_within_same_document_ = value; |
| 40 | } |
clamy | 5f34220 | 2015-03-18 13:47:56 | [diff] [blame] | 41 | |
| 42 | void set_transition_type(ui::PageTransition transition) { |
| 43 | common_params_.transition = transition; |
| 44 | } |
| 45 | |
arthursonzogni | 2dbfc509 | 2018-02-27 20:42:09 | [diff] [blame^] | 46 | base::TimeTicks time_commit_requested() const { |
| 47 | return time_commit_requested_; |
| 48 | } |
| 49 | |
clamy | 5f34220 | 2015-03-18 13:47:56 | [diff] [blame] | 50 | private: |
| 51 | NavigationStateImpl(const CommonNavigationParams& common_params, |
clamy | 57b4b8e | 2015-03-24 13:32:11 | [diff] [blame] | 52 | const RequestNavigationParams& request_params, |
arthursonzogni | 2dbfc509 | 2018-02-27 20:42:09 | [diff] [blame^] | 53 | base::TimeTicks time_commit_requested, |
clamy | 5f34220 | 2015-03-18 13:47:56 | [diff] [blame] | 54 | bool is_content_initiated); |
| 55 | |
| 56 | bool request_committed_; |
eugenebut | cf731b5 | 2017-03-17 17:36:34 | [diff] [blame] | 57 | bool was_within_same_document_; |
clamy | 5f34220 | 2015-03-18 13:47:56 | [diff] [blame] | 58 | |
| 59 | // True if this navigation was not initiated via WebFrame::LoadRequest. |
| 60 | const bool is_content_initiated_; |
| 61 | |
| 62 | CommonNavigationParams common_params_; |
clamy | 5f34220 | 2015-03-18 13:47:56 | [diff] [blame] | 63 | |
| 64 | // Note: if IsContentInitiated() is false, whether this navigation should |
| 65 | // replace the current entry in the back/forward history list is determined by |
| 66 | // the should_replace_current_entry field in |history_params|. Otherwise, use |
| 67 | // replacesCurrentHistoryItem() on the WebDataSource. |
| 68 | // |
| 69 | // TODO(davidben): It would be good to unify these and have only one source |
| 70 | // for the two cases. We can plumb this through WebFrame::loadRequest to set |
| 71 | // lockBackForwardList on the FrameLoadRequest. However, this breaks process |
| 72 | // swaps because FrameLoader::loadWithNavigationAction treats loads before a |
| 73 | // FrameLoader has committedFirstRealDocumentLoad as a replacement. (Added for |
| 74 | // http://crbug.com/178380). |
clamy | 57b4b8e | 2015-03-24 13:32:11 | [diff] [blame] | 75 | const RequestNavigationParams request_params_; |
clamy | 5f34220 | 2015-03-18 13:47:56 | [diff] [blame] | 76 | |
arthursonzogni | 2dbfc509 | 2018-02-27 20:42:09 | [diff] [blame^] | 77 | // Time when RenderFrameImpl::CommitNavigation() is called. |
| 78 | base::TimeTicks time_commit_requested_; |
| 79 | |
clamy | 5f34220 | 2015-03-18 13:47:56 | [diff] [blame] | 80 | DISALLOW_COPY_AND_ASSIGN(NavigationStateImpl); |
| 81 | }; |
| 82 | |
| 83 | } // namespace content |
| 84 | |
| 85 | #endif // CONTENT_RENDERER_NAVIGATION_STATE_IMPL_H_ |