Chromium Code Reviews| 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 41 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... | |
| 66 int GetIndexOfLastWebStateOpenedBy(const web::WebState* opener, | 68 int GetIndexOfLastWebStateOpenedBy(const web::WebState* opener, |
| 67 int start_index, | 69 int start_index, |
| 68 bool use_group) const; | 70 bool use_group) const; |
| 69 | 71 |
| 70 // Inserts the specified WebState at the specified index with an optional | 72 // Inserts the specified WebState at the specified index with an optional |
| 71 // opener (null if there is no opener). | 73 // opener (null if there is no opener). |
| 72 void InsertWebState(int index, | 74 void InsertWebState(int index, |
| 73 web::WebState* web_state, | 75 web::WebState* web_state, |
| 74 web::WebState* opener); | 76 web::WebState* opener); |
| 75 | 77 |
| 78 // Adds a WebState at the best position in the WebStateList given the | |
| 79 // specified insertion index, transition, etc. An optional opener for the new | |
| 80 // WebState may be passed. Pass kInvalidIndex for |index| to append it to the | |
|
marq (ping after 24h)
2017/02/17 13:33:00
I would have a mild preference for a separate Appe
sdefresne
2017/02/20 16:12:55
Done.
| |
| 81 // WebStateList. | |
| 82 void AddWebState(int index, | |
| 83 ui::PageTransition transition, | |
| 84 web::WebState* web_state, | |
| 85 web::WebState* opener); | |
| 86 | |
| 76 // Moves the WebState at the specified index to another index. | 87 // Moves the WebState at the specified index to another index. |
| 77 void MoveWebStateAt(int from_index, int to_index); | 88 void MoveWebStateAt(int from_index, int to_index); |
| 78 | 89 |
| 79 // Replaces the WebState at the specified index with new WebState. Returns | 90 // Replaces the WebState at the specified index with new WebState. Returns |
| 80 // the old WebState at that index to the caller (abandon ownership of the | 91 // the old WebState at that index to the caller (abandon ownership of the |
| 81 // returned WebState). An optional opener for the new WebState may be passed. | 92 // returned WebState). An optional opener for the new WebState may be passed. |
| 82 web::WebState* ReplaceWebStateAt(int index, | 93 web::WebState* ReplaceWebStateAt(int index, |
| 83 web::WebState* web_state, | 94 web::WebState* web_state, |
| 84 web::WebState* opener); | 95 web::WebState* opener); |
| 85 | 96 |
| (...skipping 24 matching lines...) Expand all Loading... | |
| 110 // same session. | 121 // same session. |
| 111 int GetIndexOfNthWebStateOpenedBy(const web::WebState* opener, | 122 int GetIndexOfNthWebStateOpenedBy(const web::WebState* opener, |
| 112 int start_index, | 123 int start_index, |
| 113 bool use_group, | 124 bool use_group, |
| 114 int n) const; | 125 int n) const; |
| 115 | 126 |
| 116 class WebStateWrapper; | 127 class WebStateWrapper; |
| 117 const WebStateOwnership web_state_ownership_; | 128 const WebStateOwnership web_state_ownership_; |
| 118 std::vector<std::unique_ptr<WebStateWrapper>> web_state_wrappers_; | 129 std::vector<std::unique_ptr<WebStateWrapper>> web_state_wrappers_; |
| 119 | 130 |
| 131 // An object that determines where new WebState should be inserted and where | |
| 132 // selection should move when a WebState is detached. | |
| 133 std::unique_ptr<WebStateListOrderController> order_controller_; | |
| 134 | |
| 120 // List of observers notified of changes to the model. | 135 // List of observers notified of changes to the model. |
| 121 base::ObserverList<WebStateListObserver, true> observers_; | 136 base::ObserverList<WebStateListObserver, true> observers_; |
| 122 | 137 |
| 123 DISALLOW_COPY_AND_ASSIGN(WebStateList); | 138 DISALLOW_COPY_AND_ASSIGN(WebStateList); |
| 124 }; | 139 }; |
| 125 | 140 |
| 126 #endif // IOS_SHARED_CHROME_BROWSER_TABS_WEB_STATE_LIST_H_ | 141 #endif // IOS_SHARED_CHROME_BROWSER_TABS_WEB_STATE_LIST_H_ |
| OLD | NEW |