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

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

Issue 2742973002: Migrate two std::remove_if usages to use base::EraseIf instead (Closed)
Patch Set: Merge thing 2742973002 Created 3 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 | « no previous file | content/browser/notifications/platform_notification_context_impl.cc » ('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 2015 The Chromium Authors. All rights reserved. 1 // Copyright 2015 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/notification_permission_context.h" 5 #include "chrome/browser/notifications/notification_permission_context.h"
6 6
7 #include <algorithm>
8 #include <deque> 7 #include <deque>
9 8
10 #include "base/callback.h" 9 #include "base/callback.h"
11 #include "base/location.h" 10 #include "base/location.h"
12 #include "base/rand_util.h" 11 #include "base/rand_util.h"
13 #include "base/single_thread_task_runner.h" 12 #include "base/single_thread_task_runner.h"
13 #include "base/stl_util.h"
14 #include "base/threading/thread_task_runner_handle.h" 14 #include "base/threading/thread_task_runner_handle.h"
15 #include "base/timer/timer.h" 15 #include "base/timer/timer.h"
16 #include "chrome/browser/notifications/desktop_notification_profile_util.h" 16 #include "chrome/browser/notifications/desktop_notification_profile_util.h"
17 #include "chrome/browser/permissions/permission_request_id.h" 17 #include "chrome/browser/permissions/permission_request_id.h"
18 #include "chrome/browser/profiles/profile.h" 18 #include "chrome/browser/profiles/profile.h"
19 #include "components/content_settings/core/common/content_settings_pattern.h" 19 #include "components/content_settings/core/common/content_settings_pattern.h"
20 #include "components/content_settings/core/common/content_settings_types.h" 20 #include "components/content_settings/core/common/content_settings_types.h"
21 #include "content/public/browser/browser_thread.h" 21 #include "content/public/browser/browser_thread.h"
22 #include "content/public/browser/render_frame_host.h" 22 #include "content/public/browser/render_frame_host.h"
23 #include "content/public/browser/web_contents_observer.h" 23 #include "content/public/browser/web_contents_observer.h"
(...skipping 91 matching lines...) Expand 10 before | Expand all | Expand 10 after
115 115
116 task_queue_.emplace_back(id, std::move(timer)); 116 task_queue_.emplace_back(id, std::move(timer));
117 117
118 if (is_visible_ && task_queue_.size() == 1) 118 if (is_visible_ && task_queue_.size() == 1)
119 task_queue_.front().timer->Reset(); 119 task_queue_.front().timer->Reset();
120 } 120 }
121 121
122 void VisibilityTimerTabHelper::CancelTask(const PermissionRequestID& id) { 122 void VisibilityTimerTabHelper::CancelTask(const PermissionRequestID& id) {
123 bool deleting_front = task_queue_.front().id == id; 123 bool deleting_front = task_queue_.front().id == id;
124 124
125 task_queue_.erase( 125 base::EraseIf(task_queue_, [id](const Task& task) { return task.id == id; });
126 std::remove_if(task_queue_.begin(), task_queue_.end(),
127 [id](const Task& task) { return task.id == id; }),
128 task_queue_.end());
129 126
130 if (!task_queue_.empty() && is_visible_ && deleting_front) 127 if (!task_queue_.empty() && is_visible_ && deleting_front)
131 task_queue_.front().timer->Reset(); 128 task_queue_.front().timer->Reset();
132 } 129 }
133 130
134 void VisibilityTimerTabHelper::WasShown() { 131 void VisibilityTimerTabHelper::WasShown() {
135 if (!is_visible_ && !task_queue_.empty()) 132 if (!is_visible_ && !task_queue_.empty())
136 task_queue_.front().timer->Reset(); 133 task_queue_.front().timer->Reset();
137 is_visible_ = true; 134 is_visible_ = true;
138 } 135 }
(...skipping 114 matching lines...) Expand 10 before | Expand all | Expand 10 after
253 requesting_origin); 250 requesting_origin);
254 } else { 251 } else {
255 DesktopNotificationProfileUtil::DenyPermission(profile(), 252 DesktopNotificationProfileUtil::DenyPermission(profile(),
256 requesting_origin); 253 requesting_origin);
257 } 254 }
258 } 255 }
259 256
260 bool NotificationPermissionContext::IsRestrictedToSecureOrigins() const { 257 bool NotificationPermissionContext::IsRestrictedToSecureOrigins() const {
261 return content_settings_type() == CONTENT_SETTINGS_TYPE_PUSH_MESSAGING; 258 return content_settings_type() == CONTENT_SETTINGS_TYPE_PUSH_MESSAGING;
262 } 259 }
OLDNEW
« no previous file with comments | « no previous file | content/browser/notifications/platform_notification_context_impl.cc » ('j') | no next file with comments »

Powered by Google App Engine
This is Rietveld 408576698