Chromium Code Reviews
chromiumcodereview-hr@appspot.gserviceaccount.com (chromiumcodereview-hr) | Please choose your nickname with Settings | Help | Chromium Project | Gerrit Changes | Sign out
(5177)

Unified Diff: chrome/browser/gtk/notifications/balloon_view_host_gtk.h

Issue 1055005: Refactor BalloonViewHost, removing a lot of duplicate code that crept into no... (Closed) Base URL: http://src.chromium.org/svn/trunk/src/
Patch Set: '' Created 10 years, 9 months ago
Use n/p to move between diff chunks; N/P to move between comments. Draft comments are only viewable by you.
Jump to:
View side-by-side diff with in-line comments
Download patch
Index: chrome/browser/gtk/notifications/balloon_view_host_gtk.h
===================================================================
--- chrome/browser/gtk/notifications/balloon_view_host_gtk.h (revision 42363)
+++ chrome/browser/gtk/notifications/balloon_view_host_gtk.h (working copy)
@@ -5,25 +5,16 @@
#ifndef CHROME_BROWSER_GTK_NOTIFICATIONS_BALLOON_VIEW_HOST_GTK_H_
#define CHROME_BROWSER_GTK_NOTIFICATIONS_BALLOON_VIEW_HOST_GTK_H_
-#include "chrome/browser/gtk/extension_view_gtk.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/render_widget_host_view_gtk.h"
-#include "chrome/browser/renderer_host/site_instance.h"
-#include "chrome/browser/tab_contents/render_view_host_delegate_helper.h"
+#include "chrome/browser/notifications/balloon_host.h"
#include "gfx/native_widget_types.h"
-#include "webkit/glue/webpreferences.h"
-class Profile;
-class RenderViewHost;
+class RenderWidgetHostViewGtk;
// 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 RenderViewHostDelegate,
- public RenderViewHostDelegate::View {
+class BalloonViewHost : public BalloonHost {
public:
explicit BalloonViewHost(Balloon* balloon);
@@ -31,104 +22,20 @@
Shutdown();
}
- // Initialize the view.
- void Init();
-
- // Stops showing the balloon.
- void Shutdown();
-
- // RenderViewHostDelegate overrides.
- virtual WebPreferences GetWebkitPrefs();
- virtual RendererPreferences GetRendererPrefs(Profile* profile) const;
- virtual SiteInstance* GetSiteInstance() const {
- return site_instance_.get();
- }
- virtual Profile* GetProfile() const { return balloon_->profile(); }
- virtual const GURL& GetURL() const {
- return balloon_->notification().content_url();
- }
- virtual void RequestOpenURL(const GURL& url, const GURL& referrer,
- WindowOpenDisposition disposition);
- virtual void Close(RenderViewHost* render_view_host);
- virtual void RenderViewCreated(RenderViewHost* render_view_host);
- virtual void DidStopLoading() {}
- 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;
- }
-
+ // Changes the size of the balloon.
void UpdateActualSize(const gfx::Size& new_size);
- // 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;
- }
- virtual void HandleKeyboardEvent(const NativeWebKeyboardEvent& event) {}
- virtual void HandleMouseEvent() {}
- virtual void HandleMouseLeave() {}
- virtual void UpdatePreferredSize(const gfx::Size& pref_size);
-
// Accessors.
- RenderViewHost* render_view_host() const { return render_view_host_; }
- gfx::NativeView native_view() const {
- return render_widget_host_view_->native_view();
- }
- const std::wstring& title() const { return title_; }
+ gfx::NativeView native_view() const;
- private:
- // True after Init() has completed.
- bool initialized_;
+ protected:
+ virtual void InitRenderWidgetHostView();
+ virtual RenderWidgetHostView* render_widget_host_view() const;
- // Non-owned pointer to the associated balloon.
- Balloon* balloon_;
-
- // Site instance for the balloon/profile, to be used for opening new links.
- scoped_refptr<SiteInstance> site_instance_;
-
- // Owned pointer to to host for the renderer process.
- RenderViewHost* render_view_host_;
-
- // 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_;
-
- // The GTK-specific widget host view.
+ private:
+ // The GTK-specific widget host view. Owned by its native view.
RenderWidgetHostViewGtk* render_widget_host_view_;
- // Common implementations of some RenderViewHostDelegate::View methods.
- RenderViewHostDelegateViewHelper delegate_view_helper_;
-
DISALLOW_COPY_AND_ASSIGN(BalloonViewHost);
};
« no previous file with comments | « chrome/browser/cocoa/notifications/balloon_view_host_mac.mm ('k') | chrome/browser/gtk/notifications/balloon_view_host_gtk.cc » ('j') | no next file with comments »

Powered by Google App Engine
This is Rietveld 408576698