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

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

Issue 11226037: Incognito-allowed package apps produce duplicate items in context menu (Closed) Base URL: http://git.chromium.org/chromium/src.git@master
Patch Set: fixed unittest Created 8 years, 1 month 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 (c) 2012 The Chromium Authors. All rights reserved. 1 // Copyright (c) 2012 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/menu_manager.h" 5 #include "chrome/browser/extensions/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 791 matching lines...) Expand 10 before | Expand all | Expand 10 after
802 AsWeakPtr(), extension->id())); 802 AsWeakPtr(), extension->id()));
803 } 803 }
804 } 804 }
805 } 805 }
806 806
807 const SkBitmap& MenuManager::GetIconForExtension( 807 const SkBitmap& MenuManager::GetIconForExtension(
808 const std::string& extension_id) { 808 const std::string& extension_id) {
809 return icon_manager_.GetIcon(extension_id); 809 return icon_manager_.GetIcon(extension_id);
810 } 810 }
811 811
812 void MenuManager::RemoveAllIncognitoContextItems() {
813 // Get all context menu items with "incognito" set to "split".
814 std::set<MenuItem::Id> items_to_remove;
815 std::map<MenuItem::Id, MenuItem*>::const_iterator iter;
816 for (iter = items_by_id_.begin();
817 iter != items_by_id_.end();
818 ++iter) {
819 if (iter->first.incognito)
820 items_to_remove.insert(iter->first);
821 }
822
823 std::set<MenuItem::Id>::iterator remove_iter;
824 for (remove_iter = items_to_remove.begin();
825 remove_iter != items_to_remove.end();
826 ++remove_iter)
827 RemoveContextMenuItem(*remove_iter);
828 }
829
812 MenuItem::Id::Id() 830 MenuItem::Id::Id()
813 : incognito(false), extension_id(""), uid(0), string_uid("") { 831 : incognito(false), extension_id(""), uid(0), string_uid("") {
814 } 832 }
815 833
816 MenuItem::Id::Id(bool incognito, const std::string& extension_id) 834 MenuItem::Id::Id(bool incognito, const std::string& extension_id)
817 : incognito(incognito), extension_id(extension_id), uid(0), 835 : incognito(incognito), extension_id(extension_id), uid(0),
818 string_uid("") { 836 string_uid("") {
819 } 837 }
820 838
821 MenuItem::Id::~Id() { 839 MenuItem::Id::~Id() {
(...skipping 20 matching lines...) Expand all
842 if (uid < other.uid) 860 if (uid < other.uid)
843 return true; 861 return true;
844 if (uid == other.uid) 862 if (uid == other.uid)
845 return string_uid < other.string_uid; 863 return string_uid < other.string_uid;
846 } 864 }
847 } 865 }
848 return false; 866 return false;
849 } 867 }
850 868
851 } // namespace extensions 869 } // namespace extensions
OLDNEW
« no previous file with comments | « chrome/browser/extensions/menu_manager.h ('k') | chrome/browser/extensions/menu_manager_unittest.cc » ('j') | no next file with comments »

Powered by Google App Engine
This is Rietveld 408576698