Chromium Code Reviews
chromiumcodereview-hr@appspot.gserviceaccount.com (chromiumcodereview-hr) | Please choose your nickname with Settings | Help | Chromium Project | Gerrit Changes | Sign out
(286)

Unified Diff: ios/shared/chrome/browser/tabs/web_state_list.h

Issue 2703333006: Move the notion of current Tab from TabModel to WebStateList. (Closed)
Patch Set: Created 3 years, 10 months ago
Use n/p to move between diff chunks; N/P to move between comments. Draft comments are only viewable by you.
Jump to:
View side-by-side diff with in-line comments
Download patch
Index: ios/shared/chrome/browser/tabs/web_state_list.h
diff --git a/ios/shared/chrome/browser/tabs/web_state_list.h b/ios/shared/chrome/browser/tabs/web_state_list.h
index 6cf8472bdbbb309f29bddb874ddb1fa52133561d..6516f7afe0a383335fd25300ba2036f9aaa451f8 100644
--- a/ios/shared/chrome/browser/tabs/web_state_list.h
+++ b/ios/shared/chrome/browser/tabs/web_state_list.h
@@ -38,9 +38,16 @@ class WebStateList {
// Returns the number of WebStates in the model.
int count() const { return static_cast<int>(web_state_wrappers_.size()); }
+ // Returns the index of the currently active WebState, or kInvalidIndex if
+ // there are no active WebState.
+ int active_index() const { return active_index_; }
+
// Returns true if the specified index is contained by the model.
bool ContainsIndex(int index) const;
+ // Returns the currently active WebState or null if there is none.
+ web::WebState* GetActiveWebState() const;
+
// Returns the WebState at the specified index. It is invalid to call this
// with an index such that |ContainsIndex(index)| returns false.
web::WebState* GetWebStateAt(int index) const;
@@ -99,6 +106,9 @@ class WebStateList {
// Detaches the WebState at the specified index.
void DetachWebStateAt(int index);
+ // Makes the WebState at the specified index the active WebState.
+ void ActivateWebStateAt(int index);
+
// Adds an observer to the model.
void AddObserver(WebStateListObserver* observer);
@@ -113,6 +123,10 @@ class WebStateList {
// specified index to null.
void FixOpenersReferencing(int index);
+ // Notify the observers if the active WebState change.
+ void NotifyIfActiveWebStateChanged(web::WebState* old_web_state,
+ bool user_action);
+
// Returns the index of the |n|-th WebState (with n > 0) in the sequence of
// WebStates opened from the specified WebState after |start_index|, or
// kInvalidIndex if there are no such WebState. If |use_group| is true, the
@@ -134,6 +148,9 @@ class WebStateList {
// List of observers notified of changes to the model.
base::ObserverList<WebStateListObserver, true> observers_;
+ // Index of the currently active WebState, kInvalidIndex if no such WebState.
+ int active_index_ = kInvalidIndex;
+
DISALLOW_COPY_AND_ASSIGN(WebStateList);
};

Powered by Google App Engine
This is Rietveld 408576698