blob: 87aad584303692974d7e13a5bb413de582c960f0 [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,
22 const StartNavigationParams& start_params,
clamy57b4b8e2015-03-24 13:32:1123 const RequestNavigationParams& request_params);
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_; }
33 const StartNavigationParams& start_params() const { return start_params_; }
clamy57b4b8e2015-03-24 13:32:1134 const RequestNavigationParams& request_params() const {
35 return request_params_;
clamy5f342202015-03-18 13:47:5636 }
37 bool request_committed() const { return request_committed_; }
38 void set_request_committed(bool value) { request_committed_ = value; }
eugenebutcf731b52017-03-17 17:36:3439 void set_was_within_same_document(bool value) {
40 was_within_same_document_ = value;
41 }
clamy5f342202015-03-18 13:47:5642
43 void set_transition_type(ui::PageTransition transition) {
44 common_params_.transition = transition;
45 }
46
47 private:
48 NavigationStateImpl(const CommonNavigationParams& common_params,
49 const StartNavigationParams& start_params,
clamy57b4b8e2015-03-24 13:32:1150 const RequestNavigationParams& request_params,
clamy5f342202015-03-18 13:47:5651 bool is_content_initiated);
52
53 bool request_committed_;
eugenebutcf731b52017-03-17 17:36:3454 bool was_within_same_document_;
clamy5f342202015-03-18 13:47:5655
56 // True if this navigation was not initiated via WebFrame::LoadRequest.
57 const bool is_content_initiated_;
58
59 CommonNavigationParams common_params_;
60 const StartNavigationParams start_params_;
61
62 // Note: if IsContentInitiated() is false, whether this navigation should
63 // replace the current entry in the back/forward history list is determined by
64 // the should_replace_current_entry field in |history_params|. Otherwise, use
65 // replacesCurrentHistoryItem() on the WebDataSource.
66 //
67 // TODO(davidben): It would be good to unify these and have only one source
68 // for the two cases. We can plumb this through WebFrame::loadRequest to set
69 // lockBackForwardList on the FrameLoadRequest. However, this breaks process
70 // swaps because FrameLoader::loadWithNavigationAction treats loads before a
71 // FrameLoader has committedFirstRealDocumentLoad as a replacement. (Added for
72 // http://crbug.com/178380).
clamy57b4b8e2015-03-24 13:32:1173 const RequestNavigationParams request_params_;
clamy5f342202015-03-18 13:47:5674
75 DISALLOW_COPY_AND_ASSIGN(NavigationStateImpl);
76};
77
78} // namespace content
79
80#endif // CONTENT_RENDERER_NAVIGATION_STATE_IMPL_H_