| OLD | NEW |
| 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/menu_manager.h" | 5 #include "chrome/browser/extensions/menu_manager.h" |
| 6 | 6 |
| 7 #include <algorithm> | 7 #include <algorithm> |
| 8 #include <memory> | 8 #include <memory> |
| 9 #include <tuple> | 9 #include <tuple> |
| 10 #include <utility> | 10 #include <utility> |
| (...skipping 607 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 618 if (!item) | 618 if (!item) |
| 619 return; | 619 return; |
| 620 | 620 |
| 621 ExtensionRegistry* registry = ExtensionRegistry::Get(browser_context_); | 621 ExtensionRegistry* registry = ExtensionRegistry::Get(browser_context_); |
| 622 const Extension* extension = | 622 const Extension* extension = |
| 623 registry->enabled_extensions().GetByID(item->extension_id()); | 623 registry->enabled_extensions().GetByID(item->extension_id()); |
| 624 | 624 |
| 625 if (item->type() == MenuItem::RADIO) | 625 if (item->type() == MenuItem::RADIO) |
| 626 RadioItemSelected(item); | 626 RadioItemSelected(item); |
| 627 | 627 |
| 628 std::unique_ptr<base::ListValue> args(new base::ListValue()); |
| 628 | 629 |
| 629 std::unique_ptr<base::DictionaryValue> properties( | 630 std::unique_ptr<base::DictionaryValue> properties( |
| 630 new base::DictionaryValue()); | 631 new base::DictionaryValue()); |
| 631 SetIdKeyValue(properties.get(), "menuItemId", item->id()); | 632 SetIdKeyValue(properties.get(), "menuItemId", item->id()); |
| 632 if (item->parent_id()) | 633 if (item->parent_id()) |
| 633 SetIdKeyValue(properties.get(), "parentMenuItemId", *item->parent_id()); | 634 SetIdKeyValue(properties.get(), "parentMenuItemId", *item->parent_id()); |
| 634 | 635 |
| 635 switch (params.media_type) { | 636 switch (params.media_type) { |
| 636 case blink::WebContextMenuData::kMediaTypeImage: | 637 case blink::WebContextMenuData::kMediaTypeImage: |
| 637 properties->SetString("mediaType", "image"); | 638 properties->SetString("mediaType", "image"); |
| (...skipping 18 matching lines...) Expand all Loading... |
| 656 properties->SetBoolean("editable", params.is_editable); | 657 properties->SetBoolean("editable", params.is_editable); |
| 657 | 658 |
| 658 WebViewGuest* webview_guest = WebViewGuest::FromWebContents(web_contents); | 659 WebViewGuest* webview_guest = WebViewGuest::FromWebContents(web_contents); |
| 659 if (webview_guest) { | 660 if (webview_guest) { |
| 660 // This is used in web_view_internalcustom_bindings.js. | 661 // This is used in web_view_internalcustom_bindings.js. |
| 661 // The property is not exposed to developer API. | 662 // The property is not exposed to developer API. |
| 662 properties->SetInteger("webviewInstanceId", | 663 properties->SetInteger("webviewInstanceId", |
| 663 webview_guest->view_instance_id()); | 664 webview_guest->view_instance_id()); |
| 664 } | 665 } |
| 665 | 666 |
| 666 auto args = base::MakeUnique<base::ListValue>(); | 667 base::DictionaryValue* raw_properties = properties.get(); |
| 667 args->Reserve(2); | |
| 668 args->Append(std::move(properties)); | 668 args->Append(std::move(properties)); |
| 669 // |properties| is invalidated at this time, which is why |args| needs to be | |
| 670 // queried for the pointer. The obtained pointer is guaranteed to stay valid | |
| 671 // even after further Appends, because enough storage was reserved above. | |
| 672 base::DictionaryValue* raw_properties = nullptr; | |
| 673 args->GetDictionary(0, &raw_properties); | |
| 674 | 669 |
| 675 // Add the tab info to the argument list. | 670 // Add the tab info to the argument list. |
| 676 // No tab info in a platform app. | 671 // No tab info in a platform app. |
| 677 if (!extension || !extension->is_platform_app()) { | 672 if (!extension || !extension->is_platform_app()) { |
| 678 // Note: web_contents are null in unit tests :( | 673 // Note: web_contents are null in unit tests :( |
| 679 if (web_contents) { | 674 if (web_contents) { |
| 680 int frame_id = ExtensionApiFrameIdMap::GetFrameId(render_frame_host); | 675 int frame_id = ExtensionApiFrameIdMap::GetFrameId(render_frame_host); |
| 681 if (frame_id != ExtensionApiFrameIdMap::kInvalidFrameId) | 676 if (frame_id != ExtensionApiFrameIdMap::kInvalidFrameId) |
| 682 raw_properties->SetInteger("frameId", frame_id); | 677 raw_properties->SetInteger("frameId", frame_id); |
| 683 | 678 |
| (...skipping 284 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 968 bool MenuItem::Id::operator!=(const Id& other) const { | 963 bool MenuItem::Id::operator!=(const Id& other) const { |
| 969 return !(*this == other); | 964 return !(*this == other); |
| 970 } | 965 } |
| 971 | 966 |
| 972 bool MenuItem::Id::operator<(const Id& other) const { | 967 bool MenuItem::Id::operator<(const Id& other) const { |
| 973 return std::tie(incognito, extension_key, uid, string_uid) < | 968 return std::tie(incognito, extension_key, uid, string_uid) < |
| 974 std::tie(other.incognito, other.extension_key, other.uid, other.string_uid); | 969 std::tie(other.incognito, other.extension_key, other.uid, other.string_uid); |
| 975 } | 970 } |
| 976 | 971 |
| 977 } // namespace extensions | 972 } // namespace extensions |
| OLD | NEW |