OLD | NEW |
1 // Copyright (c) 2013 The Chromium Authors. All rights reserved. | 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 | 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 "content/renderer/context_menu_params_builder.h" | 5 #include "content/renderer/context_menu_params_builder.h" |
6 | 6 |
7 #include "base/logging.h" | 7 #include "base/logging.h" |
8 #include "content/common/ssl_status_serialization.h" | 8 #include "content/common/ssl_status_serialization.h" |
9 #include "content/public/common/context_menu_params.h" | 9 #include "content/public/common/context_menu_params.h" |
10 #include "content/public/renderer/history_item_serialization.h" | 10 #include "content/public/renderer/history_item_serialization.h" |
11 #include "content/renderer/menu_item_builder.h" | 11 #include "content/renderer/menu_item_builder.h" |
12 #include "third_party/WebKit/public/web/WebElement.h" | 12 #include "third_party/WebKit/public/web/WebElement.h" |
13 #include "third_party/WebKit/public/web/WebNode.h" | 13 #include "third_party/WebKit/public/web/WebNode.h" |
14 | 14 |
15 namespace content { | 15 namespace content { |
16 | 16 |
17 // static | 17 // static |
18 ContextMenuParams ContextMenuParamsBuilder::Build( | 18 ContextMenuParams ContextMenuParamsBuilder::Build( |
19 const WebKit::WebContextMenuData& data) { | 19 const blink::WebContextMenuData& data) { |
20 ContextMenuParams params; | 20 ContextMenuParams params; |
21 params.media_type = data.mediaType; | 21 params.media_type = data.mediaType; |
22 params.x = data.mousePosition.x; | 22 params.x = data.mousePosition.x; |
23 params.y = data.mousePosition.y; | 23 params.y = data.mousePosition.y; |
24 params.link_url = data.linkURL; | 24 params.link_url = data.linkURL; |
25 params.unfiltered_link_url = data.linkURL; | 25 params.unfiltered_link_url = data.linkURL; |
26 params.src_url = data.srcURL; | 26 params.src_url = data.srcURL; |
27 params.has_image_contents = data.hasImageContents; | 27 params.has_image_contents = data.hasImageContents; |
28 params.page_url = data.pageURL; | 28 params.page_url = data.pageURL; |
29 params.keyword_url = data.keywordURL; | 29 params.keyword_url = data.keywordURL; |
(...skipping 18 matching lines...) Expand all Loading... |
48 params.dictionary_suggestions.push_back(data.dictionarySuggestions[i]); | 48 params.dictionary_suggestions.push_back(data.dictionarySuggestions[i]); |
49 | 49 |
50 params.custom_context.is_pepper_menu = false; | 50 params.custom_context.is_pepper_menu = false; |
51 for (size_t i = 0; i < data.customItems.size(); ++i) | 51 for (size_t i = 0; i < data.customItems.size(); ++i) |
52 params.custom_items.push_back(MenuItemBuilder::Build(data.customItems[i])); | 52 params.custom_items.push_back(MenuItemBuilder::Build(data.customItems[i])); |
53 | 53 |
54 if (!data.frameHistoryItem.isNull()) | 54 if (!data.frameHistoryItem.isNull()) |
55 params.frame_page_state = HistoryItemToPageState(data.frameHistoryItem); | 55 params.frame_page_state = HistoryItemToPageState(data.frameHistoryItem); |
56 | 56 |
57 if (!params.link_url.is_empty()) { | 57 if (!params.link_url.is_empty()) { |
58 WebKit::WebNode selectedNode = data.node; | 58 blink::WebNode selectedNode = data.node; |
59 | 59 |
60 // If there are other embedded tags (like <a ..>Some <b>text</b></a>) | 60 // If there are other embedded tags (like <a ..>Some <b>text</b></a>) |
61 // we need to extract the parent <a/> node. | 61 // we need to extract the parent <a/> node. |
62 while (!selectedNode.isLink() && !selectedNode.parentNode().isNull()) { | 62 while (!selectedNode.isLink() && !selectedNode.parentNode().isNull()) { |
63 selectedNode = selectedNode.parentNode(); | 63 selectedNode = selectedNode.parentNode(); |
64 } | 64 } |
65 | 65 |
66 WebKit::WebElement selectedElement = selectedNode.to<WebKit::WebElement>(); | 66 blink::WebElement selectedElement = selectedNode.to<blink::WebElement>(); |
67 if (selectedNode.isLink() && !selectedElement.isNull()) { | 67 if (selectedNode.isLink() && !selectedElement.isNull()) { |
68 params.link_text = selectedElement.innerText(); | 68 params.link_text = selectedElement.innerText(); |
69 } else { | 69 } else { |
70 LOG(ERROR) << "Creating a ContextMenuParams for a node that has a link" | 70 LOG(ERROR) << "Creating a ContextMenuParams for a node that has a link" |
71 << "url but is not an ElementNode or does not have an" | 71 << "url but is not an ElementNode or does not have an" |
72 << "ancestor that is a link."; | 72 << "ancestor that is a link."; |
73 } | 73 } |
74 } | 74 } |
75 | 75 |
76 // Deserialize the SSL info. | 76 // Deserialize the SSL info. |
77 if (!data.securityInfo.isEmpty()) { | 77 if (!data.securityInfo.isEmpty()) { |
78 DeserializeSecurityInfo(data.securityInfo, | 78 DeserializeSecurityInfo(data.securityInfo, |
79 ¶ms.security_info.cert_id, | 79 ¶ms.security_info.cert_id, |
80 ¶ms.security_info.cert_status, | 80 ¶ms.security_info.cert_status, |
81 ¶ms.security_info.security_bits, | 81 ¶ms.security_info.security_bits, |
82 ¶ms.security_info.connection_status); | 82 ¶ms.security_info.connection_status); |
83 } | 83 } |
84 | 84 |
85 return params; | 85 return params; |
86 } | 86 } |
87 | 87 |
88 } // namespace content | 88 } // namespace content |
OLD | NEW |