OLD | NEW |
1 // Copyright 2017 The Chromium Authors. All rights reserved. | 1 // Copyright 2017 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 IOS_SHARED_CHROME_BROWSER_TABS_WEB_STATE_LIST_H_ | 5 #ifndef IOS_SHARED_CHROME_BROWSER_TABS_WEB_STATE_LIST_H_ |
6 #define IOS_SHARED_CHROME_BROWSER_TABS_WEB_STATE_LIST_H_ | 6 #define IOS_SHARED_CHROME_BROWSER_TABS_WEB_STATE_LIST_H_ |
7 | 7 |
8 #include <memory> | 8 #include <memory> |
9 #include <vector> | 9 #include <vector> |
10 | 10 |
11 #include "base/macros.h" | 11 #include "base/macros.h" |
12 #include "base/observer_list.h" | 12 #include "base/observer_list.h" |
| 13 #include "ui/base/page_transition_types.h" |
13 | 14 |
14 class WebStateListObserver; | 15 class WebStateListObserver; |
| 16 class WebStateListOrderController; |
15 | 17 |
16 namespace web { | 18 namespace web { |
17 class WebState; | 19 class WebState; |
18 } | 20 } |
19 | 21 |
20 // Manages a list of WebStates. May owns the WebState depending on the ownership | 22 // Manages a list of WebStates. May owns the WebState depending on the ownership |
21 // setting (initialised during construction, should eventually always be "owned" | 23 // setting (initialised during construction, should eventually always be "owned" |
22 // once ownership of Tab is sane, see http://crbug.com/546222 for progress). | 24 // once ownership of Tab is sane, see http://crbug.com/546222 for progress). |
23 class WebStateList { | 25 class WebStateList { |
24 public: | 26 public: |
(...skipping 45 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
70 int GetIndexOfLastWebStateOpenedBy(const web::WebState* opener, | 72 int GetIndexOfLastWebStateOpenedBy(const web::WebState* opener, |
71 int start_index, | 73 int start_index, |
72 bool use_group) const; | 74 bool use_group) const; |
73 | 75 |
74 // Inserts the specified WebState at the specified index with an optional | 76 // Inserts the specified WebState at the specified index with an optional |
75 // opener (null if there is no opener). | 77 // opener (null if there is no opener). |
76 void InsertWebState(int index, | 78 void InsertWebState(int index, |
77 web::WebState* web_state, | 79 web::WebState* web_state, |
78 web::WebState* opener); | 80 web::WebState* opener); |
79 | 81 |
| 82 // Inserts the specified WebState at the best position in the WebStateList |
| 83 // given the specified transition, opener (optional, may be null), etc. It |
| 84 // defaults to inserting the WebState at the end of the list. |
| 85 void AppendWebState(ui::PageTransition transition, |
| 86 web::WebState* web_state, |
| 87 web::WebState* opener); |
| 88 |
80 // Moves the WebState at the specified index to another index. | 89 // Moves the WebState at the specified index to another index. |
81 void MoveWebStateAt(int from_index, int to_index); | 90 void MoveWebStateAt(int from_index, int to_index); |
82 | 91 |
83 // Replaces the WebState at the specified index with new WebState. Returns | 92 // Replaces the WebState at the specified index with new WebState. Returns |
84 // the old WebState at that index to the caller (abandon ownership of the | 93 // the old WebState at that index to the caller (abandon ownership of the |
85 // returned WebState). An optional opener for the new WebState may be passed. | 94 // returned WebState). An optional opener for the new WebState may be passed. |
86 web::WebState* ReplaceWebStateAt(int index, | 95 web::WebState* ReplaceWebStateAt(int index, |
87 web::WebState* web_state, | 96 web::WebState* web_state, |
88 web::WebState* opener); | 97 web::WebState* opener); |
89 | 98 |
(...skipping 21 matching lines...) Expand all Loading... |
111 // same session. | 120 // same session. |
112 int GetIndexOfNthWebStateOpenedBy(const web::WebState* opener, | 121 int GetIndexOfNthWebStateOpenedBy(const web::WebState* opener, |
113 int start_index, | 122 int start_index, |
114 bool use_group, | 123 bool use_group, |
115 int n) const; | 124 int n) const; |
116 | 125 |
117 class WebStateWrapper; | 126 class WebStateWrapper; |
118 const WebStateOwnership web_state_ownership_; | 127 const WebStateOwnership web_state_ownership_; |
119 std::vector<std::unique_ptr<WebStateWrapper>> web_state_wrappers_; | 128 std::vector<std::unique_ptr<WebStateWrapper>> web_state_wrappers_; |
120 | 129 |
| 130 // An object that determines where new WebState should be inserted and where |
| 131 // selection should move when a WebState is detached. |
| 132 std::unique_ptr<WebStateListOrderController> order_controller_; |
| 133 |
121 // List of observers notified of changes to the model. | 134 // List of observers notified of changes to the model. |
122 base::ObserverList<WebStateListObserver, true> observers_; | 135 base::ObserverList<WebStateListObserver, true> observers_; |
123 | 136 |
124 DISALLOW_COPY_AND_ASSIGN(WebStateList); | 137 DISALLOW_COPY_AND_ASSIGN(WebStateList); |
125 }; | 138 }; |
126 | 139 |
127 #endif // IOS_SHARED_CHROME_BROWSER_TABS_WEB_STATE_LIST_H_ | 140 #endif // IOS_SHARED_CHROME_BROWSER_TABS_WEB_STATE_LIST_H_ |
OLD | NEW |