| OLD | NEW |
| 1 // Copyright 2015 The Chromium Authors. All rights reserved. | 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 | 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_NAVIGATION_STATE_IMPL_H_ | 5 #ifndef CONTENT_RENDERER_NAVIGATION_STATE_IMPL_H_ |
| 6 #define CONTENT_RENDERER_NAVIGATION_STATE_IMPL_H_ | 6 #define CONTENT_RENDERER_NAVIGATION_STATE_IMPL_H_ |
| 7 | 7 |
| 8 #include <string> | 8 #include <string> |
| 9 | 9 |
| 10 #include "content/common/navigation_params.h" | 10 #include "content/common/navigation_params.h" |
| 11 #include "content/public/renderer/navigation_state.h" | 11 #include "content/public/renderer/navigation_state.h" |
| 12 | 12 |
| 13 namespace content { | 13 namespace content { |
| 14 | 14 |
| 15 class CONTENT_EXPORT NavigationStateImpl : public NavigationState { | 15 class CONTENT_EXPORT NavigationStateImpl : public NavigationState { |
| 16 public: | 16 public: |
| 17 ~NavigationStateImpl() override; | 17 ~NavigationStateImpl() override; |
| 18 | 18 |
| 19 static NavigationStateImpl* CreateBrowserInitiated( | 19 static NavigationStateImpl* CreateBrowserInitiated( |
| 20 const CommonNavigationParams& common_params, | 20 const CommonNavigationParams& common_params, |
| 21 const StartNavigationParams& start_params, | 21 const StartNavigationParams& start_params, |
| 22 const HistoryNavigationParams& history_params); | 22 const CommitNavigationParams& commit_params); |
| 23 | 23 |
| 24 static NavigationStateImpl* CreateContentInitiated(); | 24 static NavigationStateImpl* CreateContentInitiated(); |
| 25 | 25 |
| 26 // NavigationState implementation. | 26 // NavigationState implementation. |
| 27 ui::PageTransition GetTransitionType() override; | 27 ui::PageTransition GetTransitionType() override; |
| 28 bool WasWithinSamePage() override; | 28 bool WasWithinSamePage() override; |
| 29 bool IsContentInitiated() override; | 29 bool IsContentInitiated() override; |
| 30 | 30 |
| 31 const CommonNavigationParams& common_params() const { return common_params_; } | 31 const CommonNavigationParams& common_params() const { return common_params_; } |
| 32 const StartNavigationParams& start_params() const { return start_params_; } | 32 const StartNavigationParams& start_params() const { return start_params_; } |
| 33 const HistoryNavigationParams& history_params() const { | 33 const CommitNavigationParams& commit_params() const { return commit_params_; } |
| 34 return history_params_; | |
| 35 } | |
| 36 bool request_committed() const { return request_committed_; } | 34 bool request_committed() const { return request_committed_; } |
| 37 void set_request_committed(bool value) { request_committed_ = value; } | 35 void set_request_committed(bool value) { request_committed_ = value; } |
| 38 void set_was_within_same_page(bool value) { was_within_same_page_ = value; } | 36 void set_was_within_same_page(bool value) { was_within_same_page_ = value; } |
| 39 | 37 |
| 40 void set_transition_type(ui::PageTransition transition) { | 38 void set_transition_type(ui::PageTransition transition) { |
| 41 common_params_.transition = transition; | 39 common_params_.transition = transition; |
| 42 } | 40 } |
| 43 | 41 |
| 44 private: | 42 private: |
| 45 NavigationStateImpl(const CommonNavigationParams& common_params, | 43 NavigationStateImpl(const CommonNavigationParams& common_params, |
| 46 const StartNavigationParams& start_params, | 44 const StartNavigationParams& start_params, |
| 47 const HistoryNavigationParams& history_params, | 45 const CommitNavigationParams& commit_params, |
| 48 bool is_content_initiated); | 46 bool is_content_initiated); |
| 49 | 47 |
| 50 bool request_committed_; | 48 bool request_committed_; |
| 51 bool was_within_same_page_; | 49 bool was_within_same_page_; |
| 52 | 50 |
| 53 // True if this navigation was not initiated via WebFrame::LoadRequest. | 51 // True if this navigation was not initiated via WebFrame::LoadRequest. |
| 54 const bool is_content_initiated_; | 52 const bool is_content_initiated_; |
| 55 | 53 |
| 56 CommonNavigationParams common_params_; | 54 CommonNavigationParams common_params_; |
| 57 const StartNavigationParams start_params_; | 55 const StartNavigationParams start_params_; |
| 58 | 56 |
| 59 // Note: if IsContentInitiated() is false, whether this navigation should | 57 // Note: if IsContentInitiated() is false, whether this navigation should |
| 60 // replace the current entry in the back/forward history list is determined by | 58 // replace the current entry in the back/forward history list is determined by |
| 61 // the should_replace_current_entry field in |history_params|. Otherwise, use | 59 // the should_replace_current_entry field in |history_params|. Otherwise, use |
| 62 // replacesCurrentHistoryItem() on the WebDataSource. | 60 // replacesCurrentHistoryItem() on the WebDataSource. |
| 63 // | 61 // |
| 64 // TODO(davidben): It would be good to unify these and have only one source | 62 // TODO(davidben): It would be good to unify these and have only one source |
| 65 // for the two cases. We can plumb this through WebFrame::loadRequest to set | 63 // for the two cases. We can plumb this through WebFrame::loadRequest to set |
| 66 // lockBackForwardList on the FrameLoadRequest. However, this breaks process | 64 // lockBackForwardList on the FrameLoadRequest. However, this breaks process |
| 67 // swaps because FrameLoader::loadWithNavigationAction treats loads before a | 65 // swaps because FrameLoader::loadWithNavigationAction treats loads before a |
| 68 // FrameLoader has committedFirstRealDocumentLoad as a replacement. (Added for | 66 // FrameLoader has committedFirstRealDocumentLoad as a replacement. (Added for |
| 69 // http://crbug.com/178380). | 67 // http://crbug.com/178380). |
| 70 const HistoryNavigationParams history_params_; | 68 const CommitNavigationParams commit_params_; |
| 71 | 69 |
| 72 DISALLOW_COPY_AND_ASSIGN(NavigationStateImpl); | 70 DISALLOW_COPY_AND_ASSIGN(NavigationStateImpl); |
| 73 }; | 71 }; |
| 74 | 72 |
| 75 } // namespace content | 73 } // namespace content |
| 76 | 74 |
| 77 #endif // CONTENT_RENDERER_NAVIGATION_STATE_IMPL_H_ | 75 #endif // CONTENT_RENDERER_NAVIGATION_STATE_IMPL_H_ |
| OLD | NEW |