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