Rename vector icon header files.
[chromium-blink-merge.git] / chrome / browser / ui / views / extensions / extension_popup.h
blobcf590cccc0309130d6385a6b2823e44c384c5096
1 // Copyright (c) 2012 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.
5 #ifndef CHROME_BROWSER_UI_VIEWS_EXTENSIONS_EXTENSION_POPUP_H_
6 #define CHROME_BROWSER_UI_VIEWS_EXTENSIONS_EXTENSION_POPUP_H_
8 #include "base/callback.h"
9 #include "base/compiler_specific.h"
10 #include "chrome/browser/ui/tabs/tab_strip_model_observer.h"
11 #include "chrome/browser/ui/views/extensions/extension_view_views.h"
12 #include "content/public/browser/notification_observer.h"
13 #include "content/public/browser/notification_registrar.h"
14 #include "ui/views/bubble/bubble_delegate.h"
15 #include "url/gurl.h"
18 class Browser;
19 namespace views {
20 class Widget;
23 namespace content {
24 class DevToolsAgentHost;
27 namespace extensions {
28 class ExtensionViewHost;
31 class ExtensionPopup : public views::BubbleDelegateView,
32 public ExtensionViewViews::Container,
33 public content::NotificationObserver,
34 public TabStripModelObserver {
35 public:
36 enum ShowAction {
37 SHOW,
38 SHOW_AND_INSPECT,
41 ~ExtensionPopup() override;
43 // Create and show a popup with the given |host| positioned adjacent to
44 // |anchor_view|.
45 // The positioning of the pop-up is determined by |arrow| according to the
46 // following logic: The popup is anchored so that the corner indicated by the
47 // value of |arrow| remains fixed during popup resizes. If |arrow| is
48 // BOTTOM_*, then the popup 'pops up', otherwise the popup 'drops down'.
49 // The actual display of the popup is delayed until the page contents
50 // finish loading in order to minimize UI flashing and resizing.
51 static ExtensionPopup* ShowPopup(
52 scoped_ptr<extensions::ExtensionViewHost> host,
53 views::View* anchor_view,
54 views::BubbleBorder::Arrow arrow,
55 ShowAction show_action);
58 extensions::ExtensionViewHost* host() const { return host_.get(); }
60 // content::NotificationObserver overrides.
61 void Observe(int type,
62 const content::NotificationSource& source,
63 const content::NotificationDetails& details) override;
65 // ExtensionViewViews::Container overrides.
66 void OnExtensionSizeChanged(ExtensionViewViews* view) override;
68 // views::View overrides.
69 gfx::Size GetPreferredSize() const override;
70 void ViewHierarchyChanged(
71 const ViewHierarchyChangedDetails& details) override;
73 // views::WidgetObserver overrides.
74 void OnWidgetActivationChanged(views::Widget* widget, bool active) override;
76 // TabStripModelObserver overrides.
77 void ActiveTabChanged(content::WebContents* old_contents,
78 content::WebContents* new_contents,
79 int index,
80 int reason) override;
82 // The min/max height of popups.
83 static const int kMinWidth;
84 static const int kMinHeight;
85 static const int kMaxWidth;
86 static const int kMaxHeight;
88 protected:
89 ExtensionPopup(extensions::ExtensionViewHost* host,
90 views::View* anchor_view,
91 views::BubbleBorder::Arrow arrow,
92 ShowAction show_action);
94 // Called on anchor window activation (ie. user clicked the browser window).
95 void OnAnchorWindowActivation();
97 private:
98 static ExtensionPopup* Create(extensions::ExtensionViewHost* host,
99 views::View* anchor_view,
100 views::BubbleBorder::Arrow arrow,
101 ShowAction show_action);
103 // Show the bubble, focus on its content, and register listeners.
104 void ShowBubble();
106 void OnDevToolsStateChanged(content::DevToolsAgentHost*, bool attached);
108 // The contained host for the view.
109 scoped_ptr<extensions::ExtensionViewHost> host_;
111 // Flag used to indicate if the pop-up should open a devtools window once
112 // it is shown inspecting it.
113 bool inspect_with_devtools_;
115 content::NotificationRegistrar registrar_;
117 base::Callback<void(content::DevToolsAgentHost*, bool)> devtools_callback_;
119 bool widget_initialized_;
121 DISALLOW_COPY_AND_ASSIGN(ExtensionPopup);
124 #endif // CHROME_BROWSER_UI_VIEWS_EXTENSIONS_EXTENSION_POPUP_H_