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

Side by Side Diff: blimp/engine/common/tab_manager.h

Issue 2176733003: Add TabManager class, relocate Tab to common/. (Closed) Base URL: https://chromium.googlesource.com/chromium/src.git@master
Patch Set: Created 4 years, 5 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 | « blimp/engine/common/tab.cc ('k') | blimp/engine/common/tab_manager.cc » ('j') | no next file with comments »
Toggle Intra-line Diffs ('i') | Expand Comments ('e') | Collapse Comments ('c') | Show Comments Hide Comments ('s')
OLDNEW
(Empty)
1 // Copyright 2016 The Chromium Authors. All rights reserved.
2 // Use of this source code is governed by a BSD-style license that can be
3 // found in the LICENSE file.
4
5 #ifndef BLIMP_ENGINE_COMMON_TAB_MANAGER_H_
6 #define BLIMP_ENGINE_COMMON_TAB_MANAGER_H_
7
8 #include <map>
9 #include <memory>
10
11 #include "base/containers/small_map.h"
12 #include "base/macros.h"
13 #include "base/observer_list.h"
14
15 namespace content {
16 class WebContents;
17 }
18
19 namespace blimp {
20 namespace engine {
21
22 class Tab;
23
24 // Container class for tabs, which are addressable by their ID and WebContents.
25 class TabManager {
26 public:
27 TabManager();
28 ~TabManager();
29
30 void Add(std::unique_ptr<Tab> tab);
31 void Remove(Tab* tab);
32 void Clear();
33
34 // Finds a tab with the ID matching |tab_id|.
35 // Returns nullptr if the tab does not exist.
36 Tab* FindTabById(int tab_id) const;
37
38 // Finds the tab which owns |contents|.
39 // Returns nullptr if such a tab does not exist.
40 Tab* FindTabByWebContents(content::WebContents* contents) const;
41
42 // Transitional method, to be used while other features are rewritten to
43 // support multiple tab IDs. Should be removed ASAP.
44 Tab* GetOnlyTab() const;
45
46 private:
47 // Map of tabs, indexed by tab ID.
48 base::SmallMap<int, std::unique_ptr<Tab>> tabs_;
49
50 // Tabs, indexed by WebContents.
51 base::SmallMap<content::WebContents*, Tab*> tabs_by_webcontents_;
52
53 DISALLOW_COPY_AND_ASSIGN(TabManager);
54 };
55
56 } // namespace engine
57 } // namespace blimp
58
59 #endif // BLIMP_ENGINE_COMMON_TAB_MANAGER_H_
OLDNEW
« no previous file with comments | « blimp/engine/common/tab.cc ('k') | blimp/engine/common/tab_manager.cc » ('j') | no next file with comments »

Powered by Google App Engine
This is Rietveld 408576698