| 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 285 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 296 } | 296 } |
| 297 return true; | 297 return true; |
| 298 } | 298 } |
| 299 | 299 |
| 300 // static | 300 // static |
| 301 const char MenuManager::kOnContextMenus[] = "contextMenus"; | 301 const char MenuManager::kOnContextMenus[] = "contextMenus"; |
| 302 const char MenuManager::kOnWebviewContextMenus[] = "webview.contextMenus"; | 302 const char MenuManager::kOnWebviewContextMenus[] = "webview.contextMenus"; |
| 303 | 303 |
| 304 MenuManager::MenuManager(Profile* profile, StateStore* store) | 304 MenuManager::MenuManager(Profile* profile, StateStore* store) |
| 305 : profile_(profile), store_(store) { | 305 : profile_(profile), store_(store) { |
| 306 registrar_.Add(this, chrome::NOTIFICATION_EXTENSION_LOADED, | 306 registrar_.Add(this, |
| 307 chrome::NOTIFICATION_EXTENSION_LOADED_DEPRECATED, |
| 307 content::Source<Profile>(profile)); | 308 content::Source<Profile>(profile)); |
| 308 registrar_.Add(this, chrome::NOTIFICATION_EXTENSION_UNLOADED_DEPRECATED, | 309 registrar_.Add(this, chrome::NOTIFICATION_EXTENSION_UNLOADED_DEPRECATED, |
| 309 content::Source<Profile>(profile)); | 310 content::Source<Profile>(profile)); |
| 310 registrar_.Add(this, chrome::NOTIFICATION_PROFILE_DESTROYED, | 311 registrar_.Add(this, chrome::NOTIFICATION_PROFILE_DESTROYED, |
| 311 content::NotificationService::AllSources()); | 312 content::NotificationService::AllSources()); |
| 312 if (store_) | 313 if (store_) |
| 313 store_->RegisterKey(kContextMenusKey); | 314 store_->RegisterKey(kContextMenusKey); |
| 314 } | 315 } |
| 315 | 316 |
| 316 MenuManager::~MenuManager() { | 317 MenuManager::~MenuManager() { |
| (...skipping 520 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 837 case chrome::NOTIFICATION_EXTENSION_UNLOADED_DEPRECATED: { | 838 case chrome::NOTIFICATION_EXTENSION_UNLOADED_DEPRECATED: { |
| 838 // Remove menu items for disabled/uninstalled extensions. | 839 // Remove menu items for disabled/uninstalled extensions. |
| 839 const Extension* extension = | 840 const Extension* extension = |
| 840 content::Details<UnloadedExtensionInfo>(details)->extension; | 841 content::Details<UnloadedExtensionInfo>(details)->extension; |
| 841 MenuItem::ExtensionKey extension_key(extension->id()); | 842 MenuItem::ExtensionKey extension_key(extension->id()); |
| 842 if (ContainsKey(context_items_, extension_key)) { | 843 if (ContainsKey(context_items_, extension_key)) { |
| 843 RemoveAllContextItems(extension_key); | 844 RemoveAllContextItems(extension_key); |
| 844 } | 845 } |
| 845 break; | 846 break; |
| 846 } | 847 } |
| 847 case chrome::NOTIFICATION_EXTENSION_LOADED: { | 848 case chrome::NOTIFICATION_EXTENSION_LOADED_DEPRECATED: { |
| 848 const Extension* extension = | 849 const Extension* extension = |
| 849 content::Details<const Extension>(details).ptr(); | 850 content::Details<const Extension>(details).ptr(); |
| 850 if (store_ && BackgroundInfo::HasLazyBackgroundPage(extension)) { | 851 if (store_ && BackgroundInfo::HasLazyBackgroundPage(extension)) { |
| 851 store_->GetExtensionValue(extension->id(), kContextMenusKey, | 852 store_->GetExtensionValue(extension->id(), kContextMenusKey, |
| 852 base::Bind(&MenuManager::ReadFromStorage, | 853 base::Bind(&MenuManager::ReadFromStorage, |
| 853 AsWeakPtr(), extension->id())); | 854 AsWeakPtr(), extension->id())); |
| 854 } | 855 } |
| 855 break; | 856 break; |
| 856 } | 857 } |
| 857 case chrome::NOTIFICATION_PROFILE_DESTROYED: { | 858 case chrome::NOTIFICATION_PROFILE_DESTROYED: { |
| (...skipping 93 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 951 if (uid < other.uid) | 952 if (uid < other.uid) |
| 952 return true; | 953 return true; |
| 953 if (uid == other.uid) | 954 if (uid == other.uid) |
| 954 return string_uid < other.string_uid; | 955 return string_uid < other.string_uid; |
| 955 } | 956 } |
| 956 } | 957 } |
| 957 return false; | 958 return false; |
| 958 } | 959 } |
| 959 | 960 |
| 960 } // namespace extensions | 961 } // namespace extensions |
| OLD | NEW |