Merge Chromium + Blink git repositories
[chromium-blink-merge.git] / content / renderer / context_menu_params_builder.cc
blob6c7752a97a1fb46953133e6916454c3890edfdc4
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 "content/common/ssl_status_serialization.h"
8 #include "content/public/common/context_menu_params.h"
9 #include "content/public/renderer/content_renderer_client.h"
10 #include "content/renderer/history_serialization.h"
11 #include "content/renderer/menu_item_builder.h"
13 namespace content {
15 // static
16 ContextMenuParams ContextMenuParamsBuilder::Build(
17 const blink::WebContextMenuData& data) {
18 ContextMenuParams params;
19 params.media_type = data.mediaType;
20 params.x = data.mousePosition.x;
21 params.y = data.mousePosition.y;
22 params.link_url = data.linkURL;
23 params.unfiltered_link_url = data.linkURL;
24 params.src_url = data.srcURL;
25 params.has_image_contents = data.hasImageContents;
26 params.page_url = data.pageURL;
27 params.keyword_url = data.keywordURL;
28 params.frame_url = data.frameURL;
29 params.media_flags = data.mediaFlags;
30 params.selection_text = data.selectedText;
31 params.title_text = data.titleText;
32 params.misspelled_word = data.misspelledWord;
33 params.misspelling_hash = data.misspellingHash;
34 params.spellcheck_enabled = data.isSpellCheckingEnabled;
35 params.is_editable = data.isEditable;
36 params.writing_direction_default = data.writingDirectionDefault;
37 params.writing_direction_left_to_right = data.writingDirectionLeftToRight;
38 params.writing_direction_right_to_left = data.writingDirectionRightToLeft;
39 params.edit_flags = data.editFlags;
40 params.frame_charset = data.frameEncoding.utf8();
41 params.referrer_policy = data.referrerPolicy;
42 params.suggested_filename = data.suggestedFilename;
43 params.input_field_type = data.inputFieldType;
45 if (!data.imageResponse.isNull()) {
46 GetContentClient()->renderer()->AddImageContextMenuProperties(
47 data.imageResponse, &params.properties);
50 for (size_t i = 0; i < data.dictionarySuggestions.size(); ++i)
51 params.dictionary_suggestions.push_back(data.dictionarySuggestions[i]);
53 params.custom_context.is_pepper_menu = false;
54 for (size_t i = 0; i < data.customItems.size(); ++i)
55 params.custom_items.push_back(MenuItemBuilder::Build(data.customItems[i]));
57 if (!data.frameHistoryItem.isNull()) {
58 params.frame_page_state =
59 SingleHistoryItemToPageState(data.frameHistoryItem);
62 params.link_text = data.linkText;
64 // Deserialize the SSL info.
65 if (!data.securityInfo.isEmpty())
66 CHECK(DeserializeSecurityInfo(data.securityInfo, &params.security_info));
68 return params;
71 } // namespace content