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

Unified 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 side-by-side diff with in-line comments
Download patch
« 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 »
Expand Comments ('e') | Collapse Comments ('c') | Show Comments Hide Comments ('s')
Index: content/renderer/context_menu_params_builder.cc
diff --git a/content/renderer/context_menu_params_builder.cc b/content/renderer/context_menu_params_builder.cc
new file mode 100644
index 0000000000000000000000000000000000000000..dfc6582058bc52e48c88c3b1166c83f751bb629a
--- /dev/null
+++ b/content/renderer/context_menu_params_builder.cc
@@ -0,0 +1,88 @@
+// Copyright (c) 2013 The Chromium Authors. All rights reserved.
+// Use of this source code is governed by a BSD-style license that can be
+// found in the LICENSE file.
+
+#include "content/renderer/context_menu_params_builder.h"
+
+#include "base/logging.h"
+#include "content/common/ssl_status_serialization.h"
+#include "content/public/common/context_menu_params.h"
+#include "third_party/WebKit/Source/WebKit/chromium/public/WebElement.h"
+#include "third_party/WebKit/Source/WebKit/chromium/public/WebNode.h"
+#include "webkit/glue/glue_serialize.h"
+
+namespace content {
+
+// static
+ContextMenuParams ContextMenuParamsBuilder::Build(
+ const WebKit::WebContextMenuData& data) {
+ ContextMenuParams params;
+ params.media_type = data.mediaType;
+ params.x = data.mousePosition.x;
+ params.y = data.mousePosition.y;
+ params.link_url = data.linkURL;
+ params.unfiltered_link_url = data.linkURL;
+ params.src_url = data.srcURL;
+ params.is_image_blocked = data.isImageBlocked;
+ params.page_url = data.pageURL;
+ params.keyword_url = data.keywordURL;
+ params.frame_url = data.frameURL;
+ params.media_flags = data.mediaFlags;
+ params.selection_text = data.selectedText;
+ params.misspelled_word = data.misspelledWord;
+ params.speech_input_enabled = data.isSpeechInputEnabled;
+ params.spellcheck_enabled = data.isSpellCheckingEnabled;
+ params.is_editable = data.isEditable;
+#if defined(OS_MACOSX)
+ params.writing_direction_default = data.writingDirectionDefault;
+ params.writing_direction_left_to_right = data.writingDirectionLeftToRight;
+ params.writing_direction_right_to_left = data.writingDirectionRightToLeft;
+#endif // OS_MACOSX
+ params.edit_flags = data.editFlags;
+ params.frame_charset = data.frameEncoding.utf8();
+ params.referrer_policy = data.referrerPolicy;
+
+ for (size_t i = 0; i < data.dictionarySuggestions.size(); ++i)
+ params.dictionary_suggestions.push_back(data.dictionarySuggestions[i]);
+
+ params.custom_context.is_pepper_menu = false;
+ for (size_t i = 0; i < data.customItems.size(); ++i)
+ params.custom_items.push_back(WebMenuItem(data.customItems[i]));
+
+ if (!data.frameHistoryItem.isNull()) {
+ params.frame_content_state =
+ webkit_glue::HistoryItemToString(data.frameHistoryItem);
+ }
+
+ if (!params.link_url.is_empty()) {
+ WebKit::WebNode selectedNode = data.node;
+
+ // If there are other embedded tags (like <a ..>Some <b>text</b></a>)
+ // we need to extract the parent <a/> node.
+ while (!selectedNode.isLink() && !selectedNode.parentNode().isNull()) {
+ selectedNode = selectedNode.parentNode();
+ }
+
+ WebKit::WebElement selectedElement = selectedNode.to<WebKit::WebElement>();
+ if (selectedNode.isLink() && !selectedElement.isNull()) {
+ params.link_text = selectedElement.innerText();
+ } else {
+ LOG(ERROR) << "Creating a ContextMenuParams for a node that has a link"
+ << "url but is not an ElementNode or does not have an"
+ << "ancestor that is a link.";
+ }
+ }
+
+ // Deserialize the SSL info.
+ if (!data.securityInfo.isEmpty()) {
+ DeserializeSecurityInfo(data.securityInfo,
+ &params.security_info.cert_id,
+ &params.security_info.cert_status,
+ &params.security_info.security_bits,
+ &params.security_info.connection_status);
+ }
+
+ return params;
+}
+
+} // namespace content
« 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