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

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

Issue 7327007: Moving notification types which are chrome specific to a new header file chrome_notification_type... (Closed) Base URL: svn://svn.chromium.org/chrome/trunk/src/
Patch Set: '' Created 9 years, 5 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) 2011 The Chromium Authors. All rights reserved. 1 // Copyright (c) 2011 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"
11 #include "base/stl_util-inl.h" 11 #include "base/stl_util-inl.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/extension_event_router.h" 15 #include "chrome/browser/extensions/extension_event_router.h"
16 #include "chrome/browser/extensions/extension_tabs_module.h" 16 #include "chrome/browser/extensions/extension_tabs_module.h"
17 #include "chrome/browser/profiles/profile.h" 17 #include "chrome/browser/profiles/profile.h"
18 #include "chrome/common/chrome_notification_types.h"
18 #include "chrome/common/extensions/extension.h" 19 #include "chrome/common/extensions/extension.h"
19 #include "content/common/notification_service.h" 20 #include "content/common/notification_service.h"
20 #include "ui/base/l10n/l10n_util.h" 21 #include "ui/base/l10n/l10n_util.h"
21 #include "ui/gfx/favicon_size.h" 22 #include "ui/gfx/favicon_size.h"
22 #include "webkit/glue/context_menu.h" 23 #include "webkit/glue/context_menu.h"
23 24
24 ExtensionMenuItem::ExtensionMenuItem(const Id& id, 25 ExtensionMenuItem::ExtensionMenuItem(const Id& id,
25 const std::string& title, 26 const std::string& title,
26 bool checked, 27 bool checked,
27 Type type, 28 Type type,
(...skipping 60 matching lines...) Expand 10 before | Expand all | Expand 10 after
88 89
89 void ExtensionMenuItem::AddChild(ExtensionMenuItem* item) { 90 void ExtensionMenuItem::AddChild(ExtensionMenuItem* item) {
90 item->parent_id_.reset(new Id(id_)); 91 item->parent_id_.reset(new Id(id_));
91 children_.push_back(item); 92 children_.push_back(item);
92 } 93 }
93 94
94 const int ExtensionMenuManager::kAllowedSchemes = 95 const int ExtensionMenuManager::kAllowedSchemes =
95 URLPattern::SCHEME_HTTP | URLPattern::SCHEME_HTTPS; 96 URLPattern::SCHEME_HTTP | URLPattern::SCHEME_HTTPS;
96 97
97 ExtensionMenuManager::ExtensionMenuManager() { 98 ExtensionMenuManager::ExtensionMenuManager() {
98 registrar_.Add(this, NotificationType::EXTENSION_UNLOADED, 99 registrar_.Add(this, chrome::NOTIFICATION_EXTENSION_UNLOADED,
99 NotificationService::AllSources()); 100 NotificationService::AllSources());
100 } 101 }
101 102
102 ExtensionMenuManager::~ExtensionMenuManager() { 103 ExtensionMenuManager::~ExtensionMenuManager() {
103 MenuItemMap::iterator i; 104 MenuItemMap::iterator i;
104 for (i = context_items_.begin(); i != context_items_.end(); ++i) { 105 for (i = context_items_.begin(); i != context_items_.end(); ++i) {
105 STLDeleteElements(&(i->second)); 106 STLDeleteElements(&(i->second));
106 } 107 }
107 } 108 }
108 109
(...skipping 332 matching lines...) Expand 10 before | Expand all | Expand 10 after
441 properties->SetBoolean("checked", item->checked()); 442 properties->SetBoolean("checked", item->checked());
442 } 443 }
443 444
444 std::string json_args; 445 std::string json_args;
445 base::JSONWriter::Write(&args, false, &json_args); 446 base::JSONWriter::Write(&args, false, &json_args);
446 std::string event_name = "contextMenus"; 447 std::string event_name = "contextMenus";
447 event_router->DispatchEventToExtension( 448 event_router->DispatchEventToExtension(
448 item->extension_id(), event_name, json_args, profile, GURL()); 449 item->extension_id(), event_name, json_args, profile, GURL());
449 } 450 }
450 451
451 void ExtensionMenuManager::Observe(NotificationType type, 452 void ExtensionMenuManager::Observe(int type,
452 const NotificationSource& source, 453 const NotificationSource& source,
453 const NotificationDetails& details) { 454 const NotificationDetails& details) {
454 // Remove menu items for disabled/uninstalled extensions. 455 // Remove menu items for disabled/uninstalled extensions.
455 if (type != NotificationType::EXTENSION_UNLOADED) { 456 if (type != chrome::NOTIFICATION_EXTENSION_UNLOADED) {
456 NOTREACHED(); 457 NOTREACHED();
457 return; 458 return;
458 } 459 }
459 const Extension* extension = 460 const Extension* extension =
460 Details<UnloadedExtensionInfo>(details)->extension; 461 Details<UnloadedExtensionInfo>(details)->extension;
461 if (ContainsKey(context_items_, extension->id())) { 462 if (ContainsKey(context_items_, extension->id())) {
462 RemoveAllContextItems(extension->id()); 463 RemoveAllContextItems(extension->id());
463 } 464 }
464 } 465 }
465 466
(...skipping 35 matching lines...) Expand 10 before | Expand all | Expand 10 after
501 if (profile < other.profile) 502 if (profile < other.profile)
502 return true; 503 return true;
503 if (profile == other.profile) { 504 if (profile == other.profile) {
504 if (extension_id < other.extension_id) 505 if (extension_id < other.extension_id)
505 return true; 506 return true;
506 if (extension_id == other.extension_id) 507 if (extension_id == other.extension_id)
507 return uid < other.uid; 508 return uid < other.uid;
508 } 509 }
509 return false; 510 return false;
510 } 511 }
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