[email protected] | 574a1d6 | 2009-07-17 03:23:46 | [diff] [blame] | 1 | // Copyright (c) 2006-2009 The Chromium Authors. All rights reserved. |
license.bot | bf09a50 | 2008-08-24 00:55:55 | [diff] [blame] | 2 | // Use of this source code is governed by a BSD-style license that can be |
| 3 | // found in the LICENSE file. |
initial.commit | f5b16fe | 2008-07-27 00:20:51 | [diff] [blame] | 4 | |
| 5 | #include "config.h" |
| 6 | |
[email protected] | fa41969 | 2008-10-16 21:46:14 | [diff] [blame] | 7 | #include "base/compiler_specific.h" |
| 8 | |
| 9 | MSVC_PUSH_WARNING_LEVEL(0); |
initial.commit | f5b16fe | 2008-07-27 00:20:51 | [diff] [blame] | 10 | #include "ContextMenu.h" |
| 11 | #include "Document.h" |
| 12 | #include "DocumentLoader.h" |
| 13 | #include "Editor.h" |
[email protected] | 985f0e6 | 2008-10-29 01:05:08 | [diff] [blame] | 14 | #include "EventHandler.h" |
initial.commit | f5b16fe | 2008-07-27 00:20:51 | [diff] [blame] | 15 | #include "FrameLoader.h" |
| 16 | #include "FrameView.h" |
| 17 | #include "HitTestResult.h" |
[email protected] | 574a1d6 | 2009-07-17 03:23:46 | [diff] [blame] | 18 | #include "HTMLMediaElement.h" |
| 19 | #include "HTMLNames.h" |
initial.commit | f5b16fe | 2008-07-27 00:20:51 | [diff] [blame] | 20 | #include "KURL.h" |
| 21 | #include "Widget.h" |
[email protected] | fa41969 | 2008-10-16 21:46:14 | [diff] [blame] | 22 | MSVC_POP_WARNING(); |
initial.commit | f5b16fe | 2008-07-27 00:20:51 | [diff] [blame] | 23 | #undef LOG |
| 24 | |
| 25 | #include "webkit/glue/context_menu_client_impl.h" |
| 26 | |
| 27 | #include "base/string_util.h" |
[email protected] | 726985e2 | 2009-06-18 21:09:28 | [diff] [blame] | 28 | #include "webkit/api/public/WebURL.h" |
| 29 | #include "webkit/api/public/WebURLResponse.h" |
[email protected] | e09ba55 | 2009-02-05 03:26:29 | [diff] [blame] | 30 | #include "webkit/glue/context_menu.h" |
initial.commit | f5b16fe | 2008-07-27 00:20:51 | [diff] [blame] | 31 | #include "webkit/glue/glue_util.h" |
[email protected] | 2903f3b | 2009-03-13 16:30:50 | [diff] [blame] | 32 | #include "webkit/glue/webdatasource_impl.h" |
initial.commit | f5b16fe | 2008-07-27 00:20:51 | [diff] [blame] | 33 | #include "webkit/glue/webview_impl.h" |
| 34 | |
| 35 | #include "base/word_iterator.h" |
| 36 | |
[email protected] | 726985e2 | 2009-06-18 21:09:28 | [diff] [blame] | 37 | using WebKit::WebDataSource; |
| 38 | |
[email protected] | 985f0e6 | 2008-10-29 01:05:08 | [diff] [blame] | 39 | namespace { |
| 40 | |
initial.commit | f5b16fe | 2008-07-27 00:20:51 | [diff] [blame] | 41 | // Helper function to determine whether text is a single word or a sentence. |
[email protected] | 985f0e6 | 2008-10-29 01:05:08 | [diff] [blame] | 42 | bool IsASingleWord(const std::wstring& text) { |
initial.commit | f5b16fe | 2008-07-27 00:20:51 | [diff] [blame] | 43 | WordIterator iter(text, WordIterator::BREAK_WORD); |
| 44 | int word_count = 0; |
| 45 | if (!iter.Init()) return false; |
| 46 | while (iter.Advance()) { |
| 47 | if (iter.IsWord()) { |
| 48 | word_count++; |
| 49 | if (word_count > 1) // More than one word. |
| 50 | return false; |
| 51 | } |
| 52 | } |
[email protected] | f0a51fb5 | 2009-03-05 12:46:38 | [diff] [blame] | 53 | |
initial.commit | f5b16fe | 2008-07-27 00:20:51 | [diff] [blame] | 54 | // Check for 0 words. |
| 55 | if (!word_count) |
| 56 | return false; |
[email protected] | f0a51fb5 | 2009-03-05 12:46:38 | [diff] [blame] | 57 | |
initial.commit | f5b16fe | 2008-07-27 00:20:51 | [diff] [blame] | 58 | // Has a single word. |
| 59 | return true; |
| 60 | } |
| 61 | |
[email protected] | f0a51fb5 | 2009-03-05 12:46:38 | [diff] [blame] | 62 | // Helper function to get misspelled word on which context menu |
initial.commit | f5b16fe | 2008-07-27 00:20:51 | [diff] [blame] | 63 | // is to be evolked. This function also sets the word on which context menu |
[email protected] | 442a3a1 | 2009-04-23 18:14:06 | [diff] [blame] | 64 | // has been evoked to be the selected word, as required. This function changes |
| 65 | // the selection only when there were no selected characters. |
[email protected] | 985f0e6 | 2008-10-29 01:05:08 | [diff] [blame] | 66 | std::wstring GetMisspelledWord(const WebCore::ContextMenu* default_menu, |
| 67 | WebCore::Frame* selected_frame) { |
initial.commit | f5b16fe | 2008-07-27 00:20:51 | [diff] [blame] | 68 | std::wstring misspelled_word_string; |
| 69 | |
| 70 | // First select from selectedText to check for multiple word selection. |
| 71 | misspelled_word_string = CollapseWhitespace( |
| 72 | webkit_glue::StringToStdWString(selected_frame->selectedText()), |
| 73 | false); |
| 74 | |
[email protected] | 442a3a1 | 2009-04-23 18:14:06 | [diff] [blame] | 75 | // If some texts were already selected, we don't change the selection. |
| 76 | if (!misspelled_word_string.empty()) { |
| 77 | // Don't provide suggestions for multiple words. |
| 78 | if (!IsASingleWord(misspelled_word_string)) |
| 79 | return L""; |
| 80 | else |
| 81 | return misspelled_word_string; |
| 82 | } |
initial.commit | f5b16fe | 2008-07-27 00:20:51 | [diff] [blame] | 83 | |
[email protected] | 3a500b35 | 2008-10-31 17:10:21 | [diff] [blame] | 84 | WebCore::HitTestResult hit_test_result = selected_frame->eventHandler()-> |
| 85 | hitTestResultAtPoint(default_menu->hitTestResult().point(), true); |
| 86 | WebCore::Node* inner_node = hit_test_result.innerNode(); |
| 87 | WebCore::VisiblePosition pos(inner_node->renderer()->positionForPoint( |
| 88 | hit_test_result.localPoint())); |
[email protected] | 985f0e6 | 2008-10-29 01:05:08 | [diff] [blame] | 89 | |
[email protected] | 0f0981d | 2009-02-12 23:09:35 | [diff] [blame] | 90 | WebCore::VisibleSelection selection; |
initial.commit | f5b16fe | 2008-07-27 00:20:51 | [diff] [blame] | 91 | if (pos.isNotNull()) { |
[email protected] | 0f0981d | 2009-02-12 23:09:35 | [diff] [blame] | 92 | selection = WebCore::VisibleSelection(pos); |
initial.commit | f5b16fe | 2008-07-27 00:20:51 | [diff] [blame] | 93 | selection.expandUsingGranularity(WebCore::WordGranularity); |
| 94 | } |
[email protected] | f0a51fb5 | 2009-03-05 12:46:38 | [diff] [blame] | 95 | |
| 96 | if (selection.isRange()) { |
initial.commit | f5b16fe | 2008-07-27 00:20:51 | [diff] [blame] | 97 | selected_frame->setSelectionGranularity(WebCore::WordGranularity); |
| 98 | } |
[email protected] | f0a51fb5 | 2009-03-05 12:46:38 | [diff] [blame] | 99 | |
initial.commit | f5b16fe | 2008-07-27 00:20:51 | [diff] [blame] | 100 | if (selected_frame->shouldChangeSelection(selection)) |
[email protected] | de56f378 | 2008-10-01 22:31:35 | [diff] [blame] | 101 | selected_frame->selection()->setSelection(selection); |
[email protected] | f0a51fb5 | 2009-03-05 12:46:38 | [diff] [blame] | 102 | |
initial.commit | f5b16fe | 2008-07-27 00:20:51 | [diff] [blame] | 103 | misspelled_word_string = CollapseWhitespace( |
[email protected] | f0a51fb5 | 2009-03-05 12:46:38 | [diff] [blame] | 104 | webkit_glue::StringToStdWString(selected_frame->selectedText()), |
initial.commit | f5b16fe | 2008-07-27 00:20:51 | [diff] [blame] | 105 | false); |
[email protected] | 6d886b7 | 2009-02-11 23:30:11 | [diff] [blame] | 106 | |
| 107 | // If misspelled word is empty, then that portion should not be selected. |
| 108 | // Set the selection to that position only, and do not expand. |
| 109 | if (misspelled_word_string.empty()) { |
[email protected] | 0f0981d | 2009-02-12 23:09:35 | [diff] [blame] | 110 | selection = WebCore::VisibleSelection(pos); |
[email protected] | 6d886b7 | 2009-02-11 23:30:11 | [diff] [blame] | 111 | selected_frame->selection()->setSelection(selection); |
| 112 | } |
| 113 | |
initial.commit | f5b16fe | 2008-07-27 00:20:51 | [diff] [blame] | 114 | return misspelled_word_string; |
| 115 | } |
| 116 | |
[email protected] | 985f0e6 | 2008-10-29 01:05:08 | [diff] [blame] | 117 | } // namespace |
| 118 | |
initial.commit | f5b16fe | 2008-07-27 00:20:51 | [diff] [blame] | 119 | ContextMenuClientImpl::~ContextMenuClientImpl() { |
| 120 | } |
| 121 | |
| 122 | void ContextMenuClientImpl::contextMenuDestroyed() { |
| 123 | delete this; |
| 124 | } |
| 125 | |
| 126 | // Figure out the URL of a page or subframe. Returns |page_type| as the type, |
[email protected] | 581b87eb | 2009-07-23 23:06:56 | [diff] [blame] | 127 | // which indicates page or subframe, or ContextNodeType::NONE if the URL could not |
initial.commit | f5b16fe | 2008-07-27 00:20:51 | [diff] [blame] | 128 | // be determined for some reason. |
[email protected] | 581b87eb | 2009-07-23 23:06:56 | [diff] [blame] | 129 | static ContextNodeType GetTypeAndURLFromFrame( |
| 130 | WebCore::Frame* frame, |
| 131 | GURL* url, |
| 132 | ContextNodeType page_node_type) { |
| 133 | ContextNodeType node_type; |
initial.commit | f5b16fe | 2008-07-27 00:20:51 | [diff] [blame] | 134 | if (frame) { |
| 135 | WebCore::DocumentLoader* dl = frame->loader()->documentLoader(); |
| 136 | if (dl) { |
[email protected] | 2903f3b | 2009-03-13 16:30:50 | [diff] [blame] | 137 | WebDataSource* ds = WebDataSourceImpl::FromLoader(dl); |
initial.commit | f5b16fe | 2008-07-27 00:20:51 | [diff] [blame] | 138 | if (ds) { |
[email protected] | 581b87eb | 2009-07-23 23:06:56 | [diff] [blame] | 139 | node_type = page_node_type; |
[email protected] | 726985e2 | 2009-06-18 21:09:28 | [diff] [blame] | 140 | *url = ds->hasUnreachableURL() ? ds->unreachableURL() |
| 141 | : ds->request().url(); |
initial.commit | f5b16fe | 2008-07-27 00:20:51 | [diff] [blame] | 142 | } |
| 143 | } |
| 144 | } |
[email protected] | 581b87eb | 2009-07-23 23:06:56 | [diff] [blame] | 145 | return node_type; |
initial.commit | f5b16fe | 2008-07-27 00:20:51 | [diff] [blame] | 146 | } |
| 147 | |
| 148 | WebCore::PlatformMenuDescription |
| 149 | ContextMenuClientImpl::getCustomMenuFromDefaultItems( |
| 150 | WebCore::ContextMenu* default_menu) { |
| 151 | // Displaying the context menu in this function is a big hack as we don't |
[email protected] | f0a51fb5 | 2009-03-05 12:46:38 | [diff] [blame] | 152 | // have context, i.e. whether this is being invoked via a script or in |
initial.commit | f5b16fe | 2008-07-27 00:20:51 | [diff] [blame] | 153 | // response to user input (Mouse event WM_RBUTTONDOWN, |
| 154 | // Keyboard events KeyVK_APPS, Shift+F10). Check if this is being invoked |
| 155 | // in response to the above input events before popping up the context menu. |
| 156 | if (!webview_->context_menu_allowed()) |
| 157 | return NULL; |
| 158 | |
| 159 | WebCore::HitTestResult r = default_menu->hitTestResult(); |
| 160 | WebCore::Frame* selected_frame = r.innerNonSharedNode()->document()->frame(); |
| 161 | |
| 162 | WebCore::IntPoint menu_point = |
| 163 | selected_frame->view()->contentsToWindow(r.point()); |
| 164 | |
[email protected] | 581b87eb | 2009-07-23 23:06:56 | [diff] [blame] | 165 | ContextNodeType node_type; |
initial.commit | f5b16fe | 2008-07-27 00:20:51 | [diff] [blame] | 166 | |
[email protected] | 574a1d6 | 2009-07-17 03:23:46 | [diff] [blame] | 167 | // Links, Images, Media tags, and Image/Media-Links take preference over |
| 168 | // all else. |
initial.commit | f5b16fe | 2008-07-27 00:20:51 | [diff] [blame] | 169 | WebCore::KURL link_url = r.absoluteLinkURL(); |
initial.commit | f5b16fe | 2008-07-27 00:20:51 | [diff] [blame] | 170 | if (!link_url.isEmpty()) { |
[email protected] | 581b87eb | 2009-07-23 23:06:56 | [diff] [blame] | 171 | node_type.type |= ContextNodeType::LINK; |
initial.commit | f5b16fe | 2008-07-27 00:20:51 | [diff] [blame] | 172 | } |
[email protected] | 574a1d6 | 2009-07-17 03:23:46 | [diff] [blame] | 173 | |
| 174 | WebCore::KURL src_url; |
| 175 | |
| 176 | ContextMenuMediaParams media_params; |
| 177 | |
| 178 | if (!r.absoluteImageURL().isEmpty()) { |
| 179 | src_url = r.absoluteImageURL(); |
[email protected] | 581b87eb | 2009-07-23 23:06:56 | [diff] [blame] | 180 | node_type.type |= ContextNodeType::IMAGE; |
[email protected] | 574a1d6 | 2009-07-17 03:23:46 | [diff] [blame] | 181 | } else if (!r.absoluteMediaURL().isEmpty()) { |
| 182 | src_url = r.absoluteMediaURL(); |
[email protected] | e626d7f | 2009-08-12 19:52:44 | [diff] [blame^] | 183 | |
[email protected] | 574a1d6 | 2009-07-17 03:23:46 | [diff] [blame] | 184 | // We know that if absoluteMediaURL() is not empty, then this is a media |
| 185 | // element. |
| 186 | WebCore::HTMLMediaElement* media_element = |
| 187 | static_cast<WebCore::HTMLMediaElement*>(r.innerNonSharedNode()); |
| 188 | if (media_element->hasTagName(WebCore::HTMLNames::videoTag)) { |
[email protected] | 581b87eb | 2009-07-23 23:06:56 | [diff] [blame] | 189 | node_type.type |= ContextNodeType::VIDEO; |
[email protected] | 574a1d6 | 2009-07-17 03:23:46 | [diff] [blame] | 190 | } else if (media_element->hasTagName(WebCore::HTMLNames::audioTag)) { |
[email protected] | 581b87eb | 2009-07-23 23:06:56 | [diff] [blame] | 191 | node_type.type |= ContextNodeType::AUDIO; |
[email protected] | 574a1d6 | 2009-07-17 03:23:46 | [diff] [blame] | 192 | } |
| 193 | |
[email protected] | 574a1d6 | 2009-07-17 03:23:46 | [diff] [blame] | 194 | if (media_element->paused()) { |
[email protected] | 581b87eb | 2009-07-23 23:06:56 | [diff] [blame] | 195 | media_params.player_state |= ContextMenuMediaParams::PAUSED; |
[email protected] | 574a1d6 | 2009-07-17 03:23:46 | [diff] [blame] | 196 | } |
| 197 | if (media_element->muted()) { |
[email protected] | 581b87eb | 2009-07-23 23:06:56 | [diff] [blame] | 198 | media_params.player_state |= ContextMenuMediaParams::MUTED; |
[email protected] | 574a1d6 | 2009-07-17 03:23:46 | [diff] [blame] | 199 | } |
| 200 | if (media_element->loop()) { |
[email protected] | 581b87eb | 2009-07-23 23:06:56 | [diff] [blame] | 201 | media_params.player_state |= ContextMenuMediaParams::LOOP; |
[email protected] | 574a1d6 | 2009-07-17 03:23:46 | [diff] [blame] | 202 | } |
| 203 | if (media_element->supportsSave()) { |
[email protected] | 581b87eb | 2009-07-23 23:06:56 | [diff] [blame] | 204 | media_params.player_state |= ContextMenuMediaParams::CAN_SAVE; |
[email protected] | 574a1d6 | 2009-07-17 03:23:46 | [diff] [blame] | 205 | } |
[email protected] | 581b87eb | 2009-07-23 23:06:56 | [diff] [blame] | 206 | // TODO(ajwong): Report error states in the media player. |
initial.commit | f5b16fe | 2008-07-27 00:20:51 | [diff] [blame] | 207 | } |
initial.commit | f5b16fe | 2008-07-27 00:20:51 | [diff] [blame] | 208 | |
[email protected] | 574a1d6 | 2009-07-17 03:23:46 | [diff] [blame] | 209 | // If it's not a link, an image, a media element, or an image/media link, |
| 210 | // show a selection menu or a more generic page menu. |
initial.commit | f5b16fe | 2008-07-27 00:20:51 | [diff] [blame] | 211 | std::wstring selection_text_string; |
| 212 | std::wstring misspelled_word_string; |
| 213 | GURL frame_url; |
| 214 | GURL page_url; |
[email protected] | 6aa376b | 2008-09-23 18:49:52 | [diff] [blame] | 215 | std::string security_info; |
[email protected] | f0a51fb5 | 2009-03-05 12:46:38 | [diff] [blame] | 216 | |
[email protected] | c9825a4 | 2009-05-01 22:51:50 | [diff] [blame] | 217 | std::string frame_charset = WideToASCII( |
| 218 | webkit_glue::StringToStdWString(selected_frame->loader()->encoding())); |
initial.commit | f5b16fe | 2008-07-27 00:20:51 | [diff] [blame] | 219 | // Send the frame and page URLs in any case. |
[email protected] | 581b87eb | 2009-07-23 23:06:56 | [diff] [blame] | 220 | ContextNodeType frame_node = ContextNodeType(ContextNodeType::NONE); |
| 221 | ContextNodeType page_node = |
initial.commit | f5b16fe | 2008-07-27 00:20:51 | [diff] [blame] | 222 | GetTypeAndURLFromFrame(webview_->main_frame()->frame(), |
| 223 | &page_url, |
[email protected] | 581b87eb | 2009-07-23 23:06:56 | [diff] [blame] | 224 | ContextNodeType(ContextNodeType::PAGE)); |
initial.commit | f5b16fe | 2008-07-27 00:20:51 | [diff] [blame] | 225 | if (selected_frame != webview_->main_frame()->frame()) { |
[email protected] | 581b87eb | 2009-07-23 23:06:56 | [diff] [blame] | 226 | frame_node = |
| 227 | GetTypeAndURLFromFrame(selected_frame, |
| 228 | &frame_url, |
| 229 | ContextNodeType(ContextNodeType::FRAME)); |
initial.commit | f5b16fe | 2008-07-27 00:20:51 | [diff] [blame] | 230 | } |
[email protected] | 12464693 | 2009-01-28 18:39:02 | [diff] [blame] | 231 | |
| 232 | if (r.isSelected()) { |
[email protected] | 581b87eb | 2009-07-23 23:06:56 | [diff] [blame] | 233 | node_type.type |= ContextNodeType::SELECTION; |
[email protected] | 12464693 | 2009-01-28 18:39:02 | [diff] [blame] | 234 | selection_text_string = CollapseWhitespace( |
| 235 | webkit_glue::StringToStdWString(selected_frame->selectedText()), |
| 236 | false); |
| 237 | } |
| 238 | |
| 239 | if (r.isContentEditable()) { |
[email protected] | 581b87eb | 2009-07-23 23:06:56 | [diff] [blame] | 240 | node_type.type |= ContextNodeType::EDITABLE; |
[email protected] | 12464693 | 2009-01-28 18:39:02 | [diff] [blame] | 241 | if (webview_->GetFocusedWebCoreFrame()->editor()-> |
| 242 | isContinuousSpellCheckingEnabled()) { |
| 243 | misspelled_word_string = GetMisspelledWord(default_menu, |
| 244 | selected_frame); |
| 245 | } |
| 246 | } |
[email protected] | f0a51fb5 | 2009-03-05 12:46:38 | [diff] [blame] | 247 | |
[email protected] | 581b87eb | 2009-07-23 23:06:56 | [diff] [blame] | 248 | if (node_type.type == ContextNodeType::NONE) { |
[email protected] | 12464693 | 2009-01-28 18:39:02 | [diff] [blame] | 249 | if (selected_frame != webview_->main_frame()->frame()) { |
[email protected] | 581b87eb | 2009-07-23 23:06:56 | [diff] [blame] | 250 | node_type = frame_node; |
initial.commit | f5b16fe | 2008-07-27 00:20:51 | [diff] [blame] | 251 | } else { |
[email protected] | 581b87eb | 2009-07-23 23:06:56 | [diff] [blame] | 252 | node_type = page_node; |
initial.commit | f5b16fe | 2008-07-27 00:20:51 | [diff] [blame] | 253 | } |
| 254 | } |
| 255 | |
[email protected] | 6aa376b | 2008-09-23 18:49:52 | [diff] [blame] | 256 | // Now retrieve the security info. |
| 257 | WebCore::DocumentLoader* dl = selected_frame->loader()->documentLoader(); |
[email protected] | 2903f3b | 2009-03-13 16:30:50 | [diff] [blame] | 258 | WebDataSource* ds = WebDataSourceImpl::FromLoader(dl); |
[email protected] | 726985e2 | 2009-06-18 21:09:28 | [diff] [blame] | 259 | if (ds) |
| 260 | security_info = ds->response().securityInfo(); |
[email protected] | 6aa376b | 2008-09-23 18:49:52 | [diff] [blame] | 261 | |
[email protected] | 581b87eb | 2009-07-23 23:06:56 | [diff] [blame] | 262 | int edit_flags = ContextNodeType::CAN_DO_NONE; |
initial.commit | f5b16fe | 2008-07-27 00:20:51 | [diff] [blame] | 263 | if (webview_->GetFocusedWebCoreFrame()->editor()->canUndo()) |
[email protected] | 581b87eb | 2009-07-23 23:06:56 | [diff] [blame] | 264 | edit_flags |= ContextNodeType::CAN_UNDO; |
initial.commit | f5b16fe | 2008-07-27 00:20:51 | [diff] [blame] | 265 | if (webview_->GetFocusedWebCoreFrame()->editor()->canRedo()) |
[email protected] | 581b87eb | 2009-07-23 23:06:56 | [diff] [blame] | 266 | edit_flags |= ContextNodeType::CAN_REDO; |
initial.commit | f5b16fe | 2008-07-27 00:20:51 | [diff] [blame] | 267 | if (webview_->GetFocusedWebCoreFrame()->editor()->canCut()) |
[email protected] | 581b87eb | 2009-07-23 23:06:56 | [diff] [blame] | 268 | edit_flags |= ContextNodeType::CAN_CUT; |
initial.commit | f5b16fe | 2008-07-27 00:20:51 | [diff] [blame] | 269 | if (webview_->GetFocusedWebCoreFrame()->editor()->canCopy()) |
[email protected] | 581b87eb | 2009-07-23 23:06:56 | [diff] [blame] | 270 | edit_flags |= ContextNodeType::CAN_COPY; |
initial.commit | f5b16fe | 2008-07-27 00:20:51 | [diff] [blame] | 271 | if (webview_->GetFocusedWebCoreFrame()->editor()->canPaste()) |
[email protected] | 581b87eb | 2009-07-23 23:06:56 | [diff] [blame] | 272 | edit_flags |= ContextNodeType::CAN_PASTE; |
initial.commit | f5b16fe | 2008-07-27 00:20:51 | [diff] [blame] | 273 | if (webview_->GetFocusedWebCoreFrame()->editor()->canDelete()) |
[email protected] | 581b87eb | 2009-07-23 23:06:56 | [diff] [blame] | 274 | edit_flags |= ContextNodeType::CAN_DELETE; |
initial.commit | f5b16fe | 2008-07-27 00:20:51 | [diff] [blame] | 275 | // We can always select all... |
[email protected] | 581b87eb | 2009-07-23 23:06:56 | [diff] [blame] | 276 | edit_flags |= ContextNodeType::CAN_SELECT_ALL; |
initial.commit | f5b16fe | 2008-07-27 00:20:51 | [diff] [blame] | 277 | |
| 278 | WebViewDelegate* d = webview_->delegate(); |
| 279 | if (d) { |
| 280 | d->ShowContextMenu(webview_, |
[email protected] | 581b87eb | 2009-07-23 23:06:56 | [diff] [blame] | 281 | node_type, |
initial.commit | f5b16fe | 2008-07-27 00:20:51 | [diff] [blame] | 282 | menu_point.x(), |
| 283 | menu_point.y(), |
| 284 | webkit_glue::KURLToGURL(link_url), |
[email protected] | 574a1d6 | 2009-07-17 03:23:46 | [diff] [blame] | 285 | webkit_glue::KURLToGURL(src_url), |
initial.commit | f5b16fe | 2008-07-27 00:20:51 | [diff] [blame] | 286 | page_url, |
| 287 | frame_url, |
[email protected] | 574a1d6 | 2009-07-17 03:23:46 | [diff] [blame] | 288 | media_params, |
initial.commit | f5b16fe | 2008-07-27 00:20:51 | [diff] [blame] | 289 | selection_text_string, |
| 290 | misspelled_word_string, |
[email protected] | 6aa376b | 2008-09-23 18:49:52 | [diff] [blame] | 291 | edit_flags, |
[email protected] | c9825a4 | 2009-05-01 22:51:50 | [diff] [blame] | 292 | security_info, |
| 293 | frame_charset); |
initial.commit | f5b16fe | 2008-07-27 00:20:51 | [diff] [blame] | 294 | } |
| 295 | return NULL; |
| 296 | } |
| 297 | |
| 298 | void ContextMenuClientImpl::contextMenuItemSelected( |
| 299 | WebCore::ContextMenuItem*, const WebCore::ContextMenu*) { |
| 300 | } |
| 301 | |
| 302 | void ContextMenuClientImpl::downloadURL(const WebCore::KURL&) { |
| 303 | } |
| 304 | |
| 305 | void ContextMenuClientImpl::copyImageToClipboard(const WebCore::HitTestResult&) { |
| 306 | } |
| 307 | |
| 308 | void ContextMenuClientImpl::searchWithGoogle(const WebCore::Frame*) { |
| 309 | } |
| 310 | |
| 311 | void ContextMenuClientImpl::lookUpInDictionary(WebCore::Frame*) { |
| 312 | } |
| 313 | |
| 314 | void ContextMenuClientImpl::speak(const WebCore::String&) { |
| 315 | } |
| 316 | |
[email protected] | f3d3105 | 2009-06-29 20:49:29 | [diff] [blame] | 317 | bool ContextMenuClientImpl::isSpeaking() { |
| 318 | return false; |
| 319 | } |
| 320 | |
initial.commit | f5b16fe | 2008-07-27 00:20:51 | [diff] [blame] | 321 | void ContextMenuClientImpl::stopSpeaking() { |
| 322 | } |
| 323 | |
| 324 | bool ContextMenuClientImpl::shouldIncludeInspectElementItem() { |
| 325 | return false; // TODO(jackson): Eventually include the inspector context menu item |
| 326 | } |
license.bot | bf09a50 | 2008-08-24 00:55:55 | [diff] [blame] | 327 | |
[email protected] | 7284c650 | 2008-09-09 20:27:26 | [diff] [blame] | 328 | #if defined(OS_MACOSX) |
| 329 | void ContextMenuClientImpl::searchWithSpotlight() { |
| 330 | // TODO(pinkerton): write this |
| 331 | } |
| 332 | #endif |