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

Side by Side Diff: chrome/browser/extensions/extension_menu_manager.cc

Issue 8935016: Contributed by Eriq Augustine <eriq.augustine@gmail.com> (Closed) Base URL: http://src.chromium.org/svn/trunk/src/
Patch Set: Created 9 years 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 | Annotate | Revision Log
OLDNEW
1 // Copyright (c) 2011 The Chromium Authors. All rights reserved. 1 // Copyright (c) 2011 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/extensions/extension_menu_manager.h" 5 #include "chrome/browser/extensions/extension_menu_manager.h"
6 6
7 #include <algorithm> 7 #include <algorithm>
8 8
9 #include "base/json/json_writer.h" 9 #include "base/json/json_writer.h"
10 #include "base/logging.h" 10 #include "base/logging.h"
(...skipping 443 matching lines...) Expand 10 before | Expand all | Expand 10 after
454 DCHECK(type == chrome::NOTIFICATION_EXTENSION_UNLOADED); 454 DCHECK(type == chrome::NOTIFICATION_EXTENSION_UNLOADED);
455 455
456 // Remove menu items for disabled/uninstalled extensions. 456 // Remove menu items for disabled/uninstalled extensions.
457 const Extension* extension = 457 const Extension* extension =
458 content::Details<UnloadedExtensionInfo>(details)->extension; 458 content::Details<UnloadedExtensionInfo>(details)->extension;
459 if (ContainsKey(context_items_, extension->id())) { 459 if (ContainsKey(context_items_, extension->id())) {
460 RemoveAllContextItems(extension->id()); 460 RemoveAllContextItems(extension->id());
461 } 461 }
462 } 462 }
463 463
464 void ExtensionMenuManager::SanitizeRadioButtons() {
Aaron Boodman 2011/12/15 00:53:55 You could pass in the extension ID to cut down on
465 MenuItemMap::iterator i;
466 for (i = context_items_.begin(); i != context_items_.end(); ++i) {
467 RecursiveSanitizeRadioButtons(i->second);
468 }
469 }
470
471 void ExtensionMenuManager::RecursiveSanitizeRadioButtons(
472 const ExtensionMenuItem::List& item_list) {
473 ExtensionMenuItem::List::const_iterator i;
474
475 i = item_list.begin();
476 while (i != item_list.end()) {
477 if ((*i)->child_count() > 0) {
478 RecursiveSanitizeRadioButtons((*i)->children());
479 }
480
481 if ((*i)->type() == ExtensionMenuItem::RADIO) {
482 ExtensionMenuItem::List::const_iterator radio_run_ittr;
Aaron Boodman 2011/12/15 00:53:55 s/ittr/iter/g ?
Aaron Boodman 2011/12/15 00:53:55 Better to declare this right about the loop where
483
484 // If there are multiple items selected, the last one will override the
485 // others. This is the default behavior when adding radio items via
486 // chrome.contextMenus.create().
487 ExtensionMenuItem::List::const_iterator last_checked = item_list.end();
488 for (radio_run_ittr = i; radio_run_ittr != item_list.end();
489 ++radio_run_ittr) {
490 if ((*radio_run_ittr)->type() != ExtensionMenuItem::RADIO) {
491 break;
492 }
493
494 if ((*radio_run_ittr)->checked()) {
495 last_checked = radio_run_ittr;
496 }
497
498 (*radio_run_ittr)->SetChecked(false);
499 }
500
501 // If check radio items were found in this run,
502 // check the first radio item in the list (i).
503 if (last_checked != item_list.end()) {
504 (*last_checked)->SetChecked(true);
505 } else {
506 (*i)->SetChecked(true);
507 }
508
509 i = radio_run_ittr;
510 } else {
511 ++i;
512 }
513 }
514 }
515
464 const SkBitmap& ExtensionMenuManager::GetIconForExtension( 516 const SkBitmap& ExtensionMenuManager::GetIconForExtension(
465 const std::string& extension_id) { 517 const std::string& extension_id) {
466 return icon_manager_.GetIcon(extension_id); 518 return icon_manager_.GetIcon(extension_id);
467 } 519 }
468 520
469 ExtensionMenuItem::Id::Id() 521 ExtensionMenuItem::Id::Id()
470 : profile(NULL), uid(0) { 522 : profile(NULL), uid(0) {
471 } 523 }
472 524
473 ExtensionMenuItem::Id::Id(Profile* profile, 525 ExtensionMenuItem::Id::Id(Profile* profile,
(...skipping 19 matching lines...) Expand all
493 if (profile < other.profile) 545 if (profile < other.profile)
494 return true; 546 return true;
495 if (profile == other.profile) { 547 if (profile == other.profile) {
496 if (extension_id < other.extension_id) 548 if (extension_id < other.extension_id)
497 return true; 549 return true;
498 if (extension_id == other.extension_id) 550 if (extension_id == other.extension_id)
499 return uid < other.uid; 551 return uid < other.uid;
500 } 552 }
501 return false; 553 return false;
502 } 554 }
OLDNEW

Powered by Google App Engine
This is Rietveld 408576698