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

Side by Side Diff: chrome/browser/extensions/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: Move SidebarManager to ExtensionSystem and remove notifications Created 5 years, 6 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_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 "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
39 SidebarContainer(Browser* browser,
40 content::WebContents* tab,
41 const GURL& url);
42 ~SidebarContainer() override;
43
44 // Retruns HostContents sidebar is linked to.
45 content::WebContents* host_contents() const { return host_->host_contents(); }
46
47 // Returns TabContents sidebar is linked to.
48 content::WebContents* web_contents() const { return tab_; }
49
50 // Notifies hosting window that this sidebar was expanded.
51 void Show();
52
53 // Notifies hosting window that this sidebar was expanded.
54 void Expand();
55
56 // Navigates sidebar contents to the |url|.
57 void Navigate(const GURL& url);
58
59 const std::string& extension_id() { return host_->extension_id(); }
60
61 // content::NotificationObserver overrides.
62 void Observe(int type,
63 const content::NotificationSource& source,
64 const content::NotificationDetails& details) override;
65
66 private:
67 scoped_ptr<extensions::ExtensionViewHost> host_;
68
69 ScopedObserver<extensions::ExtensionHost, extensions::ExtensionHostObserver>
70 host_observer_;
71
72 content::NotificationRegistrar registrar_;
73
74 // Contents of the tab this sidebar is linked to.
75 content::WebContents* tab_;
76
77 // On the first expand sidebar will be automatically navigated to the default
78 // page (specified in the extension manifest), but only if the extension has
79 // not explicitly navigated it yet. This variable is set to false on the first
80 // sidebar navigation.
81 bool navigate_to_default_page_on_expand_;
82
83 DISALLOW_COPY_AND_ASSIGN(SidebarContainer);
84 };
85
86 #endif // CHROME_BROWSER_EXTENSIONS_SIDEBAR_CONTAINER_H_
OLDNEW

Powered by Google App Engine
This is Rietveld 408576698