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

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

Issue 9447034: Android: Guard off desktop notifications (Closed) Base URL: http://git.chromium.org/chromium/src.git@master
Patch Set: Fixing rebase Created 8 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
« no previous file with comments | « build/common.gypi ('k') | chrome/browser/profiles/profile_io_data.h » ('j') | no next file with comments »
Toggle Intra-line Diffs ('i') | Expand Comments ('e') | Collapse Comments ('c') | Show Comments Hide Comments ('s')
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 1109 matching lines...) Expand 10 before | Expand all | Expand 10 after
1120 1120
1121 callback.Run(devices); 1121 callback.Run(devices);
1122 #endif // TOOLKIT_VIEWS 1122 #endif // TOOLKIT_VIEWS
1123 } 1123 }
1124 1124
1125 void ChromeContentBrowserClient::RequestDesktopNotificationPermission( 1125 void ChromeContentBrowserClient::RequestDesktopNotificationPermission(
1126 const GURL& source_origin, 1126 const GURL& source_origin,
1127 int callback_context, 1127 int callback_context,
1128 int render_process_id, 1128 int render_process_id,
1129 int render_view_id) { 1129 int render_view_id) {
1130 #if defined(ENABLE_NOTIFICATIONS)
1130 RenderViewHost* rvh = RenderViewHost::FromID( 1131 RenderViewHost* rvh = RenderViewHost::FromID(
1131 render_process_id, render_view_id); 1132 render_process_id, render_view_id);
1132 if (!rvh) { 1133 if (!rvh) {
1133 NOTREACHED(); 1134 NOTREACHED();
1134 return; 1135 return;
1135 } 1136 }
1136 1137
1137 content::RenderProcessHost* process = rvh->process(); 1138 content::RenderProcessHost* process = rvh->process();
1138 Profile* profile = Profile::FromBrowserContext(process->GetBrowserContext()); 1139 Profile* profile = Profile::FromBrowserContext(process->GetBrowserContext());
1139 DesktopNotificationService* service = 1140 DesktopNotificationService* service =
1140 DesktopNotificationServiceFactory::GetForProfile(profile); 1141 DesktopNotificationServiceFactory::GetForProfile(profile);
1141 service->RequestPermission( 1142 service->RequestPermission(
1142 source_origin, render_process_id, render_view_id, callback_context, 1143 source_origin, render_process_id, render_view_id, callback_context,
1143 tab_util::GetWebContentsByID(render_process_id, render_view_id)); 1144 tab_util::GetWebContentsByID(render_process_id, render_view_id));
1145 #else
1146 NOTIMPLEMENTED();
1147 #endif
1144 } 1148 }
1145 1149
1146 WebKit::WebNotificationPresenter::Permission 1150 WebKit::WebNotificationPresenter::Permission
1147 ChromeContentBrowserClient::CheckDesktopNotificationPermission( 1151 ChromeContentBrowserClient::CheckDesktopNotificationPermission(
1148 const GURL& source_origin, 1152 const GURL& source_origin,
1149 content::ResourceContext* context, 1153 content::ResourceContext* context,
1150 int render_process_id) { 1154 int render_process_id) {
1155 #if defined(ENABLE_NOTIFICATIONS)
1151 DCHECK(BrowserThread::CurrentlyOn(BrowserThread::IO)); 1156 DCHECK(BrowserThread::CurrentlyOn(BrowserThread::IO));
1152 ProfileIOData* io_data = ProfileIOData::FromResourceContext(context); 1157 ProfileIOData* io_data = ProfileIOData::FromResourceContext(context);
1153 if (io_data->GetExtensionInfoMap()->SecurityOriginHasAPIPermission( 1158 if (io_data->GetExtensionInfoMap()->SecurityOriginHasAPIPermission(
1154 source_origin, render_process_id, 1159 source_origin, render_process_id,
1155 ExtensionAPIPermission::kNotification)) 1160 ExtensionAPIPermission::kNotification))
1156 return WebKit::WebNotificationPresenter::PermissionAllowed; 1161 return WebKit::WebNotificationPresenter::PermissionAllowed;
1157 1162
1158 // Fall back to the regular notification preferences, which works on an 1163 // Fall back to the regular notification preferences, which works on an
1159 // origin basis. 1164 // origin basis.
1160 return io_data->GetNotificationService() ? 1165 return io_data->GetNotificationService() ?
1161 io_data->GetNotificationService()->HasPermission(source_origin) : 1166 io_data->GetNotificationService()->HasPermission(source_origin) :
1162 WebKit::WebNotificationPresenter::PermissionNotAllowed; 1167 WebKit::WebNotificationPresenter::PermissionNotAllowed;
1168 #else
1169 return WebKit::WebNotificationPresenter::PermissionAllowed;
1170 #endif
1163 } 1171 }
1164 1172
1165 void ChromeContentBrowserClient::ShowDesktopNotification( 1173 void ChromeContentBrowserClient::ShowDesktopNotification(
1166 const content::ShowDesktopNotificationHostMsgParams& params, 1174 const content::ShowDesktopNotificationHostMsgParams& params,
1167 int render_process_id, 1175 int render_process_id,
1168 int render_view_id, 1176 int render_view_id,
1169 bool worker) { 1177 bool worker) {
1178 #if defined(ENABLE_NOTIFICATIONS)
1170 RenderViewHost* rvh = RenderViewHost::FromID( 1179 RenderViewHost* rvh = RenderViewHost::FromID(
1171 render_process_id, render_view_id); 1180 render_process_id, render_view_id);
1172 if (!rvh) { 1181 if (!rvh) {
1173 NOTREACHED(); 1182 NOTREACHED();
1174 return; 1183 return;
1175 } 1184 }
1176 1185
1177 content::RenderProcessHost* process = rvh->process(); 1186 content::RenderProcessHost* process = rvh->process();
1178 Profile* profile = Profile::FromBrowserContext(process->GetBrowserContext()); 1187 Profile* profile = Profile::FromBrowserContext(process->GetBrowserContext());
1179 DesktopNotificationService* service = 1188 DesktopNotificationService* service =
1180 DesktopNotificationServiceFactory::GetForProfile(profile); 1189 DesktopNotificationServiceFactory::GetForProfile(profile);
1181 service->ShowDesktopNotification( 1190 service->ShowDesktopNotification(
1182 params, render_process_id, render_view_id, 1191 params, render_process_id, render_view_id,
1183 worker ? DesktopNotificationService::WorkerNotification : 1192 worker ? DesktopNotificationService::WorkerNotification :
1184 DesktopNotificationService::PageNotification); 1193 DesktopNotificationService::PageNotification);
1194 #else
1195 NOTIMPLEMENTED();
1196 #endif
1185 } 1197 }
1186 1198
1187 void ChromeContentBrowserClient::CancelDesktopNotification( 1199 void ChromeContentBrowserClient::CancelDesktopNotification(
1188 int render_process_id, 1200 int render_process_id,
1189 int render_view_id, 1201 int render_view_id,
1190 int notification_id) { 1202 int notification_id) {
1203 #if defined(ENABLE_NOTIFICATIONS)
1191 RenderViewHost* rvh = RenderViewHost::FromID( 1204 RenderViewHost* rvh = RenderViewHost::FromID(
1192 render_process_id, render_view_id); 1205 render_process_id, render_view_id);
1193 if (!rvh) { 1206 if (!rvh) {
1194 NOTREACHED(); 1207 NOTREACHED();
1195 return; 1208 return;
1196 } 1209 }
1197 1210
1198 content::RenderProcessHost* process = rvh->process(); 1211 content::RenderProcessHost* process = rvh->process();
1199 Profile* profile = Profile::FromBrowserContext(process->GetBrowserContext()); 1212 Profile* profile = Profile::FromBrowserContext(process->GetBrowserContext());
1200 DesktopNotificationService* service = 1213 DesktopNotificationService* service =
1201 DesktopNotificationServiceFactory::GetForProfile(profile); 1214 DesktopNotificationServiceFactory::GetForProfile(profile);
1202 service->CancelDesktopNotification( 1215 service->CancelDesktopNotification(
1203 render_process_id, render_view_id, notification_id); 1216 render_process_id, render_view_id, notification_id);
1217 #else
1218 NOTIMPLEMENTED();
1219 #endif
1204 } 1220 }
1205 1221
1206 bool ChromeContentBrowserClient::CanCreateWindow( 1222 bool ChromeContentBrowserClient::CanCreateWindow(
1207 const GURL& source_origin, 1223 const GURL& source_origin,
1208 WindowContainerType container_type, 1224 WindowContainerType container_type,
1209 content::ResourceContext* context, 1225 content::ResourceContext* context,
1210 int render_process_id) { 1226 int render_process_id) {
1211 DCHECK(BrowserThread::CurrentlyOn(BrowserThread::IO)); 1227 DCHECK(BrowserThread::CurrentlyOn(BrowserThread::IO));
1212 // If the opener is trying to create a background window but doesn't have 1228 // If the opener is trying to create a background window but doesn't have
1213 // the appropriate permission, fail the attempt. 1229 // the appropriate permission, fail the attempt.
(...skipping 304 matching lines...) Expand 10 before | Expand all | Expand 10 after
1518 #if defined(USE_NSS) 1534 #if defined(USE_NSS)
1519 crypto::CryptoModuleBlockingPasswordDelegate* 1535 crypto::CryptoModuleBlockingPasswordDelegate*
1520 ChromeContentBrowserClient::GetCryptoPasswordDelegate( 1536 ChromeContentBrowserClient::GetCryptoPasswordDelegate(
1521 const GURL& url) { 1537 const GURL& url) {
1522 return browser::NewCryptoModuleBlockingDialogDelegate( 1538 return browser::NewCryptoModuleBlockingDialogDelegate(
1523 browser::kCryptoModulePasswordKeygen, url.host()); 1539 browser::kCryptoModulePasswordKeygen, url.host());
1524 } 1540 }
1525 #endif 1541 #endif
1526 1542
1527 } // namespace chrome 1543 } // namespace chrome
OLDNEW
« no previous file with comments | « build/common.gypi ('k') | chrome/browser/profiles/profile_io_data.h » ('j') | no next file with comments »

Powered by Google App Engine
This is Rietveld 408576698