OLD | NEW |
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 284 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
295 return false; | 295 return false; |
296 } | 296 } |
297 } | 297 } |
298 return true; | 298 return true; |
299 } | 299 } |
300 | 300 |
301 MenuManager::MenuManager(Profile* profile, StateStore* store) | 301 MenuManager::MenuManager(Profile* profile, StateStore* store) |
302 : profile_(profile), store_(store) { | 302 : profile_(profile), store_(store) { |
303 registrar_.Add(this, chrome::NOTIFICATION_EXTENSION_LOADED, | 303 registrar_.Add(this, chrome::NOTIFICATION_EXTENSION_LOADED, |
304 content::Source<Profile>(profile)); | 304 content::Source<Profile>(profile)); |
305 registrar_.Add(this, chrome::NOTIFICATION_EXTENSION_UNLOADED, | 305 registrar_.Add(this, chrome::NOTIFICATION_EXTENSION_UNLOADED_DEPRECATED, |
306 content::Source<Profile>(profile)); | 306 content::Source<Profile>(profile)); |
307 registrar_.Add(this, chrome::NOTIFICATION_PROFILE_DESTROYED, | 307 registrar_.Add(this, chrome::NOTIFICATION_PROFILE_DESTROYED, |
308 content::NotificationService::AllSources()); | 308 content::NotificationService::AllSources()); |
309 if (store_) | 309 if (store_) |
310 store_->RegisterKey(kContextMenusKey); | 310 store_->RegisterKey(kContextMenusKey); |
311 } | 311 } |
312 | 312 |
313 MenuManager::~MenuManager() { | 313 MenuManager::~MenuManager() { |
314 MenuItemMap::iterator i; | 314 MenuItemMap::iterator i; |
315 for (i = context_items_.begin(); i != context_items_.end(); ++i) { | 315 for (i = context_items_.begin(); i != context_items_.end(); ++i) { |
(...skipping 504 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
820 } else { | 820 } else { |
821 AddContextItem(extension, items[i]); | 821 AddContextItem(extension, items[i]); |
822 } | 822 } |
823 } | 823 } |
824 } | 824 } |
825 | 825 |
826 void MenuManager::Observe(int type, | 826 void MenuManager::Observe(int type, |
827 const content::NotificationSource& source, | 827 const content::NotificationSource& source, |
828 const content::NotificationDetails& details) { | 828 const content::NotificationDetails& details) { |
829 switch (type) { | 829 switch (type) { |
830 case chrome::NOTIFICATION_EXTENSION_UNLOADED: { | 830 case chrome::NOTIFICATION_EXTENSION_UNLOADED_DEPRECATED: { |
831 // Remove menu items for disabled/uninstalled extensions. | 831 // Remove menu items for disabled/uninstalled extensions. |
832 const Extension* extension = | 832 const Extension* extension = |
833 content::Details<UnloadedExtensionInfo>(details)->extension; | 833 content::Details<UnloadedExtensionInfo>(details)->extension; |
834 MenuItem::ExtensionKey extension_key(extension->id()); | 834 MenuItem::ExtensionKey extension_key(extension->id()); |
835 if (ContainsKey(context_items_, extension_key)) { | 835 if (ContainsKey(context_items_, extension_key)) { |
836 RemoveAllContextItems(extension_key); | 836 RemoveAllContextItems(extension_key); |
837 } | 837 } |
838 break; | 838 break; |
839 } | 839 } |
840 case chrome::NOTIFICATION_EXTENSION_LOADED: { | 840 case chrome::NOTIFICATION_EXTENSION_LOADED: { |
(...skipping 103 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
944 if (uid < other.uid) | 944 if (uid < other.uid) |
945 return true; | 945 return true; |
946 if (uid == other.uid) | 946 if (uid == other.uid) |
947 return string_uid < other.string_uid; | 947 return string_uid < other.string_uid; |
948 } | 948 } |
949 } | 949 } |
950 return false; | 950 return false; |
951 } | 951 } |
952 | 952 |
953 } // namespace extensions | 953 } // namespace extensions |
OLD | NEW |