Chromium Code Reviews| 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_VIEWS_H_ | 5 #ifndef CHROME_BROWSER_UI_VIEWS_EXTENSIONS_EXTENSION_VIEW_VIEWS_H_ |
| 6 #define CHROME_BROWSER_UI_VIEWS_EXTENSIONS_EXTENSION_VIEW_VIEWS_H_ | 6 #define CHROME_BROWSER_UI_VIEWS_EXTENSIONS_EXTENSION_VIEW_VIEWS_H_ |
| 7 | 7 |
| 8 #include "base/basictypes.h" | 8 #include "base/basictypes.h" |
| 9 #include "base/compiler_specific.h" | 9 #include "base/compiler_specific.h" |
| 10 #include "chrome/browser/extensions/extension_view.h" | |
| 10 #include "third_party/skia/include/core/SkBitmap.h" | 11 #include "third_party/skia/include/core/SkBitmap.h" |
| 11 #include "ui/views/controls/native/native_view_host.h" | 12 #include "ui/views/controls/native/native_view_host.h" |
| 12 | 13 |
| 13 class Browser; | |
| 14 | |
| 15 namespace content { | 14 namespace content { |
| 16 class RenderViewHost; | 15 class RenderViewHost; |
| 17 } | 16 } |
| 18 | 17 |
| 19 namespace extensions { | 18 namespace extensions { |
| 20 class Extension; | 19 class Extension; |
| 21 class ExtensionHost; | 20 class ExtensionHost; |
| 22 } | 21 } |
| 23 | 22 |
| 24 // This handles the display portion of an ExtensionHost. | 23 // This handles the display portion of an ExtensionHost. |
| 25 class ExtensionViewViews : public views::NativeViewHost { | 24 class ExtensionViewViews : public ExtensionView, |
|
Ben Goodger (Google)
2012/09/17 16:07:17
Because ExtensionViews are owned by the ExtensionH
tfarina
2012/09/19 01:21:39
Done.
| |
| 25 public views::NativeViewHost { | |
| 26 public: | 26 public: |
| 27 ExtensionViewViews(extensions::ExtensionHost* host, Browser* browser); | 27 ExtensionViewViews(extensions::ExtensionHost* host, Browser* browser); |
| 28 virtual ~ExtensionViewViews(); | 28 virtual ~ExtensionViewViews(); |
| 29 | 29 |
| 30 // A class that represents the container that this view is in. | |
| 31 // (bottom shelf, side bar, etc.) | |
| 32 class Container { | |
| 33 public: | |
| 34 virtual ~Container() {} | |
| 35 virtual void OnExtensionSizeChanged(ExtensionViewViews* view) {} | |
| 36 virtual void OnViewWasResized() {} | |
| 37 }; | |
| 38 | |
| 39 extensions::ExtensionHost* host() const { return host_; } | |
| 40 Browser* browser() const { return browser_; } | |
| 41 const extensions::Extension* extension() const; | |
| 42 content::RenderViewHost* render_view_host() const; | |
| 43 void DidStopLoading(); | |
| 44 void SetIsClipped(bool is_clipped); | |
| 45 | |
| 46 // Notification from ExtensionHost. | |
| 47 void ResizeDueToAutoResize(const gfx::Size& new_size); | |
| 48 | |
| 49 // Method for the ExtensionHost to notify us when the RenderViewHost has a | |
| 50 // connection. | |
| 51 void RenderViewCreated(); | |
| 52 | |
| 53 // Set a custom background for the view. The background will be tiled. | 30 // Set a custom background for the view. The background will be tiled. |
| 54 void SetBackground(const SkBitmap& background); | 31 void SetBackground(const SkBitmap& background); |
| 55 | 32 |
| 56 // Sets the container for this view. | 33 // Overridden from views::View: |
| 57 void SetContainer(Container* container) { container_ = container; } | 34 virtual void SetVisible(bool is_visible) OVERRIDE; |
| 58 | 35 |
| 36 protected: | |
| 59 // Overridden from views::NativeViewHost: | 37 // Overridden from views::NativeViewHost: |
| 60 virtual gfx::NativeCursor GetCursor(const ui::MouseEvent& event) OVERRIDE; | 38 virtual gfx::NativeCursor GetCursor(const ui::MouseEvent& event) OVERRIDE; |
| 61 virtual void SetVisible(bool is_visible) OVERRIDE; | |
| 62 virtual void ViewHierarchyChanged(bool is_add, | 39 virtual void ViewHierarchyChanged(bool is_add, |
| 63 views::View* parent, | 40 views::View* parent, |
| 64 views::View* child) OVERRIDE; | 41 views::View* child) OVERRIDE; |
| 65 | 42 |
| 66 protected: | |
| 67 // Overridden from views::View. | 43 // Overridden from views::View. |
| 68 virtual void PreferredSizeChanged() OVERRIDE; | 44 virtual void PreferredSizeChanged() OVERRIDE; |
| 69 virtual bool SkipDefaultKeyEventProcessing(const ui::KeyEvent& e) OVERRIDE; | 45 virtual bool SkipDefaultKeyEventProcessing(const ui::KeyEvent& e) OVERRIDE; |
| 70 virtual void OnBoundsChanged(const gfx::Rect& previous_bounds) OVERRIDE; | 46 virtual void OnBoundsChanged(const gfx::Rect& previous_bounds) OVERRIDE; |
| 71 | 47 |
| 72 private: | 48 private: |
| 73 friend class extensions::ExtensionHost; | 49 friend class extensions::ExtensionHost; |
| 74 | 50 |
| 51 // Overridden from ExtensionView: | |
| 52 virtual Browser* GetBrowser() OVERRIDE; | |
| 53 virtual const Browser* GetBrowser() const OVERRIDE; | |
| 54 virtual gfx::NativeView GetNativeView() OVERRIDE; | |
| 55 virtual content::RenderViewHost* GetRenderViewHost() const OVERRIDE; | |
| 56 virtual void SetContainer(ExtensionViewContainer* container) OVERRIDE; | |
| 57 virtual void ResizeDueToAutoResize(const gfx::Size& new_size) OVERRIDE; | |
| 58 virtual void RenderViewCreated() OVERRIDE; | |
| 59 virtual void DidStopLoading() OVERRIDE; | |
| 60 virtual void WindowFrameChanged() OVERRIDE; | |
| 61 | |
| 75 // Initializes the RenderWidgetHostView for this object. | 62 // Initializes the RenderWidgetHostView for this object. |
| 76 void CreateWidgetHostView(); | 63 void CreateWidgetHostView(); |
| 77 | 64 |
| 78 // We wait to show the ExtensionViewViews until several things have loaded. | 65 // We wait to show the ExtensionViewViews until several things have loaded. |
| 79 void ShowIfCompletelyLoaded(); | 66 void ShowIfCompletelyLoaded(); |
| 80 | 67 |
| 81 // Restore object to initial state. Called on shutdown or after a renderer | 68 // Restore object to initial state. Called on shutdown or after a renderer |
| 82 // crash. | 69 // crash. |
| 83 void CleanUp(); | 70 void CleanUp(); |
| 84 | 71 |
| (...skipping 10 matching lines...) Expand all Loading... | |
| 95 // The background the view should have once it is initialized. This is set | 82 // 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. | 83 // when the view has a custom background, but hasn't been initialized yet. |
| 97 SkBitmap pending_background_; | 84 SkBitmap pending_background_; |
| 98 | 85 |
| 99 // What we should set the preferred width to once the ExtensionViewViews has | 86 // What we should set the preferred width to once the ExtensionViewViews has |
| 100 // loaded. | 87 // loaded. |
| 101 gfx::Size pending_preferred_size_; | 88 gfx::Size pending_preferred_size_; |
| 102 | 89 |
| 103 // The container this view is in (not necessarily its direct superview). | 90 // The container this view is in (not necessarily its direct superview). |
| 104 // Note: the view does not own its container. | 91 // Note: the view does not own its container. |
| 105 Container* container_; | 92 ExtensionViewContainer* container_; |
| 106 | |
| 107 // Whether this extension view is clipped. | |
| 108 bool is_clipped_; | |
| 109 | 93 |
| 110 DISALLOW_COPY_AND_ASSIGN(ExtensionViewViews); | 94 DISALLOW_COPY_AND_ASSIGN(ExtensionViewViews); |
| 111 }; | 95 }; |
| 112 | 96 |
| 113 #endif // CHROME_BROWSER_UI_VIEWS_EXTENSIONS_EXTENSION_VIEW_VIEWS_H_ | 97 #endif // CHROME_BROWSER_UI_VIEWS_EXTENSIONS_EXTENSION_VIEW_VIEWS_H_ |
| OLD | NEW |