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 3 // found in the LICENSE file. 4 5 #ifndef CHROME_BROWSER_UI_GTK_EXTENSIONS_EXTENSION_VIEW_GTK_H_ 6 #define CHROME_BROWSER_UI_GTK_EXTENSIONS_EXTENSION_VIEW_GTK_H_ 7 #pragma once 8 9 #include "base/basictypes.h" 10 #include "third_party/skia/include/core/SkBitmap.h" 11 #include "ui/gfx/native_widget_types.h" 12 #include "ui/gfx/size.h" 13 14 class Browser; 15 class ExtensionHost; 16 class RenderViewHost; 17 class RenderWidgetHostViewGtk; 18 class SkBitmap; 19 20 class ExtensionViewGtk { 21 public: 22 ExtensionViewGtk(ExtensionHost* extension_host, Browser* browser); 23 24 class Container { 25 public: ~Container()26 virtual ~Container() {} OnExtensionPreferredSizeChanged(ExtensionViewGtk * view,const gfx::Size & new_size)27 virtual void OnExtensionPreferredSizeChanged(ExtensionViewGtk* view, 28 const gfx::Size& new_size) {} 29 }; 30 31 void Init(); 32 33 gfx::NativeView native_view(); browser()34 Browser* browser() const { return browser_; } 35 36 void SetBackground(const SkBitmap& background); 37 38 // Sets the container for this view. SetContainer(Container * container)39 void SetContainer(Container* container) { container_ = container; } 40 41 // Method for the ExtensionHost to notify us about the correct size for 42 // extension contents. 43 void UpdatePreferredSize(const gfx::Size& new_size); 44 45 // Method for the ExtensionHost to notify us when the RenderViewHost has a 46 // connection. 47 void RenderViewCreated(); 48 49 RenderViewHost* render_view_host() const; 50 51 private: 52 void CreateWidgetHostView(); 53 54 Browser* browser_; 55 56 ExtensionHost* extension_host_; 57 58 RenderWidgetHostViewGtk* render_widget_host_view_; 59 60 // The background the view should have once it is initialized. This is set 61 // when the view has a custom background, but hasn't been initialized yet. 62 SkBitmap pending_background_; 63 64 // This view's container. 65 Container* container_; 66 67 DISALLOW_COPY_AND_ASSIGN(ExtensionViewGtk); 68 }; 69 70 #endif // CHROME_BROWSER_UI_GTK_EXTENSIONS_EXTENSION_VIEW_GTK_H_ 71