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

Side by Side Diff: chrome/browser/sidebar/sidebar_container.h

Issue 1152613003: Implement sidebar support for extension action popups (Closed) Base URL: https://chromium.googlesource.com/chromium/src.git@master
Patch Set: Created 5 years, 7 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
OLDNEW
(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_SIDEBAR_SIDEBAR_CONTAINER_H_
6 #define CHROME_BROWSER_SIDEBAR_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 "content/public/browser/notification_observer.h"
16 #include "content/public/browser/notification_registrar.h"
17 #include "content/public/browser/web_contents_delegate.h"
18 #include "extensions/browser/extension_host_observer.h"
19
20 namespace content {
21 class WebContents;
22 }
23
24 namespace extensions {
25 class Extension;
26 }
27
28 ///////////////////////////////////////////////////////////////////////////////
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 extensions::ExtensionHostObserver,
35 public content::NotificationObserver {
36 public:
37 // Interface to implement to listen for sidebar update notification.
38 class Delegate {
39 public:
40 Delegate() {}
41 virtual ~Delegate() {}
42 virtual void UpdateSidebar(SidebarContainer* host) = 0;
43
44 private:
45 DISALLOW_COPY_AND_ASSIGN(Delegate);
46 };
47
48 SidebarContainer(Browser* browser,
49 content::WebContents* tab,
50 const GURL& url,
51 Delegate* delegate);
52 ~SidebarContainer() override;
53
54 // Called right before destroying this sidebar.
55 // Does all the necessary cleanup.
56 void SidebarClosing();
57
58 // Retruns HostContents sidebar is linked to.
59 content::WebContents* host_contents() const { return host_->host_contents(); }
60
61 // Returns TabContents sidebar is linked to.
62 content::WebContents* web_contents() const { return tab_; }
63
64 // Notifies hosting window that this sidebar was expanded.
65 void Show();
66
67 // Notifies hosting window that this sidebar was expanded.
68 void Expand();
69
70 // Notifies hosting window that this sidebar was collapsed.
71 void Collapse();
72
73 // Navigates sidebar contents to the |url|.
74 void Navigate(const GURL& url);
75
76 const std::string& extension_id() { return host_->extension_id(); }
77
78 // content::NotificationObserver overrides.
79 void Observe(int type,
80 const content::NotificationSource& source,
81 const content::NotificationDetails& details) override;
82
83 private:
84 scoped_ptr<extensions::ExtensionViewHost> host_;
85
86 ScopedObserver<extensions::ExtensionHost, extensions::ExtensionHostObserver>
87 host_observer_;
88
89 content::NotificationRegistrar registrar_;
90
91 // Contents of the tab this sidebar is linked to.
92 content::WebContents* tab_;
93
94 // Sidebar update notification listener.
95 Delegate* delegate_;
96
97 // On the first expand sidebar will be automatically navigated to the default
98 // page (specified in the extension manifest), but only if the extension has
99 // not explicitly navigated it yet. This variable is set to false on the first
100 // sidebar navigation.
101 bool navigate_to_default_page_on_expand_;
102
103 DISALLOW_COPY_AND_ASSIGN(SidebarContainer);
104 };
105
106 #endif // CHROME_BROWSER_SIDEBAR_SIDEBAR_CONTAINER_H_
OLDNEW

Powered by Google App Engine
This is Rietveld 408576698