| OLD | NEW | 
|    1 // Copyright (c) 2010 The Chromium Authors. All rights reserved. |    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 |    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_GTK_NOTIFICATIONS_BALLOON_VIEW_HOST_GTK_H_ |    5 #ifndef CHROME_BROWSER_GTK_NOTIFICATIONS_BALLOON_VIEW_HOST_GTK_H_ | 
|    6 #define CHROME_BROWSER_GTK_NOTIFICATIONS_BALLOON_VIEW_HOST_GTK_H_ |    6 #define CHROME_BROWSER_GTK_NOTIFICATIONS_BALLOON_VIEW_HOST_GTK_H_ | 
|    7  |    7  | 
|    8 #include "chrome/browser/gtk/extension_view_gtk.h" |    8 #include "chrome/browser/notifications/balloon_host.h" | 
|    9 #include "chrome/browser/notifications/balloon.h" |  | 
|   10 #include "chrome/browser/notifications/notification.h" |  | 
|   11 #include "chrome/browser/renderer_host/render_view_host_delegate.h" |  | 
|   12 #include "chrome/browser/renderer_host/render_widget_host_view_gtk.h" |  | 
|   13 #include "chrome/browser/renderer_host/site_instance.h" |  | 
|   14 #include "chrome/browser/tab_contents/render_view_host_delegate_helper.h" |  | 
|   15 #include "gfx/native_widget_types.h" |    9 #include "gfx/native_widget_types.h" | 
|   16 #include "webkit/glue/webpreferences.h" |  | 
|   17  |   10  | 
|   18 class Profile; |   11 class RenderWidgetHostViewGtk; | 
|   19 class RenderViewHost; |  | 
|   20  |   12  | 
|   21 // BalloonViewHost class is a delegate to the renderer host for the HTML |   13 // BalloonViewHost class is a delegate to the renderer host for the HTML | 
|   22 // notification.  When initialized it creates a new RenderViewHost and loads |   14 // notification.  When initialized it creates a new RenderViewHost and loads | 
|   23 // the contents of the toast into it.  It also handles links within the toast, |   15 // the contents of the toast into it.  It also handles links within the toast, | 
|   24 // loading them into a new tab. |   16 // loading them into a new tab. | 
|   25 class BalloonViewHost : public RenderViewHostDelegate, |   17 class BalloonViewHost : public BalloonHost { | 
|   26                         public RenderViewHostDelegate::View { |  | 
|   27  public: |   18  public: | 
|   28   explicit BalloonViewHost(Balloon* balloon); |   19   explicit BalloonViewHost(Balloon* balloon); | 
|   29  |   20  | 
|   30   ~BalloonViewHost() { |   21   ~BalloonViewHost() { | 
|   31      Shutdown(); |   22      Shutdown(); | 
|   32   } |   23   } | 
|   33  |   24  | 
|   34   // Initialize the view. |   25   // Changes the size of the balloon. | 
|   35   void Init(); |  | 
|   36  |  | 
|   37   // Stops showing the balloon. |  | 
|   38   void Shutdown(); |  | 
|   39  |  | 
|   40   // RenderViewHostDelegate overrides. |  | 
|   41   virtual WebPreferences GetWebkitPrefs(); |  | 
|   42   virtual RendererPreferences GetRendererPrefs(Profile* profile) const; |  | 
|   43   virtual SiteInstance* GetSiteInstance() const { |  | 
|   44     return site_instance_.get(); |  | 
|   45   } |  | 
|   46   virtual Profile* GetProfile() const { return balloon_->profile(); } |  | 
|   47   virtual const GURL& GetURL() const { |  | 
|   48     return balloon_->notification().content_url(); |  | 
|   49   } |  | 
|   50   virtual void RequestOpenURL(const GURL& url, const GURL& referrer, |  | 
|   51                               WindowOpenDisposition disposition); |  | 
|   52   virtual void Close(RenderViewHost* render_view_host); |  | 
|   53   virtual void RenderViewCreated(RenderViewHost* render_view_host); |  | 
|   54   virtual void DidStopLoading() {} |  | 
|   55   virtual void RendererReady(RenderViewHost* render_view_host); |  | 
|   56   virtual void RendererGone(RenderViewHost* render_view_host); |  | 
|   57   virtual void UpdateTitle(RenderViewHost* /* render_view_host */, |  | 
|   58                            int32 /* page_id */, const std::wstring& title) { |  | 
|   59     title_ = title; |  | 
|   60   } |  | 
|   61   virtual int GetBrowserWindowID() const { return -1; } |  | 
|   62   virtual ViewType::Type GetRenderViewType() const { |  | 
|   63     return ViewType::TAB_CONTENTS; |  | 
|   64   } |  | 
|   65   virtual RenderViewHostDelegate::View* GetViewDelegate() { |  | 
|   66     return this; |  | 
|   67   } |  | 
|   68  |  | 
|   69   void UpdateActualSize(const gfx::Size& new_size); |   26   void UpdateActualSize(const gfx::Size& new_size); | 
|   70  |   27  | 
|   71   // RenderViewHostDelegate::View methods. Only the ones for opening new |   28   // Accessors. | 
|   72   // windows are currently implemented. |   29   gfx::NativeView native_view() const; | 
|   73   virtual void CreateNewWindow(int route_id); |  | 
|   74   virtual void CreateNewWidget(int route_id, bool activatable) {} |  | 
|   75   virtual void ShowCreatedWindow(int route_id, |  | 
|   76                                  WindowOpenDisposition disposition, |  | 
|   77                                  const gfx::Rect& initial_pos, |  | 
|   78                                  bool user_gesture); |  | 
|   79   virtual void ShowCreatedWidget(int route_id, |  | 
|   80                                  const gfx::Rect& initial_pos) {} |  | 
|   81   virtual void ShowContextMenu(const ContextMenuParams& params) {} |  | 
|   82   virtual void StartDragging(const WebDropData& drop_data, |  | 
|   83                              WebKit::WebDragOperationsMask allowed_ops, |  | 
|   84                              const SkBitmap& image, |  | 
|   85                              const gfx::Point& image_offset) {} |  | 
|   86   virtual void UpdateDragCursor(WebKit::WebDragOperation operation) {} |  | 
|   87   virtual void GotFocus() {} |  | 
|   88   virtual void TakeFocus(bool reverse) {} |  | 
|   89   virtual bool PreHandleKeyboardEvent(const NativeWebKeyboardEvent& event, |  | 
|   90                                       bool* is_keyboard_shortcut) { |  | 
|   91     return false; |  | 
|   92   } |  | 
|   93   virtual void HandleKeyboardEvent(const NativeWebKeyboardEvent& event) {} |  | 
|   94   virtual void HandleMouseEvent() {} |  | 
|   95   virtual void HandleMouseLeave() {} |  | 
|   96   virtual void UpdatePreferredSize(const gfx::Size& pref_size); |  | 
|   97  |   30  | 
|   98   // Accessors. |   31  protected: | 
|   99   RenderViewHost* render_view_host() const { return render_view_host_; } |   32   virtual void InitRenderWidgetHostView(); | 
|  100   gfx::NativeView native_view() const { |   33   virtual RenderWidgetHostView* render_widget_host_view() const; | 
|  101     return render_widget_host_view_->native_view(); |  | 
|  102   } |  | 
|  103   const std::wstring& title() const { return title_; } |  | 
|  104  |   34  | 
|  105  private: |   35  private: | 
|  106   // True after Init() has completed. |   36   // The GTK-specific widget host view.  Owned by its native view. | 
|  107   bool initialized_; |  | 
|  108  |  | 
|  109   // Non-owned pointer to the associated balloon. |  | 
|  110   Balloon* balloon_; |  | 
|  111  |  | 
|  112   // Site instance for the balloon/profile, to be used for opening new links. |  | 
|  113   scoped_refptr<SiteInstance> site_instance_; |  | 
|  114  |  | 
|  115   // Owned pointer to to host for the renderer process. |  | 
|  116   RenderViewHost* render_view_host_; |  | 
|  117  |  | 
|  118   // Indicates whether we should notify about disconnection of this balloon. |  | 
|  119   // This is used to ensure disconnection notifications only happen if |  | 
|  120   // a connection notification has happened and that they happen only once. |  | 
|  121   bool should_notify_on_disconnect_; |  | 
|  122  |  | 
|  123   // The title of the balloon page. |  | 
|  124   std::wstring title_; |  | 
|  125  |  | 
|  126   // The GTK-specific widget host view. |  | 
|  127   RenderWidgetHostViewGtk* render_widget_host_view_; |   37   RenderWidgetHostViewGtk* render_widget_host_view_; | 
|  128  |   38  | 
|  129   // Common implementations of some RenderViewHostDelegate::View methods. |  | 
|  130   RenderViewHostDelegateViewHelper delegate_view_helper_; |  | 
|  131  |  | 
|  132   DISALLOW_COPY_AND_ASSIGN(BalloonViewHost); |   39   DISALLOW_COPY_AND_ASSIGN(BalloonViewHost); | 
|  133 }; |   40 }; | 
|  134  |   41  | 
|  135 #endif  // CHROME_BROWSER_GTK_NOTIFICATIONS_BALLOON_VIEW_HOST_GTK_H_ |   42 #endif  // CHROME_BROWSER_GTK_NOTIFICATIONS_BALLOON_VIEW_HOST_GTK_H_ | 
| OLD | NEW |