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

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

Issue 774573003: Start pulling away notification logic from ChromeContentBrowserClient. (Closed) Base URL: https://chromium.googlesource.com/chromium/src.git@master
Patch Set: Created 6 years 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
OLDNEW
1 // Copyright (c) 2012 The Chromium Authors. All rights reserved. 1 // Copyright (c) 2012 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 <set> 7 #include <set>
8 #include <utility> 8 #include <utility>
9 #include <vector> 9 #include <vector>
10 10
(...skipping 26 matching lines...) Expand all
37 #include "chrome/browser/geolocation/geolocation_permission_context_factory.h" 37 #include "chrome/browser/geolocation/geolocation_permission_context_factory.h"
38 #include "chrome/browser/media/cast_transport_host_filter.h" 38 #include "chrome/browser/media/cast_transport_host_filter.h"
39 #include "chrome/browser/media/media_capture_devices_dispatcher.h" 39 #include "chrome/browser/media/media_capture_devices_dispatcher.h"
40 #include "chrome/browser/media/midi_permission_context.h" 40 #include "chrome/browser/media/midi_permission_context.h"
41 #include "chrome/browser/media/midi_permission_context_factory.h" 41 #include "chrome/browser/media/midi_permission_context_factory.h"
42 #include "chrome/browser/metrics/chrome_browser_main_extra_parts_metrics.h" 42 #include "chrome/browser/metrics/chrome_browser_main_extra_parts_metrics.h"
43 #include "chrome/browser/nacl_host/nacl_browser_delegate_impl.h" 43 #include "chrome/browser/nacl_host/nacl_browser_delegate_impl.h"
44 #include "chrome/browser/net/chrome_net_log.h" 44 #include "chrome/browser/net/chrome_net_log.h"
45 #include "chrome/browser/notifications/desktop_notification_service.h" 45 #include "chrome/browser/notifications/desktop_notification_service.h"
46 #include "chrome/browser/notifications/desktop_notification_service_factory.h" 46 #include "chrome/browser/notifications/desktop_notification_service_factory.h"
47 #include "chrome/browser/notifications/platform_notification_service_impl.h"
47 #include "chrome/browser/platform_util.h" 48 #include "chrome/browser/platform_util.h"
48 #include "chrome/browser/plugins/plugin_info_message_filter.h" 49 #include "chrome/browser/plugins/plugin_info_message_filter.h"
49 #include "chrome/browser/prerender/prerender_final_status.h" 50 #include "chrome/browser/prerender/prerender_final_status.h"
50 #include "chrome/browser/prerender/prerender_manager.h" 51 #include "chrome/browser/prerender/prerender_manager.h"
51 #include "chrome/browser/prerender/prerender_manager_factory.h" 52 #include "chrome/browser/prerender/prerender_manager_factory.h"
52 #include "chrome/browser/prerender/prerender_message_filter.h" 53 #include "chrome/browser/prerender/prerender_message_filter.h"
53 #include "chrome/browser/prerender/prerender_tracker.h" 54 #include "chrome/browser/prerender/prerender_tracker.h"
54 #include "chrome/browser/printing/printing_message_filter.h" 55 #include "chrome/browser/printing/printing_message_filter.h"
55 #include "chrome/browser/profiles/chrome_browser_main_extra_parts_profiles.h" 56 #include "chrome/browser/profiles/chrome_browser_main_extra_parts_profiles.h"
56 #include "chrome/browser/profiles/profile.h" 57 #include "chrome/browser/profiles/profile.h"
(...skipping 45 matching lines...) Expand 10 before | Expand all | Expand 10 after
102 #include "components/pref_registry/pref_registry_syncable.h" 103 #include "components/pref_registry/pref_registry_syncable.h"
103 #include "components/signin/core/common/profile_management_switches.h" 104 #include "components/signin/core/common/profile_management_switches.h"
104 #include "components/translate/core/common/translate_switches.h" 105 #include "components/translate/core/common/translate_switches.h"
105 #include "content/public/browser/browser_child_process_host.h" 106 #include "content/public/browser/browser_child_process_host.h"
106 #include "content/public/browser/browser_main_parts.h" 107 #include "content/public/browser/browser_main_parts.h"
107 #include "content/public/browser/browser_ppapi_host.h" 108 #include "content/public/browser/browser_ppapi_host.h"
108 #include "content/public/browser/browser_thread.h" 109 #include "content/public/browser/browser_thread.h"
109 #include "content/public/browser/browser_url_handler.h" 110 #include "content/public/browser/browser_url_handler.h"
110 #include "content/public/browser/child_process_data.h" 111 #include "content/public/browser/child_process_data.h"
111 #include "content/public/browser/child_process_security_policy.h" 112 #include "content/public/browser/child_process_security_policy.h"
112 #include "content/public/browser/desktop_notification_delegate.h"
113 #include "content/public/browser/permission_type.h" 113 #include "content/public/browser/permission_type.h"
114 #include "content/public/browser/render_frame_host.h" 114 #include "content/public/browser/render_frame_host.h"
115 #include "content/public/browser/render_process_host.h" 115 #include "content/public/browser/render_process_host.h"
116 #include "content/public/browser/render_view_host.h" 116 #include "content/public/browser/render_view_host.h"
117 #include "content/public/browser/resource_context.h" 117 #include "content/public/browser/resource_context.h"
118 #include "content/public/browser/site_instance.h" 118 #include "content/public/browser/site_instance.h"
119 #include "content/public/browser/web_contents.h" 119 #include "content/public/browser/web_contents.h"
120 #include "content/public/common/child_process_host.h" 120 #include "content/public/common/child_process_host.h"
121 #include "content/public/common/content_descriptors.h" 121 #include "content/public/common/content_descriptors.h"
122 #include "content/public/common/show_desktop_notification_params.h"
123 #include "content/public/common/url_utils.h" 122 #include "content/public/common/url_utils.h"
124 #include "content/public/common/web_preferences.h" 123 #include "content/public/common/web_preferences.h"
125 #include "net/base/mime_util.h" 124 #include "net/base/mime_util.h"
126 #include "net/cookies/canonical_cookie.h" 125 #include "net/cookies/canonical_cookie.h"
127 #include "net/cookies/cookie_options.h" 126 #include "net/cookies/cookie_options.h"
128 #include "net/ssl/ssl_cert_request_info.h" 127 #include "net/ssl/ssl_cert_request_info.h"
129 #include "ppapi/host/ppapi_host.h" 128 #include "ppapi/host/ppapi_host.h"
130 #include "ppapi/shared_impl/ppapi_switches.h" 129 #include "ppapi/shared_impl/ppapi_switches.h"
131 #include "storage/browser/fileapi/external_mount_points.h" 130 #include "storage/browser/fileapi/external_mount_points.h"
132 #include "ui/base/l10n/l10n_util.h" 131 #include "ui/base/l10n/l10n_util.h"
(...skipping 1693 matching lines...) Expand 10 before | Expand all | Expand 10 after
1826 int render_process_id, 1825 int render_process_id,
1827 int render_frame_id) { 1826 int render_frame_id) {
1828 chrome::SSLAddCertificate(cert_type, cert_data, cert_size, 1827 chrome::SSLAddCertificate(cert_type, cert_data, cert_size,
1829 render_process_id, render_frame_id); 1828 render_process_id, render_frame_id);
1830 } 1829 }
1831 1830
1832 content::MediaObserver* ChromeContentBrowserClient::GetMediaObserver() { 1831 content::MediaObserver* ChromeContentBrowserClient::GetMediaObserver() {
1833 return MediaCaptureDevicesDispatcher::GetInstance(); 1832 return MediaCaptureDevicesDispatcher::GetInstance();
1834 } 1833 }
1835 1834
1836 blink::WebNotificationPermission 1835 content::PlatformNotificationService*
1837 ChromeContentBrowserClient::CheckDesktopNotificationPermission( 1836 ChromeContentBrowserClient::GetPlatformNotificationService() {
1838 const GURL& source_origin,
1839 content::ResourceContext* context,
1840 int render_process_id) {
1841 #if defined(ENABLE_NOTIFICATIONS) 1837 #if defined(ENABLE_NOTIFICATIONS)
1842 DCHECK(BrowserThread::CurrentlyOn(BrowserThread::IO)); 1838 return PlatformNotificationServiceImpl::GetInstance();
1843
1844 ProfileIOData* io_data = ProfileIOData::FromResourceContext(context);
1845 #if defined(ENABLE_EXTENSIONS)
1846 InfoMap* extension_info_map = io_data->GetExtensionInfoMap();
1847
1848 // We want to see if there is an extension that hasn't been manually disabled
1849 // that has the notifications permission and applies to this security origin.
1850 // First, get the list of extensions with permission for the origin.
1851 extensions::ExtensionSet extensions;
1852 extension_info_map->GetExtensionsWithAPIPermissionForSecurityOrigin(
1853 source_origin,
1854 render_process_id,
1855 extensions::APIPermission::kNotifications,
1856 &extensions);
1857 for (extensions::ExtensionSet::const_iterator iter = extensions.begin();
1858 iter != extensions.end(); ++iter) {
1859 // Then, check to see if it's been disabled by the user.
1860 if (!extension_info_map->AreNotificationsDisabled((*iter)->id()))
1861 return blink::WebNotificationPermissionAllowed;
1862 }
1863 #endif
1864
1865 // No enabled extensions exist, so check the normal host content settings.
1866 HostContentSettingsMap* host_content_settings_map =
1867 io_data->GetHostContentSettingsMap();
1868 ContentSetting setting = host_content_settings_map->GetContentSetting(
1869 source_origin,
1870 source_origin,
1871 CONTENT_SETTINGS_TYPE_NOTIFICATIONS,
1872 NO_RESOURCE_IDENTIFIER);
1873
1874 if (setting == CONTENT_SETTING_ALLOW)
1875 return blink::WebNotificationPermissionAllowed;
1876 if (setting == CONTENT_SETTING_BLOCK)
1877 return blink::WebNotificationPermissionDenied;
1878 return blink::WebNotificationPermissionDefault;
1879 #else 1839 #else
1880 return blink::WebNotificationPermissionAllowed; 1840 NOTIMPLEMENTED();
1841 return NULL;
1881 #endif 1842 #endif
1882 } 1843 }
1883 1844
1884 void ChromeContentBrowserClient::ShowDesktopNotification(
1885 const content::ShowDesktopNotificationHostMsgParams& params,
1886 content::BrowserContext* browser_context,
1887 int render_process_id,
1888 scoped_ptr<content::DesktopNotificationDelegate> delegate,
1889 base::Closure* cancel_callback) {
1890 #if defined(ENABLE_NOTIFICATIONS)
1891 Profile* profile = Profile::FromBrowserContext(browser_context);
1892 DCHECK(profile);
1893
1894 DesktopNotificationService* service =
1895 DesktopNotificationServiceFactory::GetForProfile(profile);
1896 DCHECK(service);
1897
1898 service->ShowDesktopNotification(
1899 params, render_process_id, delegate.Pass(), cancel_callback);
1900 profile->GetHostContentSettingsMap()->UpdateLastUsage(
1901 params.origin, params.origin, CONTENT_SETTINGS_TYPE_NOTIFICATIONS);
1902 #else
1903 NOTIMPLEMENTED();
1904 #endif
1905 }
1906
1907 void ChromeContentBrowserClient::RequestPermission( 1845 void ChromeContentBrowserClient::RequestPermission(
1908 content::PermissionType permission, 1846 content::PermissionType permission,
1909 content::WebContents* web_contents, 1847 content::WebContents* web_contents,
1910 int bridge_id, 1848 int bridge_id,
1911 const GURL& requesting_frame, 1849 const GURL& requesting_frame,
1912 bool user_gesture, 1850 bool user_gesture,
1913 const base::Callback<void(bool)>& result_callback) { 1851 const base::Callback<void(bool)>& result_callback) {
1914 int render_process_id = web_contents->GetRenderProcessHost()->GetID(); 1852 int render_process_id = web_contents->GetRenderProcessHost()->GetID();
1915 int render_view_id = web_contents->GetRenderViewHost()->GetRoutingID(); 1853 int render_view_id = web_contents->GetRenderViewHost()->GetRoutingID();
1916 Profile* profile = 1854 Profile* profile =
(...skipping 758 matching lines...) Expand 10 before | Expand all | Expand 10 after
2675 switches::kDisableWebRtcEncryption, 2613 switches::kDisableWebRtcEncryption,
2676 }; 2614 };
2677 to_command_line->CopySwitchesFrom(from_command_line, 2615 to_command_line->CopySwitchesFrom(from_command_line,
2678 kWebRtcDevSwitchNames, 2616 kWebRtcDevSwitchNames,
2679 arraysize(kWebRtcDevSwitchNames)); 2617 arraysize(kWebRtcDevSwitchNames));
2680 } 2618 }
2681 } 2619 }
2682 #endif // defined(ENABLE_WEBRTC) 2620 #endif // defined(ENABLE_WEBRTC)
2683 2621
2684 } // namespace chrome 2622 } // namespace chrome
OLDNEW

Powered by Google App Engine
This is Rietveld 408576698