OLD | NEW |
1 // Copyright (c) 2011 The Chromium Authors. All rights reserved. | 1 // Copyright (c) 2011 The Chromium Authors. All rights reserved. |
2 // Use of this source code is governed by a BSD-style license that can be | 2 // Use of this source code is governed by a BSD-style license that can be |
3 // found in the LICENSE file. | 3 // found in the LICENSE file. |
4 | 4 |
5 #ifndef CHROME_BROWSER_UI_VIEWS_EXTENSIONS_EXTENSION_POPUP_H_ | 5 #ifndef CHROME_BROWSER_UI_VIEWS_EXTENSIONS_EXTENSION_POPUP_H_ |
6 #define CHROME_BROWSER_UI_VIEWS_EXTENSIONS_EXTENSION_POPUP_H_ | 6 #define CHROME_BROWSER_UI_VIEWS_EXTENSIONS_EXTENSION_POPUP_H_ |
7 #pragma once | 7 #pragma once |
8 | 8 |
9 #include "base/compiler_specific.h" | 9 #include "base/compiler_specific.h" |
10 #include "chrome/browser/extensions/extension_host.h" | 10 #include "chrome/browser/extensions/extension_host.h" |
11 #include "chrome/browser/ui/views/extensions/extension_view.h" | 11 #include "chrome/browser/ui/views/extensions/extension_view.h" |
12 #include "content/public/browser/notification_observer.h" | 12 #include "content/public/browser/notification_observer.h" |
13 #include "googleurl/src/gurl.h" | 13 #include "googleurl/src/gurl.h" |
14 #include "ui/views/bubble/bubble_delegate.h" | 14 #include "ui/views/bubble/bubble_delegate.h" |
| 15 #include "ui/views/focus/widget_focus_manager.h" |
15 | 16 |
16 class Browser; | 17 class Browser; |
17 | 18 |
18 class ExtensionPopup : public views::BubbleDelegateView, | 19 class ExtensionPopup : public views::BubbleDelegateView, |
19 public ExtensionView::Container, | 20 public ExtensionView::Container, |
20 public content::NotificationObserver { | 21 public content::NotificationObserver, |
| 22 public views::WidgetFocusChangeListener { |
21 public: | 23 public: |
22 virtual ~ExtensionPopup(); | 24 virtual ~ExtensionPopup(); |
23 | 25 |
24 // Create and show a popup with |url| positioned adjacent to |anchor_view|. | 26 // Create and show a popup with |url| positioned adjacent to |anchor_view|. |
25 // |browser| is the browser to which the pop-up will be attached. NULL is a | 27 // |browser| is the browser to which the pop-up will be attached. NULL is a |
26 // valid parameter for pop-ups not associated with a browser. | 28 // valid parameter for pop-ups not associated with a browser. |
27 // The positioning of the pop-up is determined by |arrow_location| according | 29 // The positioning of the pop-up is determined by |arrow_location| according |
28 // to the following logic: The popup is anchored so that the corner indicated | 30 // to the following logic: The popup is anchored so that the corner indicated |
29 // by value of |arrow_location| remains fixed during popup resizes. | 31 // by value of |arrow_location| remains fixed during popup resizes. |
30 // If |arrow_location| is BOTTOM_*, then the popup 'pops up', otherwise | 32 // If |arrow_location| is BOTTOM_*, then the popup 'pops up', otherwise |
(...skipping 12 matching lines...) Expand all Loading... |
43 ExtensionHost* host() const { return extension_host_.get(); } | 45 ExtensionHost* host() const { return extension_host_.get(); } |
44 | 46 |
45 // content::NotificationObserver overrides. | 47 // content::NotificationObserver overrides. |
46 virtual void Observe(int type, | 48 virtual void Observe(int type, |
47 const content::NotificationSource& source, | 49 const content::NotificationSource& source, |
48 const content::NotificationDetails& details) OVERRIDE; | 50 const content::NotificationDetails& details) OVERRIDE; |
49 | 51 |
50 // ExtensionView::Container overrides. | 52 // ExtensionView::Container overrides. |
51 virtual void OnExtensionPreferredSizeChanged(ExtensionView* view) OVERRIDE; | 53 virtual void OnExtensionPreferredSizeChanged(ExtensionView* view) OVERRIDE; |
52 | 54 |
53 // view::View overrides. | 55 // views::View overrides. |
54 virtual gfx::Size GetPreferredSize() OVERRIDE; | 56 virtual gfx::Size GetPreferredSize() OVERRIDE; |
55 | 57 |
| 58 // views::WidgetFocusChangeListener overrides. |
| 59 virtual void OnNativeFocusChange(gfx::NativeView focused_before, |
| 60 gfx::NativeView focused_now) OVERRIDE; |
| 61 |
56 // The min/max height of popups. | 62 // The min/max height of popups. |
57 static const int kMinWidth; | 63 static const int kMinWidth; |
58 static const int kMinHeight; | 64 static const int kMinHeight; |
59 static const int kMaxWidth; | 65 static const int kMaxWidth; |
60 static const int kMaxHeight; | 66 static const int kMaxHeight; |
61 | 67 |
62 private: | 68 private: |
63 ExtensionPopup(Browser* browser, | 69 ExtensionPopup(Browser* browser, |
64 ExtensionHost* host, | 70 ExtensionHost* host, |
65 views::View* anchor_view, | 71 views::View* anchor_view, |
66 views::BubbleBorder::ArrowLocation arrow_location, | 72 views::BubbleBorder::ArrowLocation arrow_location, |
67 bool inspect_with_devtools); | 73 bool inspect_with_devtools); |
68 | 74 |
69 // The contained host for the view. | 75 // The contained host for the view. |
70 scoped_ptr<ExtensionHost> extension_host_; | 76 scoped_ptr<ExtensionHost> extension_host_; |
71 | 77 |
72 // Flag used to indicate if the pop-up should open a devtools window once | 78 // Flag used to indicate if the pop-up should open a devtools window once |
73 // it is shown inspecting it. | 79 // it is shown inspecting it. |
74 bool inspect_with_devtools_; | 80 bool inspect_with_devtools_; |
75 | 81 |
76 content::NotificationRegistrar registrar_; | 82 content::NotificationRegistrar registrar_; |
77 | 83 |
78 DISALLOW_COPY_AND_ASSIGN(ExtensionPopup); | 84 DISALLOW_COPY_AND_ASSIGN(ExtensionPopup); |
79 }; | 85 }; |
80 | 86 |
81 #endif // CHROME_BROWSER_UI_VIEWS_EXTENSIONS_EXTENSION_POPUP_H_ | 87 #endif // CHROME_BROWSER_UI_VIEWS_EXTENSIONS_EXTENSION_POPUP_H_ |
OLD | NEW |