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

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 2 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 109 matching lines...) Expand 10 before | Expand all | Expand 10 after
120 120
121 const ExtensionMenuItem::List* ExtensionMenuManager::MenuItems( 121 const ExtensionMenuItem::List* ExtensionMenuManager::MenuItems(
122 const std::string& extension_id) { 122 const std::string& extension_id) {
123 MenuItemMap::iterator i = context_items_.find(extension_id); 123 MenuItemMap::iterator i = context_items_.find(extension_id);
124 if (i != context_items_.end()) { 124 if (i != context_items_.end()) {
125 return &(i->second); 125 return &(i->second);
126 } 126 }
127 return NULL; 127 return NULL;
128 } 128 }
129 129
130 bool ExtensionMenuManager::AddContextItem(const Extension* extension, 130 bool ExtensionMenuManager::AddContextItem(
131 ExtensionMenuItem* item) { 131 const extensions::Extension* extension,
132 ExtensionMenuItem* item) {
132 const std::string& extension_id = item->extension_id(); 133 const std::string& extension_id = item->extension_id();
133 // The item must have a non-empty extension id, and not have already been 134 // The item must have a non-empty extension id, and not have already been
134 // added. 135 // added.
135 if (extension_id.empty() || ContainsKey(items_by_id_, item->id())) 136 if (extension_id.empty() || ContainsKey(items_by_id_, item->id()))
136 return false; 137 return false;
137 138
138 DCHECK_EQ(extension->id(), extension_id); 139 DCHECK_EQ(extension->id(), extension_id);
139 140
140 bool first_item = !ContainsKey(context_items_, extension_id); 141 bool first_item = !ContainsKey(context_items_, extension_id);
141 context_items_[extension_id].push_back(item); 142 context_items_[extension_id].push_back(item);
(...skipping 381 matching lines...) Expand 10 before | Expand all | Expand 10 after
523 return true; 524 return true;
524 } 525 }
525 526
526 void ExtensionMenuManager::Observe( 527 void ExtensionMenuManager::Observe(
527 int type, 528 int type,
528 const content::NotificationSource& source, 529 const content::NotificationSource& source,
529 const content::NotificationDetails& details) { 530 const content::NotificationDetails& details) {
530 DCHECK(type == chrome::NOTIFICATION_EXTENSION_UNLOADED); 531 DCHECK(type == chrome::NOTIFICATION_EXTENSION_UNLOADED);
531 532
532 // Remove menu items for disabled/uninstalled extensions. 533 // Remove menu items for disabled/uninstalled extensions.
533 const Extension* extension = 534 const extensions::Extension* extension =
534 content::Details<UnloadedExtensionInfo>(details)->extension; 535 content::Details<extensions::UnloadedExtensionInfo>(details)->extension;
535 if (ContainsKey(context_items_, extension->id())) { 536 if (ContainsKey(context_items_, extension->id())) {
536 RemoveAllContextItems(extension->id()); 537 RemoveAllContextItems(extension->id());
537 } 538 }
538 } 539 }
539 540
540 const SkBitmap& ExtensionMenuManager::GetIconForExtension( 541 const SkBitmap& ExtensionMenuManager::GetIconForExtension(
541 const std::string& extension_id) { 542 const std::string& extension_id) {
542 return icon_manager_.GetIcon(extension_id); 543 return icon_manager_.GetIcon(extension_id);
543 } 544 }
544 545
(...skipping 24 matching lines...) Expand all
569 if (profile < other.profile) 570 if (profile < other.profile)
570 return true; 571 return true;
571 if (profile == other.profile) { 572 if (profile == other.profile) {
572 if (extension_id < other.extension_id) 573 if (extension_id < other.extension_id)
573 return true; 574 return true;
574 if (extension_id == other.extension_id) 575 if (extension_id == other.extension_id)
575 return uid < other.uid; 576 return uid < other.uid;
576 } 577 }
577 return false; 578 return false;
578 } 579 }
OLDNEW

Powered by Google App Engine
This is Rietveld 408576698