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

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

Issue 16915006: Convert most of extensions and some other random stuff to using the base namespace for Values. (Closed) Base URL: svn://svn.chromium.org/chrome/trunk/src
Patch Set: Created 7 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 | 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"
(...skipping 64 matching lines...) Expand 10 before | Expand all | Expand 10 after
75 MenuItem* item = MenuItem::Populate( 75 MenuItem* item = MenuItem::Populate(
76 extension_id, *dict, NULL); 76 extension_id, *dict, NULL);
77 if (!item) 77 if (!item)
78 continue; 78 continue;
79 items.push_back(item); 79 items.push_back(item);
80 } 80 }
81 return items; 81 return items;
82 } 82 }
83 83
84 scoped_ptr<base::Value> MenuItemsToValue(const MenuItem::List& items) { 84 scoped_ptr<base::Value> MenuItemsToValue(const MenuItem::List& items) {
85 scoped_ptr<base::ListValue> list(new ListValue()); 85 scoped_ptr<base::ListValue> list(new base::ListValue());
86 for (size_t i = 0; i < items.size(); ++i) 86 for (size_t i = 0; i < items.size(); ++i)
87 list->Append(items[i]->ToValue().release()); 87 list->Append(items[i]->ToValue().release());
88 return scoped_ptr<Value>(list.release()); 88 return scoped_ptr<Value>(list.release());
89 } 89 }
90 90
91 bool GetStringList(const DictionaryValue& dict, 91 bool GetStringList(const DictionaryValue& dict,
92 const std::string& key, 92 const std::string& key,
93 std::vector<std::string>* out) { 93 std::vector<std::string>* out) {
94 if (!dict.HasKey(key)) 94 if (!dict.HasKey(key))
95 return true; 95 return true;
96 96
97 const ListValue* list = NULL; 97 const base::ListValue* list = NULL;
98 if (!dict.GetListWithoutPathExpansion(key, &list)) 98 if (!dict.GetListWithoutPathExpansion(key, &list))
99 return false; 99 return false;
100 100
101 for (size_t i = 0; i < list->GetSize(); ++i) { 101 for (size_t i = 0; i < list->GetSize(); ++i) {
102 std::string pattern; 102 std::string pattern;
103 if (!list->GetString(i, &pattern)) 103 if (!list->GetString(i, &pattern))
104 return false; 104 return false;
105 out->push_back(pattern); 105 out->push_back(pattern);
106 } 106 }
107 107
(...skipping 491 matching lines...) Expand 10 before | Expand all | Expand 10 after
599 599
600 // ExtensionService/Extension can be NULL in unit tests :( 600 // ExtensionService/Extension can be NULL in unit tests :(
601 ExtensionService* service = 601 ExtensionService* service =
602 ExtensionSystem::Get(profile_)->extension_service(); 602 ExtensionSystem::Get(profile_)->extension_service();
603 const Extension* extension = service ? 603 const Extension* extension = service ?
604 service->extensions()->GetByID(menu_item_id.extension_id) : NULL; 604 service->extensions()->GetByID(menu_item_id.extension_id) : NULL;
605 605
606 if (item->type() == MenuItem::RADIO) 606 if (item->type() == MenuItem::RADIO)
607 RadioItemSelected(item); 607 RadioItemSelected(item);
608 608
609 scoped_ptr<ListValue> args(new ListValue()); 609 scoped_ptr<base::ListValue> args(new base::ListValue());
610 610
611 DictionaryValue* properties = new DictionaryValue(); 611 DictionaryValue* properties = new DictionaryValue();
612 SetIdKeyValue(properties, "menuItemId", item->id()); 612 SetIdKeyValue(properties, "menuItemId", item->id());
613 if (item->parent_id()) 613 if (item->parent_id())
614 SetIdKeyValue(properties, "parentMenuItemId", *item->parent_id()); 614 SetIdKeyValue(properties, "parentMenuItemId", *item->parent_id());
615 615
616 switch (params.media_type) { 616 switch (params.media_type) {
617 case WebKit::WebContextMenuData::MediaTypeImage: 617 case WebKit::WebContextMenuData::MediaTypeImage:
618 properties->SetString("mediaType", "image"); 618 properties->SetString("mediaType", "image");
619 break; 619 break;
(...skipping 46 matching lines...) Expand 10 before | Expand all | Expand 10 after
666 WriteToStorage(extension); 666 WriteToStorage(extension);
667 } 667 }
668 668
669 // Note: web_contents are NULL in unit tests :( 669 // Note: web_contents are NULL in unit tests :(
670 if (web_contents && extensions::TabHelper::FromWebContents(web_contents)) { 670 if (web_contents && extensions::TabHelper::FromWebContents(web_contents)) {
671 extensions::TabHelper::FromWebContents(web_contents)-> 671 extensions::TabHelper::FromWebContents(web_contents)->
672 active_tab_permission_granter()->GrantIfRequested(extension); 672 active_tab_permission_granter()->GrantIfRequested(extension);
673 } 673 }
674 674
675 { 675 {
676 scoped_ptr<Event> event(new Event(event_names::kOnContextMenus, 676 scoped_ptr<Event> event(new Event(
677 scoped_ptr<ListValue>(args->DeepCopy()))); 677 event_names::kOnContextMenus,
678 scoped_ptr<base::ListValue>(args->DeepCopy())));
678 event->restrict_to_profile = profile; 679 event->restrict_to_profile = profile;
679 event->user_gesture = EventRouter::USER_GESTURE_ENABLED; 680 event->user_gesture = EventRouter::USER_GESTURE_ENABLED;
680 event_router->DispatchEventToExtension(item->extension_id(), event.Pass()); 681 event_router->DispatchEventToExtension(item->extension_id(), event.Pass());
681 } 682 }
682 { 683 {
683 scoped_ptr<Event> event(new Event(event_names::kOnContextMenuClicked, 684 scoped_ptr<Event> event(new Event(event_names::kOnContextMenuClicked,
684 args.Pass())); 685 args.Pass()));
685 event->restrict_to_profile = profile; 686 event->restrict_to_profile = profile;
686 event->user_gesture = EventRouter::USER_GESTURE_ENABLED; 687 event->user_gesture = EventRouter::USER_GESTURE_ENABLED;
687 event_router->DispatchEventToExtension(item->extension_id(), event.Pass()); 688 event_router->DispatchEventToExtension(item->extension_id(), event.Pass());
(...skipping 172 matching lines...) Expand 10 before | Expand all | Expand 10 after
860 if (uid < other.uid) 861 if (uid < other.uid)
861 return true; 862 return true;
862 if (uid == other.uid) 863 if (uid == other.uid)
863 return string_uid < other.string_uid; 864 return string_uid < other.string_uid;
864 } 865 }
865 } 866 }
866 return false; 867 return false;
867 } 868 }
868 869
869 } // namespace extensions 870 } // namespace extensions
OLDNEW

Powered by Google App Engine
This is Rietveld 408576698