| Index: blimp/engine/common/tab_manager.h
|
| diff --git a/blimp/engine/common/tab_manager.h b/blimp/engine/common/tab_manager.h
|
| new file mode 100644
|
| index 0000000000000000000000000000000000000000..35d0109caf2355fe6aa995fc5001ef07b685c6ad
|
| --- /dev/null
|
| +++ b/blimp/engine/common/tab_manager.h
|
| @@ -0,0 +1,59 @@
|
| +// Copyright 2016 The Chromium Authors. All rights reserved.
|
| +// Use of this source code is governed by a BSD-style license that can be
|
| +// found in the LICENSE file.
|
| +
|
| +#ifndef BLIMP_ENGINE_COMMON_TAB_MANAGER_H_
|
| +#define BLIMP_ENGINE_COMMON_TAB_MANAGER_H_
|
| +
|
| +#include <map>
|
| +#include <memory>
|
| +
|
| +#include "base/containers/small_map.h"
|
| +#include "base/macros.h"
|
| +#include "base/observer_list.h"
|
| +
|
| +namespace content {
|
| +class WebContents;
|
| +}
|
| +
|
| +namespace blimp {
|
| +namespace engine {
|
| +
|
| +class Tab;
|
| +
|
| +// Container class for tabs, which are addressable by their ID and WebContents.
|
| +class TabManager {
|
| + public:
|
| + TabManager();
|
| + ~TabManager();
|
| +
|
| + void Add(std::unique_ptr<Tab> tab);
|
| + void Remove(Tab* tab);
|
| + void Clear();
|
| +
|
| + // Finds a tab with the ID matching |tab_id|.
|
| + // Returns nullptr if the tab does not exist.
|
| + Tab* FindTabById(int tab_id) const;
|
| +
|
| + // Finds the tab which owns |contents|.
|
| + // Returns nullptr if such a tab does not exist.
|
| + Tab* FindTabByWebContents(content::WebContents* contents) const;
|
| +
|
| + // Transitional method, to be used while other features are rewritten to
|
| + // support multiple tab IDs. Should be removed ASAP.
|
| + Tab* GetOnlyTab() const;
|
| +
|
| + private:
|
| + // Map of tabs, indexed by tab ID.
|
| + base::SmallMap<int, std::unique_ptr<Tab>> tabs_;
|
| +
|
| + // Tabs, indexed by WebContents.
|
| + base::SmallMap<content::WebContents*, Tab*> tabs_by_webcontents_;
|
| +
|
| + DISALLOW_COPY_AND_ASSIGN(TabManager);
|
| +};
|
| +
|
| +} // namespace engine
|
| +} // namespace blimp
|
| +
|
| +#endif // BLIMP_ENGINE_COMMON_TAB_MANAGER_H_
|
|
|