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

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

Issue 1152983004: Move ObserverList to base namespace. (Closed) Base URL: https://chromium.googlesource.com/chromium/src.git@master
Patch Set: Created 5 years, 6 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 233 matching lines...) Expand 10 before | Expand all | Expand 10 after
244 AddCustomItemsToMenu(params_.custom_items, 0, &total_items, this, 244 AddCustomItemsToMenu(params_.custom_items, 0, &total_items, this,
245 &menu_model_); 245 &menu_model_);
246 return total_items > 0; 246 return total_items > 0;
247 } 247 }
248 248
249 bool RenderViewContextMenuBase::IsCommandIdKnown( 249 bool RenderViewContextMenuBase::IsCommandIdKnown(
250 int id, 250 int id,
251 bool* enabled) const { 251 bool* enabled) const {
252 // If this command is is added by one of our observers, we dispatch 252 // If this command is is added by one of our observers, we dispatch
253 // it to the observer. 253 // it to the observer.
254 ObserverListBase<RenderViewContextMenuObserver>::Iterator it(&observers_); 254 base::ObserverListBase<RenderViewContextMenuObserver>::Iterator it(
255 &observers_);
255 RenderViewContextMenuObserver* observer; 256 RenderViewContextMenuObserver* observer;
256 while ((observer = it.GetNext()) != NULL) { 257 while ((observer = it.GetNext()) != NULL) {
257 if (observer->IsCommandIdSupported(id)) { 258 if (observer->IsCommandIdSupported(id)) {
258 *enabled = observer->IsCommandIdEnabled(id); 259 *enabled = observer->IsCommandIdEnabled(id);
259 return true; 260 return true;
260 } 261 }
261 } 262 }
262 263
263 // Custom items. 264 // Custom items.
264 if (IsContentCustomCommandId(id)) { 265 if (IsContentCustomCommandId(id)) {
265 *enabled = IsCustomItemEnabled(id); 266 *enabled = IsCustomItemEnabled(id);
266 return true; 267 return true;
267 } 268 }
268 269
269 return false; 270 return false;
270 } 271 }
271 272
272 // Menu delegate functions ----------------------------------------------------- 273 // Menu delegate functions -----------------------------------------------------
273 274
274 bool RenderViewContextMenuBase::IsCommandIdChecked(int id) const { 275 bool RenderViewContextMenuBase::IsCommandIdChecked(int id) const {
275 // If this command is is added by one of our observers, we dispatch it to the 276 // If this command is is added by one of our observers, we dispatch it to the
276 // observer. 277 // observer.
277 ObserverListBase<RenderViewContextMenuObserver>::Iterator it(&observers_); 278 base::ObserverListBase<RenderViewContextMenuObserver>::Iterator it(
279 &observers_);
278 RenderViewContextMenuObserver* observer; 280 RenderViewContextMenuObserver* observer;
279 while ((observer = it.GetNext()) != NULL) { 281 while ((observer = it.GetNext()) != NULL) {
280 if (observer->IsCommandIdSupported(id)) 282 if (observer->IsCommandIdSupported(id))
281 return observer->IsCommandIdChecked(id); 283 return observer->IsCommandIdChecked(id);
282 } 284 }
283 285
284 // Custom items. 286 // Custom items.
285 if (IsContentCustomCommandId(id)) 287 if (IsContentCustomCommandId(id))
286 return IsCustomItemChecked(id); 288 return IsCustomItemChecked(id);
287 289
288 return false; 290 return false;
289 } 291 }
290 292
291 void RenderViewContextMenuBase::ExecuteCommand(int id, int event_flags) { 293 void RenderViewContextMenuBase::ExecuteCommand(int id, int event_flags) {
292 command_executed_ = true; 294 command_executed_ = true;
293 RecordUsedItem(id); 295 RecordUsedItem(id);
294 296
295 // If this command is is added by one of our observers, we dispatch 297 // If this command is is added by one of our observers, we dispatch
296 // it to the observer. 298 // it to the observer.
297 ObserverListBase<RenderViewContextMenuObserver>::Iterator it(&observers_); 299 base::ObserverListBase<RenderViewContextMenuObserver>::Iterator it(
300 &observers_);
298 RenderViewContextMenuObserver* observer; 301 RenderViewContextMenuObserver* observer;
299 while ((observer = it.GetNext()) != NULL) { 302 while ((observer = it.GetNext()) != NULL) {
300 if (observer->IsCommandIdSupported(id)) 303 if (observer->IsCommandIdSupported(id))
301 return observer->ExecuteCommand(id); 304 return observer->ExecuteCommand(id);
302 } 305 }
303 306
304 // Process custom actions range. 307 // Process custom actions range.
305 if (IsContentCustomCommandId(id)) { 308 if (IsContentCustomCommandId(id)) {
306 unsigned action = id - content_context_custom_first; 309 unsigned action = id - content_context_custom_first;
307 const content::CustomContextMenuContext& context = params_.custom_context; 310 const content::CustomContextMenuContext& context = params_.custom_context;
(...skipping 84 matching lines...) Expand 10 before | Expand all | Expand 10 after
392 } 395 }
393 396
394 bool RenderViewContextMenuBase::IsCustomItemChecked(int id) const { 397 bool RenderViewContextMenuBase::IsCustomItemChecked(int id) const {
395 return IsCustomItemCheckedInternal(params_.custom_items, id); 398 return IsCustomItemCheckedInternal(params_.custom_items, id);
396 } 399 }
397 400
398 bool RenderViewContextMenuBase::IsCustomItemEnabled(int id) const { 401 bool RenderViewContextMenuBase::IsCustomItemEnabled(int id) const {
399 return IsCustomItemEnabledInternal(params_.custom_items, id); 402 return IsCustomItemEnabledInternal(params_.custom_items, id);
400 } 403 }
401 404
OLDNEW
« no previous file with comments | « chrome/browser/extensions/extension_toolbar_model.cc ('k') | content/browser/web_contents/web_contents_impl.cc » ('j') | no next file with comments »

Powered by Google App Engine
This is Rietveld 408576698