balloon_view_host.h revision 21d179b334e59e9a3bfcaed4c4430bef1bc5759d
1// Copyright (c) 2010 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_VIEWS_NOTIFICATIONS_BALLOON_VIEW_HOST_H_ 6#define CHROME_BROWSER_UI_VIEWS_NOTIFICATIONS_BALLOON_VIEW_HOST_H_ 7#pragma once 8 9#include "chrome/browser/notifications/balloon_host.h" 10#include "views/controls/native/native_view_host.h" 11 12// BalloonViewHost class is a delegate to the renderer host for the HTML 13// notification. When initialized it creates a new RenderViewHost and loads 14// the contents of the toast into it. It also handles links within the toast, 15// loading them into a new tab. 16class BalloonViewHost : public BalloonHost { 17 public: 18 explicit BalloonViewHost(Balloon* balloon); 19 20 virtual ~BalloonViewHost() { 21 Shutdown(); 22 } 23 24 void SetPreferredSize(const gfx::Size& size) { 25 native_host_->SetPreferredSize(size); 26 } 27 28 // Accessors. 29 views::View* view() { 30 return native_host_; 31 } 32 33 gfx::NativeView native_view() const { 34 return native_host_->native_view(); 35 } 36 37 // Initialize the view, parented to |parent|, and show it. 38 void Init(gfx::NativeView parent); 39 40 protected: 41 virtual void InitRenderWidgetHostView(); 42 virtual RenderWidgetHostView* render_widget_host_view() const; 43 44 private: 45 // The platform-specific widget host view. Pointer is owned by the RVH. 46 RenderWidgetHostView* render_widget_host_view_; 47 48 // The views-specific host view. Pointer owned by the views hierarchy. 49 views::NativeViewHost* native_host_; 50 51 // The handle to the parent view. 52 gfx::NativeView parent_native_view_; 53 54 DISALLOW_COPY_AND_ASSIGN(BalloonViewHost); 55}; 56 57#endif // CHROME_BROWSER_UI_VIEWS_NOTIFICATIONS_BALLOON_VIEW_HOST_H_ 58