Chromium Code Reviews| OLD | NEW |
|---|---|
| (Empty) | |
| 1 // Copyright (c) 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 <string> | |
| 9 | |
| 10 #include "base/basictypes.h" | |
| 11 #include "base/compiler_specific.h" | |
| 12 #include "base/memory/scoped_ptr.h" | |
| 13 #include "base/scoped_observer.h" | |
| 14 #include "chrome/browser/extensions/extension_view_host.h" | |
| 15 #include "chrome/browser/ui/tabs/tab_strip_model_observer.h" | |
| 16 #include "content/public/browser/notification_observer.h" | |
| 17 #include "content/public/browser/notification_registrar.h" | |
| 18 #include "content/public/browser/web_contents_delegate.h" | |
| 19 #include "extensions/browser/extension_host_observer.h" | |
| 20 | |
| 21 class Browser; | |
| 22 | |
| 23 namespace content { | |
| 24 class WebContents; | |
| 25 } | |
| 26 | |
| 27 namespace extensions { | |
| 28 /////////////////////////////////////////////////////////////////////////////// | |
|
Devlin
2015/06/19 19:56:09
nit: We don't really use this comment syntax that
ltilve
2015/06/28 22:44:19
Done.
| |
| 29 // SidebarContainer | |
| 30 // | |
| 31 // Stores one particular sidebar state: sidebar's content, its content id, | |
| 32 // tab it is linked to, mini tab icon, title etc. | |
| 33 // | |
| 34 class SidebarContainer : public content::NotificationObserver, | |
| 35 public TabStripModelObserver { | |
| 36 public: | |
| 37 // Interface to implement to listen for sidebar update notification. | |
|
Devlin
2015/06/19 19:56:09
?
ltilve
2015/06/28 22:44:19
Done. Removed wrong comment.
| |
| 38 | |
| 39 SidebarContainer(Browser* browser, | |
| 40 content::WebContents* tab, | |
| 41 const GURL& url); | |
| 42 ~SidebarContainer() override; | |
| 43 | |
| 44 // Retruns HostContents sidebar is linked to. | |
|
Devlin
2015/06/19 19:56:09
typo
ltilve
2015/06/28 22:44:19
Done.
| |
| 45 content::WebContents* host_contents() const { return host_->host_contents(); } | |
|
Devlin
2015/06/19 19:56:09
Let's rename these - "host_contents" and "web_cont
ltilve
2015/06/28 22:44:19
Done.
| |
| 46 | |
| 47 // Returns TabContents sidebar is linked to. | |
| 48 content::WebContents* web_contents() const { return tab_; } | |
| 49 | |
| 50 const std::string& extension_id() { return host_->extension_id(); } | |
| 51 | |
| 52 // content::NotificationObserver overrides. | |
|
Devlin
2015/06/19 19:56:09
s/ overrides./: (everywhere)
ltilve
2015/06/28 22:44:19
Done.
| |
| 53 void Observe(int type, | |
|
Devlin
2015/06/19 19:56:09
make this private
ltilve
2015/06/28 22:44:19
Done.
| |
| 54 const content::NotificationSource& source, | |
| 55 const content::NotificationDetails& details) override; | |
| 56 | |
| 57 // TabStripModelObserver overrides. | |
| 58 void TabClosingAt(TabStripModel* tab_strip_model, | |
| 59 content::WebContents* contents, | |
| 60 int index); | |
| 61 | |
| 62 private: | |
| 63 scoped_ptr<extensions::ExtensionViewHost> host_; | |
| 64 | |
| 65 content::NotificationRegistrar registrar_; | |
| 66 | |
| 67 // Contents of the tab this sidebar is linked to. | |
| 68 content::WebContents* tab_; | |
| 69 | |
| 70 // Reference to browser | |
| 71 Browser* browser_; | |
| 72 | |
| 73 DISALLOW_COPY_AND_ASSIGN(SidebarContainer); | |
| 74 }; | |
| 75 | |
| 76 } // namespace extensions | |
| 77 #endif // CHROME_BROWSER_EXTENSIONS_SIDEBAR_CONTAINER_H_ | |
| OLD | NEW |