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

Side by Side Diff: chrome/browser/chrome_content_browser_client.cc

Issue 7125006: Get rid of Chrome notifications dependency, and instead go through ContentBrowserClient to show U... (Closed) Base URL: svn://chrome-svn/chrome/trunk/src/
Patch Set: fix browsertest Created 9 years, 6 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/chrome_content_browser_client.h" 5 #include "chrome/browser/chrome_content_browser_client.h"
6 6
7 #include "base/command_line.h" 7 #include "base/command_line.h"
8 #include "chrome/app/breakpad_mac.h" 8 #include "chrome/app/breakpad_mac.h"
9 #include "chrome/browser/browser_process.h" 9 #include "chrome/browser/browser_process.h"
10 #include "chrome/browser/character_encoding.h" 10 #include "chrome/browser/character_encoding.h"
11 #include "chrome/browser/chrome_plugin_message_filter.h" 11 #include "chrome/browser/chrome_plugin_message_filter.h"
12 #include "chrome/browser/chrome_quota_permission_context.h" 12 #include "chrome/browser/chrome_quota_permission_context.h"
13 #include "chrome/browser/chrome_worker_message_filter.h" 13 #include "chrome/browser/chrome_worker_message_filter.h"
14 #include "chrome/browser/content_settings/host_content_settings_map.h" 14 #include "chrome/browser/content_settings/host_content_settings_map.h"
15 #include "chrome/browser/content_settings/tab_specific_content_settings.h" 15 #include "chrome/browser/content_settings/tab_specific_content_settings.h"
16 #include "chrome/browser/debugger/devtools_handler.h" 16 #include "chrome/browser/debugger/devtools_handler.h"
17 #include "chrome/browser/desktop_notification_handler.h" 17 #include "chrome/browser/extensions/extension_info_map.h"
18 #include "chrome/browser/extensions/extension_message_handler.h" 18 #include "chrome/browser/extensions/extension_message_handler.h"
19 #include "chrome/browser/extensions/extension_service.h" 19 #include "chrome/browser/extensions/extension_service.h"
20 #include "chrome/browser/google/google_util.h" 20 #include "chrome/browser/google/google_util.h"
21 #include "chrome/browser/notifications/desktop_notification_service.h"
22 #include "chrome/browser/notifications/desktop_notification_service_factory.h"
21 #include "chrome/browser/platform_util.h" 23 #include "chrome/browser/platform_util.h"
22 #include "chrome/browser/prefs/pref_service.h" 24 #include "chrome/browser/prefs/pref_service.h"
23 #include "chrome/browser/printing/printing_message_filter.h" 25 #include "chrome/browser/printing/printing_message_filter.h"
24 #include "chrome/browser/profiles/profile.h" 26 #include "chrome/browser/profiles/profile.h"
25 #include "chrome/browser/profiles/profile_io_data.h" 27 #include "chrome/browser/profiles/profile_io_data.h"
26 #include "chrome/browser/renderer_host/chrome_render_message_filter.h" 28 #include "chrome/browser/renderer_host/chrome_render_message_filter.h"
27 #include "chrome/browser/renderer_host/chrome_render_view_host_observer.h" 29 #include "chrome/browser/renderer_host/chrome_render_view_host_observer.h"
28 #include "chrome/browser/renderer_host/text_input_client_message_filter.h" 30 #include "chrome/browser/renderer_host/text_input_client_message_filter.h"
29 #include "chrome/browser/search_engines/search_provider_install_state_message_fi lter.h" 31 #include "chrome/browser/search_engines/search_provider_install_state_message_fi lter.h"
30 #include "chrome/browser/spellcheck_message_filter.h" 32 #include "chrome/browser/spellcheck_message_filter.h"
31 #include "chrome/browser/ssl/ssl_add_cert_handler.h" 33 #include "chrome/browser/ssl/ssl_add_cert_handler.h"
32 #include "chrome/browser/ssl/ssl_blocking_page.h" 34 #include "chrome/browser/ssl/ssl_blocking_page.h"
33 #include "chrome/browser/tab_contents/tab_contents_ssl_helper.h" 35 #include "chrome/browser/tab_contents/tab_contents_ssl_helper.h"
34 #include "chrome/browser/tab_contents/tab_util.h" 36 #include "chrome/browser/tab_contents/tab_util.h"
35 #include "chrome/browser/ui/tab_contents/tab_contents_wrapper.h" 37 #include "chrome/browser/ui/tab_contents/tab_contents_wrapper.h"
36 #include "chrome/browser/ui/webui/chrome_web_ui_factory.h" 38 #include "chrome/browser/ui/webui/chrome_web_ui_factory.h"
37 #include "chrome/common/child_process_logging.h" 39 #include "chrome/common/child_process_logging.h"
38 #include "chrome/common/chrome_switches.h" 40 #include "chrome/common/chrome_switches.h"
41 #include "chrome/common/extensions/extension.h"
39 #include "chrome/common/extensions/extension_messages.h" 42 #include "chrome/common/extensions/extension_messages.h"
40 #include "chrome/common/pref_names.h" 43 #include "chrome/common/pref_names.h"
41 #include "chrome/common/render_messages.h" 44 #include "chrome/common/render_messages.h"
42 #include "chrome/common/url_constants.h" 45 #include "chrome/common/url_constants.h"
43 #include "content/browser/browsing_instance.h" 46 #include "content/browser/browsing_instance.h"
44 #include "content/browser/child_process_security_policy.h" 47 #include "content/browser/child_process_security_policy.h"
45 #include "content/browser/plugin_process_host.h" 48 #include "content/browser/plugin_process_host.h"
46 #include "content/browser/renderer_host/browser_render_process_host.h" 49 #include "content/browser/renderer_host/browser_render_process_host.h"
47 #include "content/browser/renderer_host/render_view_host.h" 50 #include "content/browser/renderer_host/render_view_host.h"
48 #include "content/browser/resource_context.h" 51 #include "content/browser/resource_context.h"
49 #include "content/browser/site_instance.h" 52 #include "content/browser/site_instance.h"
50 #include "content/browser/ssl/ssl_client_auth_handler.h" 53 #include "content/browser/ssl/ssl_client_auth_handler.h"
51 #include "content/browser/tab_contents/tab_contents.h" 54 #include "content/browser/tab_contents/tab_contents.h"
52 #include "content/browser/worker_host/worker_process_host.h" 55 #include "content/browser/worker_host/worker_process_host.h"
53 #include "content/common/bindings_policy.h" 56 #include "content/common/bindings_policy.h"
57 #include "content/common/desktop_notification_messages.h"
54 #include "net/base/cookie_monster.h" 58 #include "net/base/cookie_monster.h"
55 #include "net/base/cookie_options.h" 59 #include "net/base/cookie_options.h"
56 60
57 #if defined(OS_LINUX) 61 #if defined(OS_LINUX)
58 #include "base/linux_util.h" 62 #include "base/linux_util.h"
59 #include "chrome/browser/crash_handler_host_linux.h" 63 #include "chrome/browser/crash_handler_host_linux.h"
60 #endif 64 #endif
61 65
62 namespace { 66 namespace {
63 67
(...skipping 53 matching lines...) Expand 10 before | Expand all | Expand 10 after
117 } 121 }
118 } 122 }
119 123
120 } 124 }
121 125
122 namespace chrome { 126 namespace chrome {
123 127
124 void ChromeContentBrowserClient::RenderViewHostCreated( 128 void ChromeContentBrowserClient::RenderViewHostCreated(
125 RenderViewHost* render_view_host) { 129 RenderViewHost* render_view_host) {
126 new ChromeRenderViewHostObserver(render_view_host); 130 new ChromeRenderViewHostObserver(render_view_host);
127 DesktopNotificationHandler::Create(render_view_host);
128 new DevToolsHandler(render_view_host); 131 new DevToolsHandler(render_view_host);
129 new ExtensionMessageHandler(render_view_host); 132 new ExtensionMessageHandler(render_view_host);
130 133
131 InitRenderViewHostForExtensions(render_view_host); 134 InitRenderViewHostForExtensions(render_view_host);
132 } 135 }
133 136
134 void ChromeContentBrowserClient::BrowserRenderProcessHostCreated( 137 void ChromeContentBrowserClient::BrowserRenderProcessHostCreated(
135 BrowserRenderProcessHost* host) { 138 BrowserRenderProcessHost* host) {
136 int id = host->id(); 139 int id = host->id();
137 Profile* profile = host->profile(); 140 Profile* profile = host->profile();
(...skipping 218 matching lines...) Expand 10 before | Expand all | Expand 10 after
356 359
357 void ChromeContentBrowserClient::AddNewCertificate( 360 void ChromeContentBrowserClient::AddNewCertificate(
358 net::URLRequest* request, 361 net::URLRequest* request,
359 net::X509Certificate* cert, 362 net::X509Certificate* cert,
360 int render_process_id, 363 int render_process_id,
361 int render_view_id) { 364 int render_view_id) {
362 // The handler will run the UI and delete itself when it's finished. 365 // The handler will run the UI and delete itself when it's finished.
363 new SSLAddCertHandler(request, cert, render_process_id, render_view_id); 366 new SSLAddCertHandler(request, cert, render_process_id, render_view_id);
364 } 367 }
365 368
369 void ChromeContentBrowserClient::RequestDesktopNotificationPermission(
370 const GURL& source_origin,
371 int callback_context,
372 int render_process_id,
373 int render_view_id) {
374 RenderViewHost* rvh = RenderViewHost::FromID(
375 render_process_id, render_view_id);
376 if (!rvh) {
377 NOTREACHED();
378 return;
379 }
380
381 RenderProcessHost* process = rvh->process();
382 DesktopNotificationService* service =
383 DesktopNotificationServiceFactory::GetForProfile(process->profile());
384 service->RequestPermission(
385 source_origin, render_process_id, render_view_id, callback_context,
386 tab_util::GetTabContentsByID(render_process_id, render_view_id));
387 }
388
389 WebKit::WebNotificationPresenter::Permission
390 ChromeContentBrowserClient::CheckDesktopNotificationPermission(
391 const GURL& source_url,
392 const content::ResourceContext& context) {
393 DCHECK(BrowserThread::CurrentlyOn(BrowserThread::IO));
394 ProfileIOData* io_data =
395 reinterpret_cast<ProfileIOData*>(context.GetUserData(NULL));
396
397 const Extension* extension =
398 io_data->GetExtensionInfoMap()->extensions().GetByURL(source_url);
399 if (extension &&
400 extension->HasApiPermission(Extension::kNotificationPermission)) {
401 return WebKit::WebNotificationPresenter::PermissionAllowed;
402 }
403
404 // Fall back to the regular notification preferences, which works on an
405 // origin basis.
406 return io_data->GetNotificationService() ?
407 io_data->GetNotificationService()->HasPermission(source_url.GetOrigin()) :
408 WebKit::WebNotificationPresenter::PermissionNotAllowed;
409 }
410
411 void ChromeContentBrowserClient::ShowDesktopNotification(
412 const DesktopNotificationHostMsg_Show_Params& params,
413 int render_process_id,
414 int render_view_id,
415 bool worker) {
416 RenderViewHost* rvh = RenderViewHost::FromID(
417 render_process_id, render_view_id);
418 if (!rvh) {
419 NOTREACHED();
420 return;
421 }
422
423 RenderProcessHost* process = rvh->process();
424 DesktopNotificationService* service =
425 DesktopNotificationServiceFactory::GetForProfile(process->profile());
426 service->ShowDesktopNotification(
427 params, render_process_id, render_view_id,
428 worker ? DesktopNotificationService::WorkerNotification :
429 DesktopNotificationService::PageNotification);
430 }
431
432 void ChromeContentBrowserClient::CancelDesktopNotification(
433 int render_process_id,
434 int render_view_id,
435 int notification_id) {
436 RenderViewHost* rvh = RenderViewHost::FromID(
437 render_process_id, render_view_id);
438 if (!rvh) {
439 NOTREACHED();
440 return;
441 }
442
443 RenderProcessHost* process = rvh->process();
444 DesktopNotificationService* service =
445 DesktopNotificationServiceFactory::GetForProfile(process->profile());
446 service->CancelDesktopNotification(
447 render_process_id, render_view_id, notification_id);
448 }
449
366 #if defined(OS_LINUX) 450 #if defined(OS_LINUX)
367 int ChromeContentBrowserClient::GetCrashSignalFD( 451 int ChromeContentBrowserClient::GetCrashSignalFD(
368 const std::string& process_type) { 452 const std::string& process_type) {
369 if (process_type == switches::kRendererProcess) 453 if (process_type == switches::kRendererProcess)
370 return RendererCrashHandlerHostLinux::GetInstance()->GetDeathSignalSocket(); 454 return RendererCrashHandlerHostLinux::GetInstance()->GetDeathSignalSocket();
371 455
372 if (process_type == switches::kPluginProcess) 456 if (process_type == switches::kPluginProcess)
373 return PluginCrashHandlerHostLinux::GetInstance()->GetDeathSignalSocket(); 457 return PluginCrashHandlerHostLinux::GetInstance()->GetDeathSignalSocket();
374 458
375 if (process_type == switches::kPpapiPluginProcess) 459 if (process_type == switches::kPpapiPluginProcess)
376 return PpapiCrashHandlerHostLinux::GetInstance()->GetDeathSignalSocket(); 460 return PpapiCrashHandlerHostLinux::GetInstance()->GetDeathSignalSocket();
377 461
378 if (process_type == switches::kGpuProcess) 462 if (process_type == switches::kGpuProcess)
379 return GpuCrashHandlerHostLinux::GetInstance()->GetDeathSignalSocket(); 463 return GpuCrashHandlerHostLinux::GetInstance()->GetDeathSignalSocket();
380 464
381 return -1; 465 return -1;
382 } 466 }
383 #endif 467 #endif
384 468
385 } // namespace chrome 469 } // namespace chrome
OLDNEW

Powered by Google App Engine
This is Rietveld 408576698