| 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()); | |
| 629 | 628 |
| 630 std::unique_ptr<base::DictionaryValue> properties( | 629 std::unique_ptr<base::DictionaryValue> properties( |
| 631 new base::DictionaryValue()); | 630 new base::DictionaryValue()); |
| 632 SetIdKeyValue(properties.get(), "menuItemId", item->id()); | 631 SetIdKeyValue(properties.get(), "menuItemId", item->id()); |
| 633 if (item->parent_id()) | 632 if (item->parent_id()) |
| 634 SetIdKeyValue(properties.get(), "parentMenuItemId", *item->parent_id()); | 633 SetIdKeyValue(properties.get(), "parentMenuItemId", *item->parent_id()); |
| 635 | 634 |
| 636 switch (params.media_type) { | 635 switch (params.media_type) { |
| 637 case blink::WebContextMenuData::kMediaTypeImage: | 636 case blink::WebContextMenuData::kMediaTypeImage: |
| 638 properties->SetString("mediaType", "image"); | 637 properties->SetString("mediaType", "image"); |
| (...skipping 18 matching lines...) Expand all Loading... |
| 657 properties->SetBoolean("editable", params.is_editable); | 656 properties->SetBoolean("editable", params.is_editable); |
| 658 | 657 |
| 659 WebViewGuest* webview_guest = WebViewGuest::FromWebContents(web_contents); | 658 WebViewGuest* webview_guest = WebViewGuest::FromWebContents(web_contents); |
| 660 if (webview_guest) { | 659 if (webview_guest) { |
| 661 // This is used in web_view_internalcustom_bindings.js. | 660 // This is used in web_view_internalcustom_bindings.js. |
| 662 // The property is not exposed to developer API. | 661 // The property is not exposed to developer API. |
| 663 properties->SetInteger("webviewInstanceId", | 662 properties->SetInteger("webviewInstanceId", |
| 664 webview_guest->view_instance_id()); | 663 webview_guest->view_instance_id()); |
| 665 } | 664 } |
| 666 | 665 |
| 667 base::DictionaryValue* raw_properties = properties.get(); | 666 auto args = base::MakeUnique<base::ListValue>(); |
| 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); |
| 669 | 674 |
| 670 // Add the tab info to the argument list. | 675 // Add the tab info to the argument list. |
| 671 // No tab info in a platform app. | 676 // No tab info in a platform app. |
| 672 if (!extension || !extension->is_platform_app()) { | 677 if (!extension || !extension->is_platform_app()) { |
| 673 // Note: web_contents are null in unit tests :( | 678 // Note: web_contents are null in unit tests :( |
| 674 if (web_contents) { | 679 if (web_contents) { |
| 675 int frame_id = ExtensionApiFrameIdMap::GetFrameId(render_frame_host); | 680 int frame_id = ExtensionApiFrameIdMap::GetFrameId(render_frame_host); |
| 676 if (frame_id != ExtensionApiFrameIdMap::kInvalidFrameId) | 681 if (frame_id != ExtensionApiFrameIdMap::kInvalidFrameId) |
| 677 raw_properties->SetInteger("frameId", frame_id); | 682 raw_properties->SetInteger("frameId", frame_id); |
| 678 | 683 |
| (...skipping 284 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 963 bool MenuItem::Id::operator!=(const Id& other) const { | 968 bool MenuItem::Id::operator!=(const Id& other) const { |
| 964 return !(*this == other); | 969 return !(*this == other); |
| 965 } | 970 } |
| 966 | 971 |
| 967 bool MenuItem::Id::operator<(const Id& other) const { | 972 bool MenuItem::Id::operator<(const Id& other) const { |
| 968 return std::tie(incognito, extension_key, uid, string_uid) < | 973 return std::tie(incognito, extension_key, uid, string_uid) < |
| 969 std::tie(other.incognito, other.extension_key, other.uid, other.string_uid); | 974 std::tie(other.incognito, other.extension_key, other.uid, other.string_uid); |
| 970 } | 975 } |
| 971 | 976 |
| 972 } // namespace extensions | 977 } // namespace extensions |
| OLD | NEW |