| OLD | NEW |
| 1 // Copyright (c) 2006-2009 The Chromium Authors. All rights reserved. | 1 // Copyright (c) 2006-2009 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_EXTENSIONS_EXTENSION_VIEW_H_ | 5 #ifndef CHROME_BROWSER_EXTENSIONS_EXTENSION_VIEW_H_ |
| 6 #define CHROME_BROWSER_EXTENSIONS_EXTENSION_VIEW_H_ | 6 #define CHROME_BROWSER_EXTENSIONS_EXTENSION_VIEW_H_ |
| 7 | 7 |
| 8 #include "build/build_config.h" | 8 #include "build/build_config.h" |
| 9 | 9 |
| 10 #include "base/scoped_ptr.h" | 10 #include "base/scoped_ptr.h" |
| 11 #include "chrome/browser/extensions/extension_host.h" | 11 #include "chrome/browser/extensions/extension_host.h" |
| 12 #include "googleurl/src/gurl.h" | 12 #include "googleurl/src/gurl.h" |
| 13 #include "third_party/skia/include/core/SkBitmap.h" | 13 #include "third_party/skia/include/core/SkBitmap.h" |
| 14 | 14 #include "views/controls/native/native_view_host.h" |
| 15 // TODO(port): Port these files. | |
| 16 #if defined(OS_WIN) | |
| 17 #include "views/controls/hwnd_view.h" | |
| 18 #else | |
| 19 #include "views/view.h" | |
| 20 #include "chrome/common/temp_scaffolding_stubs.h" | |
| 21 #endif | |
| 22 | 15 |
| 23 class Browser; | 16 class Browser; |
| 24 class Extension; | 17 class Extension; |
| 25 | 18 |
| 26 // A class that represents the container that this view is in. | 19 // A class that represents the container that this view is in. |
| 27 // (bottom shelf, side bar, etc.) | 20 // (bottom shelf, side bar, etc.) |
| 28 class ExtensionContainer { | 21 class ExtensionContainer { |
| 29 public: | 22 public: |
| 30 // Mouse event notifications from the view. (useful for hover UI). | 23 // Mouse event notifications from the view. (useful for hover UI). |
| 31 virtual void OnExtensionMouseEvent(ExtensionView* view) = 0; | 24 virtual void OnExtensionMouseEvent(ExtensionView* view) = 0; |
| 32 virtual void OnExtensionMouseLeave(ExtensionView* view) = 0; | 25 virtual void OnExtensionMouseLeave(ExtensionView* view) = 0; |
| 33 }; | 26 }; |
| 34 | 27 |
| 35 // This handles the display portion of an ExtensionHost. | 28 // This handles the display portion of an ExtensionHost. |
| 36 class ExtensionView : public views::HWNDView { | 29 class ExtensionView : public views::NativeViewHost { |
| 37 public: | 30 public: |
| 38 ExtensionView(ExtensionHost* host, Browser* browser, const GURL& content_url); | 31 ExtensionView(ExtensionHost* host, Browser* browser, const GURL& content_url); |
| 39 ~ExtensionView(); | 32 ~ExtensionView(); |
| 40 | 33 |
| 41 ExtensionHost* host() const { return host_.get(); } | 34 ExtensionHost* host() const { return host_.get(); } |
| 42 Browser* browser() const { return browser_; } | 35 Browser* browser() const { return browser_; } |
| 43 Extension* extension() { return host_->extension(); } | 36 Extension* extension() { return host_->extension(); } |
| 44 RenderViewHost* render_view_host() { return host_->render_view_host(); } | 37 RenderViewHost* render_view_host() { return host_->render_view_host(); } |
| 45 | 38 |
| 46 // Notification from ExtensionHost. | 39 // Notification from ExtensionHost. |
| 47 void DidContentsPreferredWidthChange(const int pref_width); | 40 void DidContentsPreferredWidthChange(const int pref_width); |
| 48 void HandleMouseEvent(); | 41 void HandleMouseEvent(); |
| 49 void HandleMouseLeave(); | 42 void HandleMouseLeave(); |
| 50 | 43 |
| 51 // Set a custom background for the view. The background will be tiled. | 44 // Set a custom background for the view. The background will be tiled. |
| 52 void SetBackground(const SkBitmap& background); | 45 void SetBackground(const SkBitmap& background); |
| 53 | 46 |
| 54 // Sets the container for this view. | 47 // Sets the container for this view. |
| 55 void SetContainer(ExtensionContainer* container) { container_ = container; } | 48 void SetContainer(ExtensionContainer* container) { container_ = container; } |
| 56 | 49 |
| 57 // views::HWNDView | 50 // Overridden from views::NativeViewHost: |
| 58 virtual void SetVisible(bool is_visible); | 51 virtual void SetVisible(bool is_visible); |
| 59 virtual void DidChangeBounds(const gfx::Rect& previous, | 52 virtual void DidChangeBounds(const gfx::Rect& previous, |
| 60 const gfx::Rect& current); | 53 const gfx::Rect& current); |
| 61 virtual void ViewHierarchyChanged(bool is_add, | 54 virtual void ViewHierarchyChanged(bool is_add, |
| 62 views::View *parent, views::View *child); | 55 views::View *parent, views::View *child); |
| 63 | 56 |
| 64 private: | 57 private: |
| 65 friend class ExtensionHost; | 58 friend class ExtensionHost; |
| 66 | 59 |
| 67 // We wait to show the ExtensionView until several things have loaded. | 60 // We wait to show the ExtensionView until several things have loaded. |
| (...skipping 20 matching lines...) Expand all Loading... |
| 88 int pending_preferred_width_; | 81 int pending_preferred_width_; |
| 89 | 82 |
| 90 // The container this view is in (not necessarily its direct superview). | 83 // The container this view is in (not necessarily its direct superview). |
| 91 // Note: the view does not own its container. | 84 // Note: the view does not own its container. |
| 92 ExtensionContainer* container_; | 85 ExtensionContainer* container_; |
| 93 | 86 |
| 94 DISALLOW_COPY_AND_ASSIGN(ExtensionView); | 87 DISALLOW_COPY_AND_ASSIGN(ExtensionView); |
| 95 }; | 88 }; |
| 96 | 89 |
| 97 #endif // CHROME_BROWSER_EXTENSIONS_EXTENSION_VIEW_H_ | 90 #endif // CHROME_BROWSER_EXTENSIONS_EXTENSION_VIEW_H_ |
| OLD | NEW |