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

Unified Diff: chrome/browser/extensions/sidebar_container.h

Issue 1168383002: Implement sidebar support for extension action popups Base URL: https://chromium.googlesource.com/chromium/src.git@master
Patch Set: Created 5 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 side-by-side diff with in-line comments
Download patch
Index: chrome/browser/extensions/sidebar_container.h
diff --git a/chrome/browser/extensions/sidebar_container.h b/chrome/browser/extensions/sidebar_container.h
new file mode 100644
index 0000000000000000000000000000000000000000..d094776f1fcd98f8454395cdd69d9c9f82979838
--- /dev/null
+++ b/chrome/browser/extensions/sidebar_container.h
@@ -0,0 +1,72 @@
+// Copyright 2015 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 CHROME_BROWSER_EXTENSIONS_SIDEBAR_CONTAINER_H_
+#define CHROME_BROWSER_EXTENSIONS_SIDEBAR_CONTAINER_H_
+
+#include "base/memory/scoped_ptr.h"
+#include "base/scoped_observer.h"
+#include "chrome/browser/extensions/extension_view_host.h"
+#include "chrome/browser/ui/tabs/tab_strip_model_observer.h"
+#include "content/public/browser/notification_observer.h"
+#include "content/public/browser/notification_registrar.h"
+#include "extensions/browser/extension_host_observer.h"
+
+class Browser;
+
+namespace content {
+class WebContents;
+}
+
+namespace extensions {
+
+// Stores one particular sidebar state: sidebar's content, its content id,
+// tab it is linked to, mini tab icon, title etc.
+class SidebarContainer : public content::NotificationObserver,
+ public TabStripModelObserver {
+ public:
+ SidebarContainer(Browser* browser,
+ content::WebContents* tab,
+ const GURL& url);
+ ~SidebarContainer() override;
+
+ // Returns HostContents sidebar is linked to.
+ content::WebContents* sidebar_contents() const {
+ return host_->host_contents();
+ }
+
+ // Returns TabContents sidebar is linked to.
+ content::WebContents* tab_contents() const { return tab_; }
+
+ const std::string& extension_id() { return host_->extension_id(); }
+
+ // TabStripModelObserver
+ void TabClosingAt(TabStripModel* tab_strip_model,
+ content::WebContents* contents,
+ int index) override;
+
+ private:
+ // content::NotificationObserver
+ void Observe(int type,
+ const content::NotificationSource& source,
+ const content::NotificationDetails& details) override;
+
+ scoped_ptr<extensions::ExtensionViewHost> host_;
+
+ content::NotificationRegistrar registrar_;
+
+ // Contents of the tab this sidebar is linked to.
+ content::WebContents* tab_;
+
+ // Reference to browser
+ Browser* browser_;
+
+ ScopedObserver<TabStripModel, TabStripModelObserver>
+ tab_strip_model_observer_;
+
+ DISALLOW_COPY_AND_ASSIGN(SidebarContainer);
+};
+
+} // namespace extensions
+#endif // CHROME_BROWSER_EXTENSIONS_SIDEBAR_CONTAINER_H_

Powered by Google App Engine
This is Rietveld 408576698