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

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

Issue 1181263007: WebView context menu cleanup. (Closed) Base URL: https://chromium.googlesource.com/chromium/src.git@master
Patch Set: Addressed comments. Rebased. 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 (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 865 matching lines...) Expand 10 before | Expand all | Expand 10 after
876 items_to_remove.insert(iter->first); 876 items_to_remove.insert(iter->first);
877 } 877 }
878 878
879 std::set<MenuItem::Id>::iterator remove_iter; 879 std::set<MenuItem::Id>::iterator remove_iter;
880 for (remove_iter = items_to_remove.begin(); 880 for (remove_iter = items_to_remove.begin();
881 remove_iter != items_to_remove.end(); 881 remove_iter != items_to_remove.end();
882 ++remove_iter) 882 ++remove_iter)
883 RemoveContextMenuItem(*remove_iter); 883 RemoveContextMenuItem(*remove_iter);
884 } 884 }
885 885
886 MenuItem::ExtensionKey::ExtensionKey() : webview_instance_id(0) {} 886 MenuItem::ExtensionKey::ExtensionKey()
887 887 : webview_embedder_process_id(0), webview_instance_id(0) {}
888 MenuItem::ExtensionKey::ExtensionKey(const std::string& extension_id,
889 int webview_instance_id)
890 : extension_id(extension_id), webview_instance_id(webview_instance_id) {}
891 888
892 MenuItem::ExtensionKey::ExtensionKey(const std::string& extension_id) 889 MenuItem::ExtensionKey::ExtensionKey(const std::string& extension_id)
893 : extension_id(extension_id), webview_instance_id(0) {} 890 : extension_id(extension_id),
891 webview_embedder_process_id(0),
892 webview_instance_id(0) {
893 DCHECK(!extension_id.empty());
894 }
895
896 MenuItem::ExtensionKey::ExtensionKey(int webview_embedder_process_id,
897 int webview_instance_id)
898 : webview_embedder_process_id(webview_embedder_process_id),
899 webview_instance_id(webview_instance_id) {
900 DCHECK(webview_embedder_process_id && webview_instance_id);
901 }
894 902
895 bool MenuItem::ExtensionKey::operator==(const ExtensionKey& other) const { 903 bool MenuItem::ExtensionKey::operator==(const ExtensionKey& other) const {
896 return extension_id == other.extension_id && 904 return extension_id == other.extension_id &&
897 webview_instance_id == other.webview_instance_id; 905 webview_instance_id == other.webview_instance_id &&
906 webview_embedder_process_id == other.webview_embedder_process_id;
898 } 907 }
899 908
900 bool MenuItem::ExtensionKey::operator<(const ExtensionKey& other) const { 909 bool MenuItem::ExtensionKey::operator<(const ExtensionKey& other) const {
901 if (extension_id != other.extension_id) 910 if (webview_embedder_process_id != other.webview_embedder_process_id)
902 return extension_id < other.extension_id; 911 return webview_embedder_process_id < other.webview_embedder_process_id;
903 912
904 return webview_instance_id < other.webview_instance_id; 913 if (webview_instance_id != other.webview_instance_id)
914 return webview_instance_id < other.webview_instance_id;
915
916 return extension_id < other.extension_id;
905 } 917 }
906 918
907 bool MenuItem::ExtensionKey::operator!=(const ExtensionKey& other) const { 919 bool MenuItem::ExtensionKey::operator!=(const ExtensionKey& other) const {
908 return !(*this == other); 920 return !(*this == other);
909 } 921 }
910 922
911 bool MenuItem::ExtensionKey::empty() const { 923 bool MenuItem::ExtensionKey::empty() const {
912 return extension_id.empty() && !webview_instance_id; 924 return extension_id.empty() && !webview_embedder_process_id &&
925 !webview_instance_id;
913 } 926 }
914 927
915 MenuItem::Id::Id() : incognito(false), uid(0) {} 928 MenuItem::Id::Id() : incognito(false), uid(0) {}
916 929
917 MenuItem::Id::Id(bool incognito, const MenuItem::ExtensionKey& extension_key) 930 MenuItem::Id::Id(bool incognito, const MenuItem::ExtensionKey& extension_key)
918 : incognito(incognito), extension_key(extension_key), uid(0) {} 931 : incognito(incognito), extension_key(extension_key), uid(0) {}
919 932
920 MenuItem::Id::~Id() { 933 MenuItem::Id::~Id() {
921 } 934 }
922 935
(...skipping 17 matching lines...) Expand all
940 if (uid < other.uid) 953 if (uid < other.uid)
941 return true; 954 return true;
942 if (uid == other.uid) 955 if (uid == other.uid)
943 return string_uid < other.string_uid; 956 return string_uid < other.string_uid;
944 } 957 }
945 } 958 }
946 return false; 959 return false;
947 } 960 }
948 961
949 } // namespace extensions 962 } // namespace extensions
OLDNEW

Powered by Google App Engine
This is Rietveld 408576698