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

Side by Side Diff: components/renderer_context_menu/render_view_context_menu_base.cc

Issue 982413002: base: Stop passing a non-const ref to ObserverListBase::Iterator. (Closed) Base URL: https://chromium.googlesource.com/chromium/src.git@master
Patch Set: observerref: fixwindowsbuild Created 5 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
OLDNEW
1 // Copyright 2014 The Chromium Authors. All rights reserved. 1 // Copyright 2014 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 "components/renderer_context_menu/render_view_context_menu_base.h" 5 #include "components/renderer_context_menu/render_view_context_menu_base.h"
6 6
7 #include <algorithm> 7 #include <algorithm>
8 #include <utility> 8 #include <utility>
9 9
10 #include "base/command_line.h" 10 #include "base/command_line.h"
(...skipping 248 matching lines...) Expand 10 before | Expand all | Expand 10 after
259 AddCustomItemsToMenu(params_.custom_items, 0, &total_items, this, 259 AddCustomItemsToMenu(params_.custom_items, 0, &total_items, this,
260 &menu_model_); 260 &menu_model_);
261 return total_items > 0; 261 return total_items > 0;
262 } 262 }
263 263
264 bool RenderViewContextMenuBase::IsCommandIdKnown( 264 bool RenderViewContextMenuBase::IsCommandIdKnown(
265 int id, 265 int id,
266 bool* enabled) const { 266 bool* enabled) const {
267 // If this command is is added by one of our observers, we dispatch 267 // If this command is is added by one of our observers, we dispatch
268 // it to the observer. 268 // it to the observer.
269 ObserverListBase<RenderViewContextMenuObserver>::Iterator it(observers_); 269 ObserverListBase<RenderViewContextMenuObserver>::Iterator it(&observers_);
270 RenderViewContextMenuObserver* observer; 270 RenderViewContextMenuObserver* observer;
271 while ((observer = it.GetNext()) != NULL) { 271 while ((observer = it.GetNext()) != NULL) {
272 if (observer->IsCommandIdSupported(id)) { 272 if (observer->IsCommandIdSupported(id)) {
273 *enabled = observer->IsCommandIdEnabled(id); 273 *enabled = observer->IsCommandIdEnabled(id);
274 return true; 274 return true;
275 } 275 }
276 } 276 }
277 277
278 // Custom items. 278 // Custom items.
279 if (IsContentCustomCommandId(id)) { 279 if (IsContentCustomCommandId(id)) {
280 *enabled = IsCustomItemEnabled(id); 280 *enabled = IsCustomItemEnabled(id);
281 return true; 281 return true;
282 } 282 }
283 283
284 return false; 284 return false;
285 } 285 }
286 286
287 // Menu delegate functions ----------------------------------------------------- 287 // Menu delegate functions -----------------------------------------------------
288 288
289 bool RenderViewContextMenuBase::IsCommandIdChecked(int id) const { 289 bool RenderViewContextMenuBase::IsCommandIdChecked(int id) const {
290 // If this command is is added by one of our observers, we dispatch it to the 290 // If this command is is added by one of our observers, we dispatch it to the
291 // observer. 291 // observer.
292 ObserverListBase<RenderViewContextMenuObserver>::Iterator it(observers_); 292 ObserverListBase<RenderViewContextMenuObserver>::Iterator it(&observers_);
293 RenderViewContextMenuObserver* observer; 293 RenderViewContextMenuObserver* observer;
294 while ((observer = it.GetNext()) != NULL) { 294 while ((observer = it.GetNext()) != NULL) {
295 if (observer->IsCommandIdSupported(id)) 295 if (observer->IsCommandIdSupported(id))
296 return observer->IsCommandIdChecked(id); 296 return observer->IsCommandIdChecked(id);
297 } 297 }
298 298
299 // Custom items. 299 // Custom items.
300 if (IsContentCustomCommandId(id)) 300 if (IsContentCustomCommandId(id))
301 return IsCustomItemChecked(id); 301 return IsCustomItemChecked(id);
302 302
303 return false; 303 return false;
304 } 304 }
305 305
306 void RenderViewContextMenuBase::ExecuteCommand(int id, int event_flags) { 306 void RenderViewContextMenuBase::ExecuteCommand(int id, int event_flags) {
307 command_executed_ = true; 307 command_executed_ = true;
308 RecordUsedItem(id); 308 RecordUsedItem(id);
309 309
310 // If this command is is added by one of our observers, we dispatch 310 // If this command is is added by one of our observers, we dispatch
311 // it to the observer. 311 // it to the observer.
312 ObserverListBase<RenderViewContextMenuObserver>::Iterator it(observers_); 312 ObserverListBase<RenderViewContextMenuObserver>::Iterator it(&observers_);
313 RenderViewContextMenuObserver* observer; 313 RenderViewContextMenuObserver* observer;
314 while ((observer = it.GetNext()) != NULL) { 314 while ((observer = it.GetNext()) != NULL) {
315 if (observer->IsCommandIdSupported(id)) 315 if (observer->IsCommandIdSupported(id))
316 return observer->ExecuteCommand(id); 316 return observer->ExecuteCommand(id);
317 } 317 }
318 318
319 // Process custom actions range. 319 // Process custom actions range.
320 if (IsContentCustomCommandId(id)) { 320 if (IsContentCustomCommandId(id)) {
321 unsigned action = id - content_context_custom_first; 321 unsigned action = id - content_context_custom_first;
322 const content::CustomContextMenuContext& context = params_.custom_context; 322 const content::CustomContextMenuContext& context = params_.custom_context;
(...skipping 84 matching lines...) Expand 10 before | Expand all | Expand 10 after
407 } 407 }
408 408
409 bool RenderViewContextMenuBase::IsCustomItemChecked(int id) const { 409 bool RenderViewContextMenuBase::IsCustomItemChecked(int id) const {
410 return IsCustomItemCheckedInternal(params_.custom_items, id); 410 return IsCustomItemCheckedInternal(params_.custom_items, id);
411 } 411 }
412 412
413 bool RenderViewContextMenuBase::IsCustomItemEnabled(int id) const { 413 bool RenderViewContextMenuBase::IsCustomItemEnabled(int id) const {
414 return IsCustomItemEnabledInternal(params_.custom_items, id); 414 return IsCustomItemEnabledInternal(params_.custom_items, id);
415 } 415 }
416 416
OLDNEW
« no previous file with comments | « chrome/browser/extensions/extension_toolbar_model.cc ('k') | content/browser/loader/resource_dispatcher_host_impl.cc » ('j') | no next file with comments »

Powered by Google App Engine
This is Rietveld 408576698