OLD | NEW |
1 // Copyright (c) 2012 The Chromium Authors. All rights reserved. | 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 | 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_VIEW_H_ | 5 #ifndef CHROME_BROWSER_UI_VIEWS_EXTENSIONS_EXTENSION_VIEW_H_ |
6 #define CHROME_BROWSER_UI_VIEWS_EXTENSIONS_EXTENSION_VIEW_H_ | 6 #define CHROME_BROWSER_UI_VIEWS_EXTENSIONS_EXTENSION_VIEW_H_ |
7 | 7 |
8 #include "build/build_config.h" | 8 #include "build/build_config.h" |
9 | 9 |
10 #include "third_party/skia/include/core/SkBitmap.h" | 10 #include "third_party/skia/include/core/SkBitmap.h" |
11 #include "ui/views/controls/native/native_view_host.h" | 11 #include "ui/views/controls/native/native_view_host.h" |
12 | 12 |
13 class Browser; | 13 class Browser; |
14 class ExtensionHost; | |
15 class ExtensionView; | 14 class ExtensionView; |
16 | 15 |
17 namespace extensions { | 16 namespace extensions { |
18 class Extension; | 17 class Extension; |
| 18 class ExtensionHost; |
19 } | 19 } |
20 | 20 |
21 namespace content { | 21 namespace content { |
22 class RenderViewHost; | 22 class RenderViewHost; |
23 } | 23 } |
24 | 24 |
25 // This handles the display portion of an ExtensionHost. | 25 // This handles the display portion of an ExtensionHost. |
26 class ExtensionView : public views::NativeViewHost { | 26 class ExtensionView : public views::NativeViewHost { |
27 public: | 27 public: |
28 ExtensionView(ExtensionHost* host, Browser* browser); | 28 ExtensionView(extensions::ExtensionHost* host, Browser* browser); |
29 virtual ~ExtensionView(); | 29 virtual ~ExtensionView(); |
30 | 30 |
31 // A class that represents the container that this view is in. | 31 // A class that represents the container that this view is in. |
32 // (bottom shelf, side bar, etc.) | 32 // (bottom shelf, side bar, etc.) |
33 class Container { | 33 class Container { |
34 public: | 34 public: |
35 virtual ~Container() {} | 35 virtual ~Container() {} |
36 virtual void OnExtensionSizeChanged(ExtensionView* view) {} | 36 virtual void OnExtensionSizeChanged(ExtensionView* view) {} |
37 virtual void OnViewWasResized() {} | 37 virtual void OnViewWasResized() {} |
38 }; | 38 }; |
39 | 39 |
40 ExtensionHost* host() const { return host_; } | 40 extensions::ExtensionHost* host() const { return host_; } |
41 Browser* browser() const { return browser_; } | 41 Browser* browser() const { return browser_; } |
42 const extensions::Extension* extension() const; | 42 const extensions::Extension* extension() const; |
43 content::RenderViewHost* render_view_host() const; | 43 content::RenderViewHost* render_view_host() const; |
44 void DidStopLoading(); | 44 void DidStopLoading(); |
45 void SetIsClipped(bool is_clipped); | 45 void SetIsClipped(bool is_clipped); |
46 | 46 |
47 // Notification from ExtensionHost. | 47 // Notification from ExtensionHost. |
48 void ResizeDueToAutoResize(const gfx::Size& new_size); | 48 void ResizeDueToAutoResize(const gfx::Size& new_size); |
49 | 49 |
50 // Method for the ExtensionHost to notify us when the RenderViewHost has a | 50 // Method for the ExtensionHost to notify us when the RenderViewHost has a |
(...skipping 12 matching lines...) Expand all Loading... |
63 virtual void ViewHierarchyChanged( | 63 virtual void ViewHierarchyChanged( |
64 bool is_add, views::View *parent, views::View *child) OVERRIDE; | 64 bool is_add, views::View *parent, views::View *child) OVERRIDE; |
65 | 65 |
66 protected: | 66 protected: |
67 // Overridden from views::View. | 67 // Overridden from views::View. |
68 virtual void PreferredSizeChanged() OVERRIDE; | 68 virtual void PreferredSizeChanged() OVERRIDE; |
69 virtual bool SkipDefaultKeyEventProcessing(const views::KeyEvent& e) OVERRIDE; | 69 virtual bool SkipDefaultKeyEventProcessing(const views::KeyEvent& e) OVERRIDE; |
70 virtual void OnBoundsChanged(const gfx::Rect& previous_bounds) OVERRIDE; | 70 virtual void OnBoundsChanged(const gfx::Rect& previous_bounds) OVERRIDE; |
71 | 71 |
72 private: | 72 private: |
73 friend class ExtensionHost; | 73 friend class extensions::ExtensionHost; |
74 | 74 |
75 // Initializes the RenderWidgetHostView for this object. | 75 // Initializes the RenderWidgetHostView for this object. |
76 void CreateWidgetHostView(); | 76 void CreateWidgetHostView(); |
77 | 77 |
78 // We wait to show the ExtensionView until several things have loaded. | 78 // We wait to show the ExtensionView until several things have loaded. |
79 void ShowIfCompletelyLoaded(); | 79 void ShowIfCompletelyLoaded(); |
80 | 80 |
81 // Restore object to initial state. Called on shutdown or after a renderer | 81 // Restore object to initial state. Called on shutdown or after a renderer |
82 // crash. | 82 // crash. |
83 void CleanUp(); | 83 void CleanUp(); |
84 | 84 |
85 // The running extension instance that we're displaying. | 85 // The running extension instance that we're displaying. |
86 // Note that host_ owns view | 86 // Note that host_ owns view |
87 ExtensionHost* host_; | 87 extensions::ExtensionHost* host_; |
88 | 88 |
89 // The browser window that this view is in. | 89 // The browser window that this view is in. |
90 Browser* browser_; | 90 Browser* browser_; |
91 | 91 |
92 // True if we've been initialized. | 92 // True if we've been initialized. |
93 bool initialized_; | 93 bool initialized_; |
94 | 94 |
95 // The background the view should have once it is initialized. This is set | 95 // The background the view should have once it is initialized. This is set |
96 // when the view has a custom background, but hasn't been initialized yet. | 96 // when the view has a custom background, but hasn't been initialized yet. |
97 SkBitmap pending_background_; | 97 SkBitmap pending_background_; |
98 | 98 |
99 // What we should set the preferred width to once the ExtensionView has | 99 // What we should set the preferred width to once the ExtensionView has |
100 // loaded. | 100 // loaded. |
101 gfx::Size pending_preferred_size_; | 101 gfx::Size pending_preferred_size_; |
102 | 102 |
103 // The container this view is in (not necessarily its direct superview). | 103 // The container this view is in (not necessarily its direct superview). |
104 // Note: the view does not own its container. | 104 // Note: the view does not own its container. |
105 Container* container_; | 105 Container* container_; |
106 | 106 |
107 // Whether this extension view is clipped. | 107 // Whether this extension view is clipped. |
108 bool is_clipped_; | 108 bool is_clipped_; |
109 | 109 |
110 DISALLOW_COPY_AND_ASSIGN(ExtensionView); | 110 DISALLOW_COPY_AND_ASSIGN(ExtensionView); |
111 }; | 111 }; |
112 | 112 |
113 #endif // CHROME_BROWSER_UI_VIEWS_EXTENSIONS_EXTENSION_VIEW_H_ | 113 #endif // CHROME_BROWSER_UI_VIEWS_EXTENSIONS_EXTENSION_VIEW_H_ |
OLD | NEW |