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

Side by Side Diff: ios/shared/chrome/browser/ui/browser_list/browser_list.h

Issue 2798863004: [ios] Extend BrowserList API. (Closed)
Patch Set: Created 3 years, 8 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 unified diff | Download patch
« no previous file with comments | « no previous file | ios/shared/chrome/browser/ui/browser_list/browser_list.mm » ('j') | no next file with comments »
Toggle Intra-line Diffs ('i') | Expand Comments ('e') | Collapse Comments ('c') | Show Comments Hide Comments ('s')
OLDNEW
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_UI_BROWSER_LIST_BROWSER_LIST_H_ 5 #ifndef IOS_SHARED_CHROME_BROWSER_UI_BROWSER_LIST_BROWSER_LIST_H_
6 #define IOS_SHARED_CHROME_BROWSER_UI_BROWSER_LIST_BROWSER_LIST_H_ 6 #define IOS_SHARED_CHROME_BROWSER_UI_BROWSER_LIST_BROWSER_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/supports_user_data.h" 12 #include "base/supports_user_data.h"
13 #include "ios/shared/chrome/browser/ui/browser_list/browser.h" 13 #include "ios/shared/chrome/browser/ui/browser_list/browser.h"
14 14
15 namespace ios { 15 namespace ios {
16 class ChromeBrowserState; 16 class ChromeBrowserState;
17 } 17 }
18 18
19 // BrowserList attaches Browsers instance to a ChromeBrowserState. 19 // BrowserList attaches Browsers instance to a ChromeBrowserState.
20 class BrowserList : public base::SupportsUserData::Data { 20 class BrowserList : public base::SupportsUserData::Data {
21 public: 21 public:
22 explicit BrowserList(ios::ChromeBrowserState* browser_state); 22 explicit BrowserList(ios::ChromeBrowserState* browser_state);
23 ~BrowserList() override; 23 ~BrowserList() override;
24 24
25 static BrowserList* FromBrowserState(ios::ChromeBrowserState* browser_state); 25 static BrowserList* FromBrowserState(ios::ChromeBrowserState* browser_state);
26 26
27 // Returns the number of open Browsers. 27 // Returns the number of Browsers in the BrowserList.
28 int GetBrowserCount() const; 28 int count() const { return static_cast<int>(browsers_.size()); }
marq (ping after 24h) 2017/04/05 13:43:24 Why move the implementation to the header?
sdefresne 2017/04/06 11:32:47 It is a trivial accessor and worth inlining (this
29 29
30 // Returns whether the specified index is valid. 30 // Returns whether the specified index is valid.
31 int ContainsIndex(int index) const; 31 int ContainsIndex(int index) const;
32 32
33 // Returns the Browser at the specified index. 33 // Returns the Browser at the specified index.
34 Browser* GetBrowserAtIndex(int index) const; 34 Browser* GetBrowserAt(int index) const;
35
36 // Returns the index of the specified Browser, or kInvalidIndex if not found.
37 int GetIndexOfBrowser(const Browser* browser) const;
35 38
36 // Creates and returns a new Browser instance. 39 // Creates and returns a new Browser instance.
37 Browser* CreateNewBrowser(); 40 Browser* CreateNewBrowser();
38 41
39 // Closes the Browser at the specified index. 42 // Closes the Browser at the specified index.
40 void CloseBrowserAtIndex(int index); 43 void CloseBrowserAtIndex(int index);
41 44
45 // Invalid index.
46 static const int kInvalidIndex = -1;
47
42 private: 48 private:
43 ios::ChromeBrowserState* browser_state_; 49 ios::ChromeBrowserState* browser_state_;
44 std::vector<std::unique_ptr<Browser>> browsers_; 50 std::vector<std::unique_ptr<Browser>> browsers_;
45 51
46 DISALLOW_COPY_AND_ASSIGN(BrowserList); 52 DISALLOW_COPY_AND_ASSIGN(BrowserList);
47 }; 53 };
48 54
49 #endif // IOS_SHARED_CHROME_BROWSER_UI_BROWSER_LIST_BROWSER_LIST_H_ 55 #endif // IOS_SHARED_CHROME_BROWSER_UI_BROWSER_LIST_BROWSER_LIST_H_
OLDNEW
« no previous file with comments | « no previous file | ios/shared/chrome/browser/ui/browser_list/browser_list.mm » ('j') | no next file with comments »

Powered by Google App Engine
This is Rietveld 408576698