| OLD | NEW |
| 1 // Copyright (c) 2010 The Chromium Authors. All rights reserved. | 1 // Copyright (c) 2010 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 "app/l10n_util.h" | 9 #include "app/l10n_util.h" |
| 10 #include "base/logging.h" | 10 #include "base/logging.h" |
| (...skipping 371 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 382 ExtensionMenuItem* item = GetItemById(menuItemId); | 382 ExtensionMenuItem* item = GetItemById(menuItemId); |
| 383 if (!item) | 383 if (!item) |
| 384 return; | 384 return; |
| 385 | 385 |
| 386 if (item->type() == ExtensionMenuItem::RADIO) | 386 if (item->type() == ExtensionMenuItem::RADIO) |
| 387 RadioItemSelected(item); | 387 RadioItemSelected(item); |
| 388 | 388 |
| 389 ListValue args; | 389 ListValue args; |
| 390 | 390 |
| 391 DictionaryValue* properties = new DictionaryValue(); | 391 DictionaryValue* properties = new DictionaryValue(); |
| 392 properties->SetInteger("menuItemId", item->id().second); | 392 properties->SetInteger("menuItemId", item->id().uid); |
| 393 if (item->parent_id()) | 393 if (item->parent_id()) |
| 394 properties->SetInteger("parentMenuItemId", item->parent_id()->second); | 394 properties->SetInteger("parentMenuItemId", item->parent_id()->uid); |
| 395 | 395 |
| 396 switch (params.media_type) { | 396 switch (params.media_type) { |
| 397 case WebKit::WebContextMenuData::MediaTypeImage: | 397 case WebKit::WebContextMenuData::MediaTypeImage: |
| 398 properties->SetString("mediaType", "image"); | 398 properties->SetString("mediaType", "image"); |
| 399 break; | 399 break; |
| 400 case WebKit::WebContextMenuData::MediaTypeVideo: | 400 case WebKit::WebContextMenuData::MediaTypeVideo: |
| 401 properties->SetString("mediaType", "video"); | 401 properties->SetString("mediaType", "video"); |
| 402 break; | 402 break; |
| 403 case WebKit::WebContextMenuData::MediaTypeAudio: | 403 case WebKit::WebContextMenuData::MediaTypeAudio: |
| 404 properties->SetString("mediaType", "audio"); | 404 properties->SetString("mediaType", "audio"); |
| (...skipping 59 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 464 const SkBitmap& ExtensionMenuManager::GetIconForExtension( | 464 const SkBitmap& ExtensionMenuManager::GetIconForExtension( |
| 465 const std::string& extension_id) { | 465 const std::string& extension_id) { |
| 466 return icon_manager_.GetIcon(extension_id); | 466 return icon_manager_.GetIcon(extension_id); |
| 467 } | 467 } |
| 468 | 468 |
| 469 // static | 469 // static |
| 470 bool ExtensionMenuManager::HasAllowedScheme(const GURL& url) { | 470 bool ExtensionMenuManager::HasAllowedScheme(const GURL& url) { |
| 471 URLPattern pattern(kAllowedSchemes); | 471 URLPattern pattern(kAllowedSchemes); |
| 472 return pattern.SetScheme(url.scheme()); | 472 return pattern.SetScheme(url.scheme()); |
| 473 } | 473 } |
| 474 |
| 475 ExtensionMenuItem::Id::Id() |
| 476 : profile(NULL), uid(0) { |
| 477 } |
| 478 |
| 479 ExtensionMenuItem::Id::Id(Profile* profile, std::string extension_id, int uid) |
| 480 : profile(profile), extension_id(extension_id), uid(uid) { |
| 481 } |
| 482 |
| 483 ExtensionMenuItem::Id::~Id() { |
| 484 } |
| 485 |
| 486 bool ExtensionMenuItem::Id::operator==(const Id& other) const { |
| 487 return (profile == other.profile && |
| 488 extension_id == other.extension_id && |
| 489 uid == other.uid); |
| 490 } |
| 491 |
| 492 bool ExtensionMenuItem::Id::operator!=(const Id& other) const { |
| 493 return !(*this == other); |
| 494 } |
| 495 |
| 496 bool ExtensionMenuItem::Id::operator<(const Id& other) const { |
| 497 if (profile < other.profile) |
| 498 return true; |
| 499 if (profile == other.profile) { |
| 500 if (extension_id < other.extension_id) |
| 501 return true; |
| 502 if (extension_id == other.extension_id) |
| 503 return uid < other.uid; |
| 504 } |
| 505 return false; |
| 506 } |
| OLD | NEW |