blob: 8f8f83cd5cef0a28b04c6fa0620ad1b68ddc1786 [file] [log] [blame]
clamy5f342202015-03-18 13:47:561// 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
avi1023d012015-12-25 02:39:1410#include "base/macros.h"
clamy5f342202015-03-18 13:47:5611#include "content/common/navigation_params.h"
12#include "content/public/renderer/navigation_state.h"
13
14namespace content {
15
16class CONTENT_EXPORT NavigationStateImpl : public NavigationState {
17 public:
18 ~NavigationStateImpl() override;
19
20 static NavigationStateImpl* CreateBrowserInitiated(
21 const CommonNavigationParams& common_params,
arthursonzogni2dbfc5092018-02-27 20:42:0922 const RequestNavigationParams& request_params,
23 base::TimeTicks time_commit_requested);
clamy5f342202015-03-18 13:47:5624
25 static NavigationStateImpl* CreateContentInitiated();
26
27 // NavigationState implementation.
28 ui::PageTransition GetTransitionType() override;
eugenebutcf731b52017-03-17 17:36:3429 bool WasWithinSameDocument() override;
clamy5f342202015-03-18 13:47:5630 bool IsContentInitiated() override;
31
32 const CommonNavigationParams& common_params() const { return common_params_; }
clamy57b4b8e2015-03-24 13:32:1133 const RequestNavigationParams& request_params() const {
34 return request_params_;
clamy5f342202015-03-18 13:47:5635 }
36 bool request_committed() const { return request_committed_; }
37 void set_request_committed(bool value) { request_committed_ = value; }
eugenebutcf731b52017-03-17 17:36:3438 void set_was_within_same_document(bool value) {
39 was_within_same_document_ = value;
40 }
clamy5f342202015-03-18 13:47:5641
42 void set_transition_type(ui::PageTransition transition) {
43 common_params_.transition = transition;
44 }
45
arthursonzogni2dbfc5092018-02-27 20:42:0946 base::TimeTicks time_commit_requested() const {
47 return time_commit_requested_;
48 }
49
clamy5f342202015-03-18 13:47:5650 private:
51 NavigationStateImpl(const CommonNavigationParams& common_params,
clamy57b4b8e2015-03-24 13:32:1152 const RequestNavigationParams& request_params,
arthursonzogni2dbfc5092018-02-27 20:42:0953 base::TimeTicks time_commit_requested,
clamy5f342202015-03-18 13:47:5654 bool is_content_initiated);
55
56 bool request_committed_;
eugenebutcf731b52017-03-17 17:36:3457 bool was_within_same_document_;
clamy5f342202015-03-18 13:47:5658
59 // True if this navigation was not initiated via WebFrame::LoadRequest.
60 const bool is_content_initiated_;
61
62 CommonNavigationParams common_params_;
clamy5f342202015-03-18 13:47:5663
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).
clamy57b4b8e2015-03-24 13:32:1175 const RequestNavigationParams request_params_;
clamy5f342202015-03-18 13:47:5676
arthursonzogni2dbfc5092018-02-27 20:42:0977 // Time when RenderFrameImpl::CommitNavigation() is called.
78 base::TimeTicks time_commit_requested_;
79
clamy5f342202015-03-18 13:47:5680 DISALLOW_COPY_AND_ASSIGN(NavigationStateImpl);
81};
82
83} // namespace content
84
85#endif // CONTENT_RENDERER_NAVIGATION_STATE_IMPL_H_