| Index: chrome/browser/views/notifications/balloon_view_host.h
|
| ===================================================================
|
| --- chrome/browser/views/notifications/balloon_view_host.h (revision 42363)
|
| +++ chrome/browser/views/notifications/balloon_view_host.h (working copy)
|
| @@ -5,29 +5,14 @@
|
| #ifndef CHROME_BROWSER_VIEWS_NOTIFICATIONS_BALLOON_VIEW_HOST_H_
|
| #define CHROME_BROWSER_VIEWS_NOTIFICATIONS_BALLOON_VIEW_HOST_H_
|
|
|
| -#include "chrome/browser/notifications/balloon.h"
|
| -#include "chrome/browser/notifications/notification.h"
|
| -#include "chrome/browser/renderer_host/render_view_host_delegate.h"
|
| -#include "chrome/browser/renderer_host/site_instance.h"
|
| -#include "chrome/browser/tab_contents/render_view_host_delegate_helper.h"
|
| -#include "chrome/common/renderer_preferences.h"
|
| +#include "chrome/browser/notifications/balloon_host.h"
|
| #include "views/controls/native/native_view_host.h"
|
| -#include "webkit/glue/webpreferences.h"
|
|
|
| -class Profile;
|
| -class RenderViewHost;
|
| -class SkBitmap;
|
| -namespace gfx {
|
| -class Point;
|
| -}
|
| -
|
| // BalloonViewHost class is a delegate to the renderer host for the HTML
|
| // notification. When initialized it creates a new RenderViewHost and loads
|
| // the contents of the toast into it. It also handles links within the toast,
|
| // loading them into a new tab.
|
| -class BalloonViewHost : public views::NativeViewHost,
|
| - public RenderViewHostDelegate,
|
| - public RenderViewHostDelegate::View {
|
| +class BalloonViewHost : public BalloonHost {
|
| public:
|
| explicit BalloonViewHost(Balloon* balloon);
|
|
|
| @@ -35,103 +20,38 @@
|
| Shutdown();
|
| }
|
|
|
| - // Stops showing the balloon.
|
| - void Shutdown();
|
| + void SetPreferredSize(const gfx::Size& size) {
|
| + native_host_->SetPreferredSize(size);
|
| + }
|
|
|
| - // RenderViewHostDelegate overrides.
|
| - virtual WebPreferences GetWebkitPrefs();
|
| - virtual SiteInstance* GetSiteInstance() const {
|
| - return site_instance_.get();
|
| + // Accessors.
|
| + views::View* view() {
|
| + return native_host_.get();
|
| }
|
| - virtual Profile* GetProfile() const { return balloon_->profile(); }
|
| - virtual const GURL& GetURL() const {
|
| - return balloon_->notification().content_url();
|
| - }
|
| - virtual void Close(RenderViewHost* render_view_host);
|
| - virtual void RenderViewCreated(RenderViewHost* render_view_host);
|
| - virtual void RendererReady(RenderViewHost* render_view_host);
|
| - virtual void RendererGone(RenderViewHost* render_view_host);
|
| - virtual void UpdateTitle(RenderViewHost* /* render_view_host */,
|
| - int32 /* page_id */, const std::wstring& title) {
|
| - title_ = title;
|
| - }
|
| - virtual int GetBrowserWindowID() const { return -1; }
|
| - virtual ViewType::Type GetRenderViewType() const {
|
| - return ViewType::TAB_CONTENTS;
|
| - }
|
| - virtual RenderViewHostDelegate::View* GetViewDelegate() {
|
| - return this;
|
| - }
|
|
|
| - // RenderViewHostDelegate::View methods. Only the ones for opening new
|
| - // windows are currently implemented.
|
| - virtual void CreateNewWindow(int route_id);
|
| - virtual void CreateNewWidget(int route_id, bool activatable) {}
|
| - virtual void ShowCreatedWindow(int route_id,
|
| - WindowOpenDisposition disposition,
|
| - const gfx::Rect& initial_pos,
|
| - bool user_gesture);
|
| - virtual void ShowCreatedWidget(int route_id,
|
| - const gfx::Rect& initial_pos) {}
|
| - virtual void ShowContextMenu(const ContextMenuParams& params) {}
|
| - virtual void StartDragging(const WebDropData& drop_data,
|
| - WebKit::WebDragOperationsMask allowed_ops,
|
| - const SkBitmap& image,
|
| - const gfx::Point& image_offset) {}
|
| - virtual void UpdateDragCursor(WebKit::WebDragOperation operation) {}
|
| - virtual void GotFocus() {}
|
| - virtual void TakeFocus(bool reverse) {}
|
| - virtual bool PreHandleKeyboardEvent(const NativeWebKeyboardEvent& event,
|
| - bool* is_keyboard_shortcut) {
|
| - return false;
|
| + gfx::NativeView native_view() const {
|
| + return native_host_->native_view();
|
| }
|
| - virtual void HandleKeyboardEvent(const NativeWebKeyboardEvent& event) {}
|
| - virtual void HandleMouseEvent() {}
|
| - virtual void HandleMouseLeave() {}
|
| - virtual void UpdatePreferredSize(const gfx::Size& pref_size);
|
| - virtual RendererPreferences GetRendererPrefs(Profile* profile) const {
|
| - return RendererPreferences();
|
| - }
|
|
|
| - // Accessors.
|
| - RenderViewHost* render_view_host() const { return render_view_host_; }
|
| - const std::wstring& title() const { return title_; }
|
| -
|
| - private:
|
| - // View overrides.
|
| - virtual void ViewHierarchyChanged(bool is_add,
|
| - views::View *parent,
|
| - views::View *child);
|
| -
|
| // Initialize the view, parented to |parent|, and show it.
|
| void Init(gfx::NativeView parent);
|
|
|
| - // True after Init() has completed.
|
| - bool initialized_;
|
| + protected:
|
| + virtual void InitRenderWidgetHostView();
|
| + virtual RenderWidgetHostView* render_widget_host_view() const {
|
| + return render_widget_host_view_;
|
| + }
|
|
|
| - // Non-owned pointer to the associated balloon.
|
| - Balloon* balloon_;
|
| + private:
|
| + // The platform-specific widget host view. Pointer is owned by the RVH.
|
| + RenderWidgetHostView* render_widget_host_view_;
|
|
|
| - // Site instance for the balloon/profile, to be used for opening new links.
|
| - scoped_refptr<SiteInstance> site_instance_;
|
| + // The views-specific host view.
|
| + scoped_ptr<views::NativeViewHost> native_host_;
|
|
|
| - // Owned pointer to to host for the renderer process.
|
| - RenderViewHost* render_view_host_;
|
| + // The handle to the parent view.
|
| + gfx::NativeView parent_native_view_;
|
|
|
| - // Indicates whether we should notify about disconnection of this balloon.
|
| - // This is used to ensure disconnection notifications only happen if
|
| - // a connection notification has happened and that they happen only once.
|
| - bool should_notify_on_disconnect_;
|
| -
|
| - // The title of the balloon page.
|
| - std::wstring title_;
|
| -
|
| - // Whether the page we are rendering is from an extension.
|
| - bool is_extension_page_;
|
| -
|
| - // Common implementations of some RenderViewHostDelegate::View methods.
|
| - RenderViewHostDelegateViewHelper delegate_view_helper_;
|
| -
|
| DISALLOW_COPY_AND_ASSIGN(BalloonViewHost);
|
| };
|
|
|
|
|