OLD | NEW |
(Empty) | |
| 1 // Copyright 2015 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 CHROME_BROWSER_EXTENSIONS_SIDEBAR_CONTAINER_H_ |
| 6 #define CHROME_BROWSER_EXTENSIONS_SIDEBAR_CONTAINER_H_ |
| 7 |
| 8 #include "base/memory/scoped_ptr.h" |
| 9 #include "base/scoped_observer.h" |
| 10 #include "chrome/browser/extensions/extension_view_host.h" |
| 11 #include "chrome/browser/ui/tabs/tab_strip_model_observer.h" |
| 12 #include "content/public/browser/notification_observer.h" |
| 13 #include "content/public/browser/notification_registrar.h" |
| 14 #include "extensions/browser/extension_host_observer.h" |
| 15 |
| 16 class Browser; |
| 17 |
| 18 namespace content { |
| 19 class WebContents; |
| 20 } |
| 21 |
| 22 namespace extensions { |
| 23 |
| 24 // Stores one particular sidebar state: sidebar's content, its content id, |
| 25 // tab it is linked to, mini tab icon, title etc. |
| 26 class SidebarContainer : public content::NotificationObserver, |
| 27 public TabStripModelObserver { |
| 28 public: |
| 29 SidebarContainer(Browser* browser, |
| 30 content::WebContents* tab, |
| 31 const GURL& url); |
| 32 ~SidebarContainer() override; |
| 33 |
| 34 // Returns HostContents sidebar is linked to. |
| 35 content::WebContents* sidebar_contents() const { |
| 36 return host_->host_contents(); |
| 37 } |
| 38 |
| 39 // Returns TabContents sidebar is linked to. |
| 40 content::WebContents* tab_contents() const { return tab_; } |
| 41 |
| 42 const std::string& extension_id() { return host_->extension_id(); } |
| 43 |
| 44 // TabStripModelObserver |
| 45 void TabClosingAt(TabStripModel* tab_strip_model, |
| 46 content::WebContents* contents, |
| 47 int index) override; |
| 48 |
| 49 private: |
| 50 // content::NotificationObserver |
| 51 void Observe(int type, |
| 52 const content::NotificationSource& source, |
| 53 const content::NotificationDetails& details) override; |
| 54 |
| 55 scoped_ptr<extensions::ExtensionViewHost> host_; |
| 56 |
| 57 content::NotificationRegistrar registrar_; |
| 58 |
| 59 // Contents of the tab this sidebar is linked to. |
| 60 content::WebContents* tab_; |
| 61 |
| 62 // Reference to browser |
| 63 Browser* browser_; |
| 64 |
| 65 ScopedObserver<TabStripModel, TabStripModelObserver> |
| 66 tab_strip_model_observer_; |
| 67 |
| 68 DISALLOW_COPY_AND_ASSIGN(SidebarContainer); |
| 69 }; |
| 70 |
| 71 } // namespace extensions |
| 72 #endif // CHROME_BROWSER_EXTENSIONS_SIDEBAR_CONTAINER_H_ |
OLD | NEW |