Chromium Code Reviews
chromiumcodereview-hr@appspot.gserviceaccount.com (chromiumcodereview-hr) | Please choose your nickname with Settings | Help | Chromium Project | Gerrit Changes | Sign out
(979)

Side by Side Diff: content/renderer/context_menu_params_builder.cc

Issue 15049004: Move ContextMenuParams(WebContextMenuInfo) ctor to content/renderer/. (Closed) Base URL: svn://svn.chromium.org/chrome/trunk/src
Patch Set: class -> struct Created 7 years, 7 months ago
Use n/p to move between diff chunks; N/P to move between comments. Draft comments are only viewable by you.
Jump to:
View unified diff | Download patch | Annotate | Revision Log
« no previous file with comments | « content/renderer/context_menu_params_builder.h ('k') | content/renderer/render_view_impl.cc » ('j') | no next file with comments »
Toggle Intra-line Diffs ('i') | Expand Comments ('e') | Collapse Comments ('c') | Show Comments Hide Comments ('s')
OLDNEW
(Empty)
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.
4
5 #include "content/renderer/context_menu_params_builder.h"
6
7 #include "base/logging.h"
8 #include "content/common/ssl_status_serialization.h"
9 #include "content/public/common/context_menu_params.h"
10 #include "third_party/WebKit/Source/WebKit/chromium/public/WebElement.h"
11 #include "third_party/WebKit/Source/WebKit/chromium/public/WebNode.h"
12 #include "webkit/glue/glue_serialize.h"
13
14 namespace content {
15
16 // static
17 ContextMenuParams ContextMenuParamsBuilder::Build(
18 const WebKit::WebContextMenuData& data) {
19 ContextMenuParams params;
20 params.media_type = data.mediaType;
21 params.x = data.mousePosition.x;
22 params.y = data.mousePosition.y;
23 params.link_url = data.linkURL;
24 params.unfiltered_link_url = data.linkURL;
25 params.src_url = data.srcURL;
26 params.is_image_blocked = data.isImageBlocked;
27 params.page_url = data.pageURL;
28 params.keyword_url = data.keywordURL;
29 params.frame_url = data.frameURL;
30 params.media_flags = data.mediaFlags;
31 params.selection_text = data.selectedText;
32 params.misspelled_word = data.misspelledWord;
33 params.speech_input_enabled = data.isSpeechInputEnabled;
34 params.spellcheck_enabled = data.isSpellCheckingEnabled;
35 params.is_editable = data.isEditable;
36 #if defined(OS_MACOSX)
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 #endif // OS_MACOSX
41 params.edit_flags = data.editFlags;
42 params.frame_charset = data.frameEncoding.utf8();
43 params.referrer_policy = data.referrerPolicy;
44
45 for (size_t i = 0; i < data.dictionarySuggestions.size(); ++i)
46 params.dictionary_suggestions.push_back(data.dictionarySuggestions[i]);
47
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(WebMenuItem(data.customItems[i]));
51
52 if (!data.frameHistoryItem.isNull()) {
53 params.frame_content_state =
54 webkit_glue::HistoryItemToString(data.frameHistoryItem);
55 }
56
57 if (!params.link_url.is_empty()) {
58 WebKit::WebNode selectedNode = data.node;
59
60 // If there are other embedded tags (like <a ..>Some <b>text</b></a>)
61 // we need to extract the parent <a/> node.
62 while (!selectedNode.isLink() && !selectedNode.parentNode().isNull()) {
63 selectedNode = selectedNode.parentNode();
64 }
65
66 WebKit::WebElement selectedElement = selectedNode.to<WebKit::WebElement>();
67 if (selectedNode.isLink() && !selectedElement.isNull()) {
68 params.link_text = selectedElement.innerText();
69 } else {
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"
72 << "ancestor that is a link.";
73 }
74 }
75
76 // Deserialize the SSL info.
77 if (!data.securityInfo.isEmpty()) {
78 DeserializeSecurityInfo(data.securityInfo,
79 &params.security_info.cert_id,
80 &params.security_info.cert_status,
81 &params.security_info.security_bits,
82 &params.security_info.connection_status);
83 }
84
85 return params;
86 }
87
88 } // namespace content
OLDNEW
« no previous file with comments | « content/renderer/context_menu_params_builder.h ('k') | content/renderer/render_view_impl.cc » ('j') | no next file with comments »

Powered by Google App Engine
This is Rietveld 408576698