OLD | NEW |
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" |
(...skipping 74 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
85 return false; | 85 return false; |
86 checked_ = checked; | 86 checked_ = checked; |
87 return true; | 87 return true; |
88 } | 88 } |
89 | 89 |
90 void ExtensionMenuItem::AddChild(ExtensionMenuItem* item) { | 90 void ExtensionMenuItem::AddChild(ExtensionMenuItem* item) { |
91 item->parent_id_.reset(new Id(id_)); | 91 item->parent_id_.reset(new Id(id_)); |
92 children_.push_back(item); | 92 children_.push_back(item); |
93 } | 93 } |
94 | 94 |
95 const int ExtensionMenuManager::kAllowedSchemes = | |
96 URLPattern::SCHEME_HTTP | URLPattern::SCHEME_HTTPS; | |
97 | |
98 ExtensionMenuManager::ExtensionMenuManager() { | 95 ExtensionMenuManager::ExtensionMenuManager() { |
99 registrar_.Add(this, chrome::NOTIFICATION_EXTENSION_UNLOADED, | 96 registrar_.Add(this, chrome::NOTIFICATION_EXTENSION_UNLOADED, |
100 NotificationService::AllSources()); | 97 NotificationService::AllSources()); |
101 } | 98 } |
102 | 99 |
103 ExtensionMenuManager::~ExtensionMenuManager() { | 100 ExtensionMenuManager::~ExtensionMenuManager() { |
104 MenuItemMap::iterator i; | 101 MenuItemMap::iterator i; |
105 for (i = context_items_.begin(); i != context_items_.end(); ++i) { | 102 for (i = context_items_.begin(); i != context_items_.end(); ++i) { |
106 STLDeleteElements(&(i->second)); | 103 STLDeleteElements(&(i->second)); |
107 } | 104 } |
(...skipping 354 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
462 if (ContainsKey(context_items_, extension->id())) { | 459 if (ContainsKey(context_items_, extension->id())) { |
463 RemoveAllContextItems(extension->id()); | 460 RemoveAllContextItems(extension->id()); |
464 } | 461 } |
465 } | 462 } |
466 | 463 |
467 const SkBitmap& ExtensionMenuManager::GetIconForExtension( | 464 const SkBitmap& ExtensionMenuManager::GetIconForExtension( |
468 const std::string& extension_id) { | 465 const std::string& extension_id) { |
469 return icon_manager_.GetIcon(extension_id); | 466 return icon_manager_.GetIcon(extension_id); |
470 } | 467 } |
471 | 468 |
472 // static | |
473 bool ExtensionMenuManager::HasAllowedScheme(const GURL& url) { | |
474 URLPattern pattern(kAllowedSchemes); | |
475 return pattern.SetScheme(url.scheme()); | |
476 } | |
477 | |
478 ExtensionMenuItem::Id::Id() | 469 ExtensionMenuItem::Id::Id() |
479 : profile(NULL), uid(0) { | 470 : profile(NULL), uid(0) { |
480 } | 471 } |
481 | 472 |
482 ExtensionMenuItem::Id::Id(Profile* profile, | 473 ExtensionMenuItem::Id::Id(Profile* profile, |
483 const std::string& extension_id, | 474 const std::string& extension_id, |
484 int uid) | 475 int uid) |
485 : profile(profile), extension_id(extension_id), uid(uid) { | 476 : profile(profile), extension_id(extension_id), uid(uid) { |
486 } | 477 } |
487 | 478 |
(...skipping 14 matching lines...) Expand all Loading... |
502 if (profile < other.profile) | 493 if (profile < other.profile) |
503 return true; | 494 return true; |
504 if (profile == other.profile) { | 495 if (profile == other.profile) { |
505 if (extension_id < other.extension_id) | 496 if (extension_id < other.extension_id) |
506 return true; | 497 return true; |
507 if (extension_id == other.extension_id) | 498 if (extension_id == other.extension_id) |
508 return uid < other.uid; | 499 return uid < other.uid; |
509 } | 500 } |
510 return false; | 501 return false; |
511 } | 502 } |
OLD | NEW |