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" |
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/extensions/extension.h" | 18 #include "chrome/common/extensions/extension.h" |
19 #include "content/common/notification_service.h" | 19 #include "content/common/notification_service.h" |
20 #include "ui/base/l10n/l10n_util.h" | 20 #include "ui/base/l10n/l10n_util.h" |
21 #include "ui/gfx/favicon_size.h" | 21 #include "ui/gfx/favicon_size.h" |
22 #include "webkit/glue/context_menu.h" | 22 #include "webkit/glue/context_menu.h" |
23 | 23 |
24 ExtensionMenuItem::ExtensionMenuItem(const Id& id, | 24 ExtensionMenuItem::ExtensionMenuItem(const Id& id, |
25 std::string title, | 25 const std::string& title, |
26 bool checked, | 26 bool checked, |
27 Type type, | 27 Type type, |
28 const ContextList& contexts) | 28 const ContextList& contexts) |
29 : id_(id), | 29 : id_(id), |
30 title_(title), | 30 title_(title), |
31 type_(type), | 31 type_(type), |
32 checked_(checked), | 32 checked_(checked), |
33 contexts_(contexts), | 33 contexts_(contexts), |
34 parent_id_(0) { | 34 parent_id_(0) { |
35 } | 35 } |
(...skipping 434 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
470 // static | 470 // static |
471 bool ExtensionMenuManager::HasAllowedScheme(const GURL& url) { | 471 bool ExtensionMenuManager::HasAllowedScheme(const GURL& url) { |
472 URLPattern pattern(kAllowedSchemes); | 472 URLPattern pattern(kAllowedSchemes); |
473 return pattern.SetScheme(url.scheme()); | 473 return pattern.SetScheme(url.scheme()); |
474 } | 474 } |
475 | 475 |
476 ExtensionMenuItem::Id::Id() | 476 ExtensionMenuItem::Id::Id() |
477 : profile(NULL), uid(0) { | 477 : profile(NULL), uid(0) { |
478 } | 478 } |
479 | 479 |
480 ExtensionMenuItem::Id::Id(Profile* profile, std::string extension_id, int uid) | 480 ExtensionMenuItem::Id::Id(Profile* profile, |
| 481 const std::string& extension_id, |
| 482 int uid) |
481 : profile(profile), extension_id(extension_id), uid(uid) { | 483 : profile(profile), extension_id(extension_id), uid(uid) { |
482 } | 484 } |
483 | 485 |
484 ExtensionMenuItem::Id::~Id() { | 486 ExtensionMenuItem::Id::~Id() { |
485 } | 487 } |
486 | 488 |
487 bool ExtensionMenuItem::Id::operator==(const Id& other) const { | 489 bool ExtensionMenuItem::Id::operator==(const Id& other) const { |
488 return (profile == other.profile && | 490 return (profile == other.profile && |
489 extension_id == other.extension_id && | 491 extension_id == other.extension_id && |
490 uid == other.uid); | 492 uid == other.uid); |
491 } | 493 } |
492 | 494 |
493 bool ExtensionMenuItem::Id::operator!=(const Id& other) const { | 495 bool ExtensionMenuItem::Id::operator!=(const Id& other) const { |
494 return !(*this == other); | 496 return !(*this == other); |
495 } | 497 } |
496 | 498 |
497 bool ExtensionMenuItem::Id::operator<(const Id& other) const { | 499 bool ExtensionMenuItem::Id::operator<(const Id& other) const { |
498 if (profile < other.profile) | 500 if (profile < other.profile) |
499 return true; | 501 return true; |
500 if (profile == other.profile) { | 502 if (profile == other.profile) { |
501 if (extension_id < other.extension_id) | 503 if (extension_id < other.extension_id) |
502 return true; | 504 return true; |
503 if (extension_id == other.extension_id) | 505 if (extension_id == other.extension_id) |
504 return uid < other.uid; | 506 return uid < other.uid; |
505 } | 507 } |
506 return false; | 508 return false; |
507 } | 509 } |
OLD | NEW |