| 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 521 matching lines...) Expand 10 before | Expand all | Expand 10 after  Loading... | 
| 838     case chrome::NOTIFICATION_EXTENSION_UNLOADED_DEPRECATED: { | 839     case chrome::NOTIFICATION_EXTENSION_UNLOADED_DEPRECATED: { | 
| 839       // Remove menu items for disabled/uninstalled extensions. | 840       // Remove menu items for disabled/uninstalled extensions. | 
| 840       const Extension* extension = | 841       const Extension* extension = | 
| 841           content::Details<UnloadedExtensionInfo>(details)->extension; | 842           content::Details<UnloadedExtensionInfo>(details)->extension; | 
| 842       MenuItem::ExtensionKey extension_key(extension->id()); | 843       MenuItem::ExtensionKey extension_key(extension->id()); | 
| 843       if (ContainsKey(context_items_, extension_key)) { | 844       if (ContainsKey(context_items_, extension_key)) { | 
| 844         RemoveAllContextItems(extension_key); | 845         RemoveAllContextItems(extension_key); | 
| 845       } | 846       } | 
| 846       break; | 847       break; | 
| 847     } | 848     } | 
| 848     case chrome::NOTIFICATION_EXTENSION_LOADED: { | 849     case chrome::NOTIFICATION_EXTENSION_LOADED_DEPRECATED: { | 
| 849       const Extension* extension = | 850       const Extension* extension = | 
| 850           content::Details<const Extension>(details).ptr(); | 851           content::Details<const Extension>(details).ptr(); | 
| 851       if (store_ && BackgroundInfo::HasLazyBackgroundPage(extension)) { | 852       if (store_ && BackgroundInfo::HasLazyBackgroundPage(extension)) { | 
| 852         store_->GetExtensionValue(extension->id(), kContextMenusKey, | 853         store_->GetExtensionValue(extension->id(), kContextMenusKey, | 
| 853             base::Bind(&MenuManager::ReadFromStorage, | 854             base::Bind(&MenuManager::ReadFromStorage, | 
| 854                        AsWeakPtr(), extension->id())); | 855                        AsWeakPtr(), extension->id())); | 
| 855       } | 856       } | 
| 856       break; | 857       break; | 
| 857     } | 858     } | 
| 858     case chrome::NOTIFICATION_PROFILE_DESTROYED: { | 859     case chrome::NOTIFICATION_PROFILE_DESTROYED: { | 
| (...skipping 93 matching lines...) Expand 10 before | Expand all | Expand 10 after  Loading... | 
| 952       if (uid < other.uid) | 953       if (uid < other.uid) | 
| 953         return true; | 954         return true; | 
| 954       if (uid == other.uid) | 955       if (uid == other.uid) | 
| 955         return string_uid < other.string_uid; | 956         return string_uid < other.string_uid; | 
| 956     } | 957     } | 
| 957   } | 958   } | 
| 958   return false; | 959   return false; | 
| 959 } | 960 } | 
| 960 | 961 | 
| 961 }  // namespace extensions | 962 }  // namespace extensions | 
| OLD | NEW | 
|---|