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

Side by Side Diff: chrome/browser/notifications/balloon_host.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 unified diff | Download patch | Annotate | Revision Log
OLDNEW
(Empty)
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_NOTIFICATIONS_BALLOON_HOST_H_
6 #define CHROME_BROWSER_NOTIFICATIONS_BALLOON_HOST_H_
7
8 #include "chrome/browser/notifications/balloon.h"
9 #include "chrome/browser/notifications/notification.h"
10 #include "chrome/browser/renderer_host/render_view_host_delegate.h"
11 #include "chrome/browser/renderer_host/site_instance.h"
12 #include "chrome/browser/tab_contents/render_view_host_delegate_helper.h"
13 #include "chrome/common/renderer_preferences.h"
14 #include "webkit/glue/webpreferences.h"
15
16 class Profile;
17
18 class BalloonHost : public RenderViewHostDelegate,
19 public RenderViewHostDelegate::View {
20 public:
21 explicit BalloonHost(Balloon* balloon);
22
23 // Initialize the view.
24 void Init();
25
26 // Stops showing the balloon.
27 void Shutdown();
28
29 RenderViewHost* render_view_host() const { return render_view_host_; }
30
31 // RenderViewHostDelegate overrides.
32 virtual WebPreferences GetWebkitPrefs();
33 virtual SiteInstance* GetSiteInstance() const {
34 return site_instance_.get();
35 }
36 virtual Profile* GetProfile() const { return balloon_->profile(); }
37 virtual const GURL& GetURL() const {
38 return balloon_->notification().content_url();
39 }
40 virtual void Close(RenderViewHost* render_view_host);
41 virtual void RenderViewCreated(RenderViewHost* render_view_host);
42 virtual void RendererReady(RenderViewHost* render_view_host);
43 virtual void RendererGone(RenderViewHost* render_view_host);
44 virtual void UpdateTitle(RenderViewHost* render_view_host,
45 int32 page_id, const std::wstring& title) {}
46 virtual int GetBrowserWindowID() const { return -1; }
47 virtual ViewType::Type GetRenderViewType() const {
48 return ViewType::TAB_CONTENTS;
49 }
50 virtual RenderViewHostDelegate::View* GetViewDelegate() {
51 return this;
52 }
53
54 // RenderViewHostDelegate::View methods. Only the ones for opening new
55 // windows are currently implemented.
56 virtual void CreateNewWindow(int route_id);
57 virtual void CreateNewWidget(int route_id, bool activatable) {}
58 virtual void ShowCreatedWindow(int route_id,
59 WindowOpenDisposition disposition,
60 const gfx::Rect& initial_pos,
61 bool user_gesture);
62 virtual void ShowCreatedWidget(int route_id,
63 const gfx::Rect& initial_pos) {}
64 virtual void ShowContextMenu(const ContextMenuParams& params) {}
65 virtual void StartDragging(const WebDropData& drop_data,
66 WebKit::WebDragOperationsMask allowed_ops) {}
67 virtual void StartDragging(const WebDropData&,
68 WebKit::WebDragOperationsMask,
69 const SkBitmap&,
70 const gfx::Point&) {}
71 virtual void UpdateDragCursor(WebKit::WebDragOperation operation) {}
72 virtual void GotFocus() {}
73 virtual void TakeFocus(bool reverse) {}
74 virtual bool PreHandleKeyboardEvent(const NativeWebKeyboardEvent& event,
75 bool* is_keyboard_shortcut) {
76 return false;
77 }
78 virtual void HandleKeyboardEvent(const NativeWebKeyboardEvent& event) {}
79 virtual void HandleMouseEvent() {}
80 virtual void HandleMouseLeave() {}
81 virtual void UpdatePreferredSize(const gfx::Size& pref_size);
82 virtual RendererPreferences GetRendererPrefs(Profile* profile) const {
83 return RendererPreferences();
84 }
85
86 protected:
87 // Must override in platform specific implementations.
88 virtual void InitRenderWidgetHostView() = 0;
89 virtual RenderWidgetHostView* render_widget_host_view() const = 0;
90
91 // Owned pointer to to host for the renderer process.
92 RenderViewHost* render_view_host_;
93
94 private:
95 // Non-owned pointer to the associated balloon.
96 Balloon* balloon_;
97
98 // True after Init() has completed.
99 bool initialized_;
100
101 // Indicates whether we should notify about disconnection of this balloon.
102 // This is used to ensure disconnection notifications only happen if
103 // a connection notification has happened and that they happen only once.
104 bool should_notify_on_disconnect_;
105
106 // Whether the page we are rendering is from an extension.
107 bool is_extension_page_;
108
109 // Site instance for the balloon/profile, to be used for opening new links.
110 scoped_refptr<SiteInstance> site_instance_;
111
112 // Common implementations of some RenderViewHostDelegate::View methods.
113 RenderViewHostDelegateViewHelper delegate_view_helper_;
114 };
115
116 #endif // CHROME_BROWSER_NOTIFICATIONS_BALLOON_HOST_H_
OLDNEW
« no previous file with comments | « chrome/browser/gtk/notifications/balloon_view_host_gtk.cc ('k') | chrome/browser/notifications/balloon_host.cc » ('j') | no next file with comments »

Powered by Google App Engine
This is Rietveld 408576698