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

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

Issue 593153002: Restore the iframe behavior of notification permissions (Closed) Base URL: https://chromium.googlesource.com/chromium/src.git@master
Patch Set: Created 6 years, 3 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 | « chrome/browser/notifications/desktop_notification_service.h ('k') | no next file » | 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/notifications/desktop_notification_service.h" 5 #include "chrome/browser/notifications/desktop_notification_service.h"
6 6
7 #include "base/bind.h" 7 #include "base/bind.h"
8 #include "base/metrics/histogram.h" 8 #include "base/metrics/histogram.h"
9 #include "base/prefs/scoped_user_pref_update.h" 9 #include "base/prefs/scoped_user_pref_update.h"
10 #include "base/strings/utf_string_conversions.h" 10 #include "base/strings/utf_string_conversions.h"
(...skipping 295 matching lines...) Expand 10 before | Expand all | Expand 10 after
306 return; 306 return;
307 307
308 // The settings for ephemeral apps will be persisted across cache evictions. 308 // The settings for ephemeral apps will be persisted across cache evictions.
309 if (extensions::util::IsEphemeralApp(extension->id(), profile_)) 309 if (extensions::util::IsEphemeralApp(extension->id(), profile_))
310 return; 310 return;
311 311
312 SetNotifierEnabled(notifier_id, true); 312 SetNotifierEnabled(notifier_id, true);
313 #endif 313 #endif
314 } 314 }
315 315
316 // Unlike other permission types, granting a notification for a given origin
317 // will not take into account the |embedder_origin|, it will only be based
318 // on the requesting iframe origin.
319 // TODO(mukai) Consider why notifications behave differently than
320 // other permissions. crbug.com/416894
321 void DesktopNotificationService::UpdateContentSetting(
322 const GURL& requesting_origin,
323 const GURL& embedder_origin,
324 bool allowed) {
325 if (allowed) {
326 DesktopNotificationProfileUtil::GrantPermission(
327 profile_, requesting_origin);
328 } else {
329 DesktopNotificationProfileUtil::DenyPermission(profile_, requesting_origin);
330 }
331 }
332
316 void DesktopNotificationService::OnNotificationPermissionRequested( 333 void DesktopNotificationService::OnNotificationPermissionRequested(
317 const NotificationPermissionCallback& callback, bool allowed) { 334 const NotificationPermissionCallback& callback, bool allowed) {
318 blink::WebNotificationPermission permission = allowed ? 335 blink::WebNotificationPermission permission = allowed ?
319 blink::WebNotificationPermissionAllowed : 336 blink::WebNotificationPermissionAllowed :
320 blink::WebNotificationPermissionDenied; 337 blink::WebNotificationPermissionDenied;
321 338
322 callback.Run(permission); 339 callback.Run(permission);
323 } 340 }
324 341
325 void DesktopNotificationService::FirePermissionLevelChangedEvent( 342 void DesktopNotificationService::FirePermissionLevelChangedEvent(
(...skipping 15 matching lines...) Expand all
341 // Tell the IO thread that this extension's permission for notifications 358 // Tell the IO thread that this extension's permission for notifications
342 // has changed. 359 // has changed.
343 extensions::InfoMap* extension_info_map = 360 extensions::InfoMap* extension_info_map =
344 extensions::ExtensionSystem::Get(profile_)->info_map(); 361 extensions::ExtensionSystem::Get(profile_)->info_map();
345 BrowserThread::PostTask( 362 BrowserThread::PostTask(
346 BrowserThread::IO, FROM_HERE, 363 BrowserThread::IO, FROM_HERE,
347 base::Bind(&extensions::InfoMap::SetNotificationsDisabled, 364 base::Bind(&extensions::InfoMap::SetNotificationsDisabled,
348 extension_info_map, notifier_id.id, !enabled)); 365 extension_info_map, notifier_id.id, !enabled));
349 #endif 366 #endif
350 } 367 }
OLDNEW
« no previous file with comments | « chrome/browser/notifications/desktop_notification_service.h ('k') | no next file » | no next file with comments »

Powered by Google App Engine
This is Rietveld 408576698