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

Side by Side Diff: chrome/browser/notifications/balloon_host.cc

Issue 6794035: Move dispatching and sending of the last extension specific messages out of TabContents and Rende... (Closed) Base URL: svn://chrome-svn/chrome/trunk/src/
Patch Set: '' Created 9 years, 8 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
1 // Copyright (c) 2011 The Chromium Authors. All rights reserved. 1 // Copyright (c) 2011 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 #include "chrome/browser/notifications/balloon_host.h" 5 #include "chrome/browser/notifications/balloon_host.h"
6 6
7 #include "chrome/browser/browser_list.h" 7 #include "chrome/browser/browser_list.h"
8 #include "chrome/browser/extensions/extension_message_handler.h"
8 #include "chrome/browser/extensions/extension_process_manager.h" 9 #include "chrome/browser/extensions/extension_process_manager.h"
9 #include "chrome/browser/extensions/extension_service.h" 10 #include "chrome/browser/extensions/extension_service.h"
10 #include "chrome/browser/notifications/balloon.h" 11 #include "chrome/browser/notifications/balloon.h"
11 #include "chrome/browser/notifications/notification.h" 12 #include "chrome/browser/notifications/notification.h"
12 #include "chrome/browser/profiles/profile.h" 13 #include "chrome/browser/profiles/profile.h"
13 #include "chrome/browser/renderer_host/browser_render_process_host.h" 14 #include "chrome/browser/renderer_host/browser_render_process_host.h"
14 #include "chrome/browser/renderer_preferences_util.h" 15 #include "chrome/browser/renderer_preferences_util.h"
15 #include "chrome/browser/ui/webui/chrome_web_ui_factory.h" 16 #include "chrome/browser/ui/webui/chrome_web_ui_factory.h"
16 #include "chrome/common/bindings_policy.h" 17 #include "chrome/common/bindings_policy.h"
17 #include "chrome/common/render_messages.h" 18 #include "chrome/common/render_messages.h"
(...skipping 45 matching lines...) Expand 10 before | Expand all | Expand 10 after
63 // TODO(aa): Should this return the native view of the BalloonView*? 64 // TODO(aa): Should this return the native view of the BalloonView*?
64 return NULL; 65 return NULL;
65 } 66 }
66 67
67 TabContents* BalloonHost::associated_tab_contents() const { return NULL; } 68 TabContents* BalloonHost::associated_tab_contents() const { return NULL; }
68 69
69 const string16& BalloonHost::GetSource() const { 70 const string16& BalloonHost::GetSource() const {
70 return balloon_->notification().display_source(); 71 return balloon_->notification().display_source();
71 } 72 }
72 73
74 bool BalloonHost::OnMessageReceived(const IPC::Message& message) {
75 if (!extension_message_handler_.get())
76 return false;
77 return extension_message_handler_->OnMessageReceived(message);
78 }
79
73 WebPreferences BalloonHost::GetWebkitPrefs() { 80 WebPreferences BalloonHost::GetWebkitPrefs() {
74 WebPreferences web_prefs = 81 WebPreferences web_prefs =
75 RenderViewHostDelegateHelper::GetWebkitPrefs(GetProfile(), 82 RenderViewHostDelegateHelper::GetWebkitPrefs(GetProfile(),
76 enable_web_ui_); 83 enable_web_ui_);
77 web_prefs.allow_scripts_to_close_windows = true; 84 web_prefs.allow_scripts_to_close_windows = true;
78 return web_prefs; 85 return web_prefs;
79 } 86 }
80 87
81 SiteInstance* BalloonHost::GetSiteInstance() const { 88 SiteInstance* BalloonHost::GetSiteInstance() const {
82 return site_instance_.get(); 89 return site_instance_.get();
(...skipping 42 matching lines...) Expand 10 before | Expand all | Expand 10 after
125 } 132 }
126 133
127 ViewType::Type BalloonHost::GetRenderViewType() const { 134 ViewType::Type BalloonHost::GetRenderViewType() const {
128 return ViewType::NOTIFICATION; 135 return ViewType::NOTIFICATION;
129 } 136 }
130 137
131 RenderViewHostDelegate::View* BalloonHost::GetViewDelegate() { 138 RenderViewHostDelegate::View* BalloonHost::GetViewDelegate() {
132 return this; 139 return this;
133 } 140 }
134 141
135 void BalloonHost::ProcessWebUIMessage(
136 const ExtensionHostMsg_DomMessage_Params& params) {
137 if (extension_function_dispatcher_.get()) {
138 extension_function_dispatcher_->HandleRequest(params);
139 }
140 }
141
142 // RenderViewHostDelegate::View methods implemented to allow links to 142 // RenderViewHostDelegate::View methods implemented to allow links to
143 // open pages in new tabs. 143 // open pages in new tabs.
144 void BalloonHost::CreateNewWindow( 144 void BalloonHost::CreateNewWindow(
145 int route_id, 145 int route_id,
146 const ViewHostMsg_CreateWindow_Params& params) { 146 const ViewHostMsg_CreateWindow_Params& params) {
147 delegate_view_helper_.CreateNewWindow( 147 delegate_view_helper_.CreateNewWindow(
148 route_id, 148 route_id,
149 balloon_->profile(), 149 balloon_->profile(),
150 site_instance_.get(), 150 site_instance_.get(),
151 ChromeWebUIFactory::GetInstance()->GetWebUIType(balloon_->profile(), 151 ChromeWebUIFactory::GetInstance()->GetWebUIType(balloon_->profile(),
(...skipping 50 matching lines...) Expand 10 before | Expand all | Expand 10 after
202 rvh, this, balloon_->notification().content_url())); 202 rvh, this, balloon_->notification().content_url()));
203 } 203 }
204 if (extension_function_dispatcher_.get()) { 204 if (extension_function_dispatcher_.get()) {
205 rvh->AllowBindings(BindingsPolicy::EXTENSION); 205 rvh->AllowBindings(BindingsPolicy::EXTENSION);
206 rvh->set_is_extension_process(true); 206 rvh->set_is_extension_process(true);
207 const Extension* installed_app = 207 const Extension* installed_app =
208 GetProfile()->GetExtensionService()->GetInstalledApp( 208 GetProfile()->GetExtensionService()->GetInstalledApp(
209 balloon_->notification().content_url()); 209 balloon_->notification().content_url());
210 static_cast<BrowserRenderProcessHost*>(rvh->process())->set_installed_app( 210 static_cast<BrowserRenderProcessHost*>(rvh->process())->set_installed_app(
211 installed_app); 211 installed_app);
212
213 extension_message_handler_.reset(new ExtensionMessageHandler(
214 rvh->process()->id(), rvh, GetProfile()));
215 extension_message_handler_->set_extension_function_dispatcher(
216 extension_function_dispatcher_.get());
212 } else if (enable_web_ui_) { 217 } else if (enable_web_ui_) {
213 rvh->AllowBindings(BindingsPolicy::WEB_UI); 218 rvh->AllowBindings(BindingsPolicy::WEB_UI);
214 } 219 }
215 220
216 // Do platform-specific initialization. 221 // Do platform-specific initialization.
217 render_view_host_ = rvh; 222 render_view_host_ = rvh;
218 InitRenderWidgetHostView(); 223 InitRenderWidgetHostView();
219 DCHECK(render_widget_host_view()); 224 DCHECK(render_widget_host_view());
220 225
221 rvh->set_view(render_widget_host_view()); 226 rvh->set_view(render_widget_host_view());
(...skipping 39 matching lines...) Expand 10 before | Expand all | Expand 10 after
261 266
262 void BalloonHost::NotifyDisconnect() { 267 void BalloonHost::NotifyDisconnect() {
263 if (!should_notify_on_disconnect_) 268 if (!should_notify_on_disconnect_)
264 return; 269 return;
265 270
266 should_notify_on_disconnect_ = false; 271 should_notify_on_disconnect_ = false;
267 NotificationService::current()->Notify( 272 NotificationService::current()->Notify(
268 NotificationType::NOTIFY_BALLOON_DISCONNECTED, 273 NotificationType::NOTIFY_BALLOON_DISCONNECTED,
269 Source<BalloonHost>(this), NotificationService::NoDetails()); 274 Source<BalloonHost>(this), NotificationService::NoDetails());
270 } 275 }
OLDNEW

Powered by Google App Engine
This is Rietveld 408576698