Revert of Copy the contents of the ASan/Win blacklist to work around http://llvm...
[chromium-blink-merge.git] / content / renderer / context_menu_params_builder.cc
bloba4a37d57a896c1f1abe4d0633d47e94fe5bf4531
1 // Copyright (c) 2013 The Chromium Authors. All rights reserved.
2 // Use of this source code is governed by a BSD-style license that can be
3 // found in the LICENSE file.
5 #include "content/renderer/context_menu_params_builder.h"
7 #include "base/logging.h"
8 #include "content/common/ssl_status_serialization.h"
9 #include "content/public/common/context_menu_params.h"
10 #include "content/renderer/dom_utils.h"
11 #include "content/renderer/history_serialization.h"
12 #include "content/renderer/menu_item_builder.h"
13 #include "third_party/WebKit/public/web/WebElement.h"
14 #include "third_party/WebKit/public/web/WebNode.h"
16 namespace content {
18 // static
19 ContextMenuParams ContextMenuParamsBuilder::Build(
20 const blink::WebContextMenuData& data) {
21 ContextMenuParams params;
22 params.media_type = data.mediaType;
23 params.x = data.mousePosition.x;
24 params.y = data.mousePosition.y;
25 params.link_url = data.linkURL;
26 params.unfiltered_link_url = data.linkURL;
27 params.src_url = data.srcURL;
28 params.has_image_contents = data.hasImageContents;
29 params.page_url = data.pageURL;
30 params.keyword_url = data.keywordURL;
31 params.frame_url = data.frameURL;
32 params.media_flags = data.mediaFlags;
33 params.selection_text = data.selectedText;
34 params.misspelled_word = data.misspelledWord;
35 params.spellcheck_enabled = data.isSpellCheckingEnabled;
36 params.is_editable = data.isEditable;
37 params.writing_direction_default = data.writingDirectionDefault;
38 params.writing_direction_left_to_right = data.writingDirectionLeftToRight;
39 params.writing_direction_right_to_left = data.writingDirectionRightToLeft;
40 params.edit_flags = data.editFlags;
41 params.frame_charset = data.frameEncoding.utf8();
42 params.referrer_policy = data.referrerPolicy;
43 params.suggested_filename = data.suggestedFilename;
45 for (size_t i = 0; i < data.dictionarySuggestions.size(); ++i)
46 params.dictionary_suggestions.push_back(data.dictionarySuggestions[i]);
48 params.custom_context.is_pepper_menu = false;
49 for (size_t i = 0; i < data.customItems.size(); ++i)
50 params.custom_items.push_back(MenuItemBuilder::Build(data.customItems[i]));
52 if (!data.frameHistoryItem.isNull()) {
53 params.frame_page_state =
54 SingleHistoryItemToPageState(data.frameHistoryItem);
57 if (!params.link_url.is_empty()) {
58 blink::WebNode selectedNode = DomUtils::ExtractParentAnchorNode(data.node);
59 blink::WebElement selectedElement = selectedNode.to<blink::WebElement>();
60 if (!selectedElement.isNull() && selectedNode.isLink()) {
61 params.link_text = selectedElement.innerText();
62 } else {
63 LOG(ERROR) << "Creating a ContextMenuParams for a node that has a link"
64 << "url but is not an ElementNode or does not have an"
65 << "ancestor that is a link.";
69 // Deserialize the SSL info.
70 if (!data.securityInfo.isEmpty()) {
71 DeserializeSecurityInfo(data.securityInfo,
72 &params.security_info.cert_id, &params.security_info.cert_status,
73 &params.security_info.security_bits,
74 &params.security_info.connection_status,
75 &params.security_info.signed_certificate_timestamp_ids);
78 return params;
81 } // namespace content