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

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

Issue 12253022: Manifest handler for all keys background-related. (Closed) Base URL: svn://svn.chromium.org/chrome/trunk/src
Patch Set: Created 7 years, 9 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 | Annotate | Revision Log
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"
11 #include "base/stl_util.h" 11 #include "base/stl_util.h"
12 #include "base/string_util.h" 12 #include "base/string_util.h"
13 #include "base/utf_string_conversions.h" 13 #include "base/utf_string_conversions.h"
14 #include "base/values.h" 14 #include "base/values.h"
15 #include "chrome/browser/extensions/event_names.h" 15 #include "chrome/browser/extensions/event_names.h"
16 #include "chrome/browser/extensions/event_router.h" 16 #include "chrome/browser/extensions/event_router.h"
17 #include "chrome/browser/extensions/extension_service.h" 17 #include "chrome/browser/extensions/extension_service.h"
18 #include "chrome/browser/extensions/extension_system.h" 18 #include "chrome/browser/extensions/extension_system.h"
19 #include "chrome/browser/extensions/tab_helper.h" 19 #include "chrome/browser/extensions/tab_helper.h"
20 #include "chrome/browser/extensions/extension_tab_util.h" 20 #include "chrome/browser/extensions/extension_tab_util.h"
21 #include "chrome/browser/extensions/state_store.h" 21 #include "chrome/browser/extensions/state_store.h"
22 #include "chrome/browser/profiles/profile.h" 22 #include "chrome/browser/profiles/profile.h"
23 #include "chrome/common/chrome_notification_types.h" 23 #include "chrome/common/chrome_notification_types.h"
24 #include "chrome/common/extensions/background_info.h"
24 #include "chrome/common/extensions/extension.h" 25 #include "chrome/common/extensions/extension.h"
25 #include "content/public/browser/notification_details.h" 26 #include "content/public/browser/notification_details.h"
26 #include "content/public/browser/notification_source.h" 27 #include "content/public/browser/notification_source.h"
27 #include "content/public/browser/web_contents.h" 28 #include "content/public/browser/web_contents.h"
28 #include "content/public/common/context_menu_params.h" 29 #include "content/public/common/context_menu_params.h"
29 #include "ui/base/text/text_elider.h" 30 #include "ui/base/text/text_elider.h"
30 #include "ui/gfx/favicon_size.h" 31 #include "ui/gfx/favicon_size.h"
31 32
32 using content::WebContents; 33 using content::WebContents;
33 using extensions::ExtensionSystem; 34 using extensions::ExtensionSystem;
(...skipping 705 matching lines...) Expand 10 before | Expand all | Expand 10 after
739 NOTREACHED(); 740 NOTREACHED();
740 return false; 741 return false;
741 } 742 }
742 SanitizeRadioList(i->second); 743 SanitizeRadioList(i->second);
743 } 744 }
744 745
745 return true; 746 return true;
746 } 747 }
747 748
748 void MenuManager::WriteToStorage(const Extension* extension) { 749 void MenuManager::WriteToStorage(const Extension* extension) {
749 if (!extension->has_lazy_background_page()) 750 if (!BackgroundInfo::HasLazyBackgroundPage(extension))
750 return; 751 return;
751 const MenuItem::List* top_items = MenuItems(extension->id()); 752 const MenuItem::List* top_items = MenuItems(extension->id());
752 MenuItem::List all_items; 753 MenuItem::List all_items;
753 if (top_items) { 754 if (top_items) {
754 for (MenuItem::List::const_iterator i = top_items->begin(); 755 for (MenuItem::List::const_iterator i = top_items->begin();
755 i != top_items->end(); ++i) { 756 i != top_items->end(); ++i) {
756 (*i)->GetFlattenedSubtree(&all_items); 757 (*i)->GetFlattenedSubtree(&all_items);
757 } 758 }
758 } 759 }
759 760
(...skipping 34 matching lines...) Expand 10 before | Expand all | Expand 10 after
794 // Remove menu items for disabled/uninstalled extensions. 795 // Remove menu items for disabled/uninstalled extensions.
795 const Extension* extension = 796 const Extension* extension =
796 content::Details<UnloadedExtensionInfo>(details)->extension; 797 content::Details<UnloadedExtensionInfo>(details)->extension;
797 if (ContainsKey(context_items_, extension->id())) { 798 if (ContainsKey(context_items_, extension->id())) {
798 RemoveAllContextItems(extension->id()); 799 RemoveAllContextItems(extension->id());
799 } 800 }
800 } else if (type == chrome::NOTIFICATION_EXTENSION_LOADED) { 801 } else if (type == chrome::NOTIFICATION_EXTENSION_LOADED) {
801 const Extension* extension = 802 const Extension* extension =
802 content::Details<const Extension>(details).ptr(); 803 content::Details<const Extension>(details).ptr();
803 StateStore* store = ExtensionSystem::Get(profile_)->state_store(); 804 StateStore* store = ExtensionSystem::Get(profile_)->state_store();
804 if (store && extension->has_lazy_background_page()) { 805 if (store && BackgroundInfo::HasLazyBackgroundPage(extension)) {
805 store->GetExtensionValue(extension->id(), kContextMenusKey, 806 store->GetExtensionValue(extension->id(), kContextMenusKey,
806 base::Bind(&MenuManager::ReadFromStorage, 807 base::Bind(&MenuManager::ReadFromStorage,
807 AsWeakPtr(), extension->id())); 808 AsWeakPtr(), extension->id()));
808 } 809 }
809 } 810 }
810 } 811 }
811 812
812 const SkBitmap& MenuManager::GetIconForExtension( 813 const SkBitmap& MenuManager::GetIconForExtension(
813 const std::string& extension_id) { 814 const std::string& extension_id) {
814 return icon_manager_.GetIcon(extension_id); 815 return icon_manager_.GetIcon(extension_id);
(...skipping 50 matching lines...) Expand 10 before | Expand all | Expand 10 after
865 if (uid < other.uid) 866 if (uid < other.uid)
866 return true; 867 return true;
867 if (uid == other.uid) 868 if (uid == other.uid)
868 return string_uid < other.string_uid; 869 return string_uid < other.string_uid;
869 } 870 }
870 } 871 }
871 return false; 872 return false;
872 } 873 }
873 874
874 } // namespace extensions 875 } // namespace extensions
OLDNEW
« no previous file with comments | « chrome/browser/extensions/manifest_url_parser.cc ('k') | chrome/browser/extensions/sandboxed_unpacker_unittest.cc » ('j') | no next file with comments »

Powered by Google App Engine
This is Rietveld 408576698