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

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

Issue 10375021: Move Extension into extensions namespace (Closed) Base URL: http://git.chromium.org/chromium/src.git@master
Patch Set: Take 6 Created 8 years, 7 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
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/extension_menu_manager.h" 5 #include "chrome/browser/extensions/extension_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 122 matching lines...) Expand 10 before | Expand all | Expand 10 after
133 133
134 const ExtensionMenuItem::List* ExtensionMenuManager::MenuItems( 134 const ExtensionMenuItem::List* ExtensionMenuManager::MenuItems(
135 const std::string& extension_id) { 135 const std::string& extension_id) {
136 MenuItemMap::iterator i = context_items_.find(extension_id); 136 MenuItemMap::iterator i = context_items_.find(extension_id);
137 if (i != context_items_.end()) { 137 if (i != context_items_.end()) {
138 return &(i->second); 138 return &(i->second);
139 } 139 }
140 return NULL; 140 return NULL;
141 } 141 }
142 142
143 bool ExtensionMenuManager::AddContextItem(const Extension* extension, 143 bool ExtensionMenuManager::AddContextItem(
144 ExtensionMenuItem* item) { 144 const extensions::Extension* extension,
145 ExtensionMenuItem* item) {
145 const std::string& extension_id = item->extension_id(); 146 const std::string& extension_id = item->extension_id();
146 // The item must have a non-empty extension id, and not have already been 147 // The item must have a non-empty extension id, and not have already been
147 // added. 148 // added.
148 if (extension_id.empty() || ContainsKey(items_by_id_, item->id())) 149 if (extension_id.empty() || ContainsKey(items_by_id_, item->id()))
149 return false; 150 return false;
150 151
151 DCHECK_EQ(extension->id(), extension_id); 152 DCHECK_EQ(extension->id(), extension_id);
152 153
153 bool first_item = !ContainsKey(context_items_, extension_id); 154 bool first_item = !ContainsKey(context_items_, extension_id);
154 context_items_[extension_id].push_back(item); 155 context_items_[extension_id].push_back(item);
(...skipping 382 matching lines...) Expand 10 before | Expand all | Expand 10 after
537 return true; 538 return true;
538 } 539 }
539 540
540 void ExtensionMenuManager::Observe( 541 void ExtensionMenuManager::Observe(
541 int type, 542 int type,
542 const content::NotificationSource& source, 543 const content::NotificationSource& source,
543 const content::NotificationDetails& details) { 544 const content::NotificationDetails& details) {
544 DCHECK(type == chrome::NOTIFICATION_EXTENSION_UNLOADED); 545 DCHECK(type == chrome::NOTIFICATION_EXTENSION_UNLOADED);
545 546
546 // Remove menu items for disabled/uninstalled extensions. 547 // Remove menu items for disabled/uninstalled extensions.
547 const Extension* extension = 548 const extensions::Extension* extension =
548 content::Details<UnloadedExtensionInfo>(details)->extension; 549 content::Details<extensions::UnloadedExtensionInfo>(details)->extension;
549 if (ContainsKey(context_items_, extension->id())) { 550 if (ContainsKey(context_items_, extension->id())) {
550 RemoveAllContextItems(extension->id()); 551 RemoveAllContextItems(extension->id());
551 } 552 }
552 } 553 }
553 554
554 const SkBitmap& ExtensionMenuManager::GetIconForExtension( 555 const SkBitmap& ExtensionMenuManager::GetIconForExtension(
555 const std::string& extension_id) { 556 const std::string& extension_id) {
556 return icon_manager_.GetIcon(extension_id); 557 return icon_manager_.GetIcon(extension_id);
557 } 558 }
558 559
(...skipping 29 matching lines...) Expand all
588 return true; 589 return true;
589 if (extension_id == other.extension_id) { 590 if (extension_id == other.extension_id) {
590 if (uid < other.uid) 591 if (uid < other.uid)
591 return true; 592 return true;
592 if (uid == other.uid) 593 if (uid == other.uid)
593 return string_uid < other.string_uid; 594 return string_uid < other.string_uid;
594 } 595 }
595 } 596 }
596 return false; 597 return false;
597 } 598 }
OLDNEW
« no previous file with comments | « chrome/browser/extensions/extension_menu_manager.h ('k') | chrome/browser/extensions/extension_menu_manager_unittest.cc » ('j') | no next file with comments »

Powered by Google App Engine
This is Rietveld 408576698