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

Unified Diff: content/shell/renderer/test_runner/notification_presenter.cc

Issue 183663021: Notification.permission's default value of "default" should be testable. (Closed) Base URL: svn://svn.chromium.org/chrome/trunk/src
Patch Set: Rebase Created 6 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 side-by-side diff with in-line comments
Download patch
« no previous file with comments | « content/shell/renderer/test_runner/notification_presenter.h ('k') | no next file » | no next file with comments »
Expand Comments ('e') | Collapse Comments ('c') | Show Comments Hide Comments ('s')
Index: content/shell/renderer/test_runner/notification_presenter.cc
diff --git a/content/shell/renderer/test_runner/notification_presenter.cc b/content/shell/renderer/test_runner/notification_presenter.cc
index d6f4a25347cefb6168710c5f151087fae496bf0a..e6362d3131abf49f88ae5cae8289f136c4955e5d 100644
--- a/content/shell/renderer/test_runner/notification_presenter.cc
+++ b/content/shell/renderer/test_runner/notification_presenter.cc
@@ -37,8 +37,9 @@ NotificationPresenter::NotificationPresenter() : delegate_(0) {}
NotificationPresenter::~NotificationPresenter() {}
-void NotificationPresenter::GrantPermission(const std::string& origin) {
- allowed_origins_.insert(origin);
+void NotificationPresenter::GrantPermission(const std::string& origin,
+ bool permission_granted) {
+ known_origins_[origin] = permission_granted;
}
bool NotificationPresenter::SimulateClick(const std::string& title) {
@@ -63,7 +64,7 @@ void NotificationPresenter::CancelAllActiveNotifications() {
void NotificationPresenter::Reset() {
// TODO(peter): Ensure that |active_notifications_| is empty as well.
- allowed_origins_.clear();
+ known_origins_.clear();
}
bool NotificationPresenter::show(const WebNotification& notification) {
@@ -121,7 +122,12 @@ void NotificationPresenter::objectDestroyed(
WebNotificationPresenter::Permission NotificationPresenter::checkPermission(
const WebSecurityOrigin& security_origin) {
const std::string origin = security_origin.toString().utf8();
- if (allowed_origins_.find(origin) != allowed_origins_.end())
+ const KnownOriginMap::iterator it = known_origins_.find(origin);
+ if (it == known_origins_.end())
+ return WebNotificationPresenter::PermissionNotAllowed;
+
+ // Values in |known_origins_| indicate whether permission has been granted.
+ if (it->second)
return WebNotificationPresenter::PermissionAllowed;
return WebNotificationPresenter::PermissionDenied;
« no previous file with comments | « content/shell/renderer/test_runner/notification_presenter.h ('k') | no next file » | no next file with comments »

Powered by Google App Engine
This is Rietveld 408576698