| OLD | NEW |
| 1 /* | 1 /* |
| 2 * Copyright (C) 2009, 2012 Google Inc. All rights reserved. | 2 * Copyright (C) 2009, 2012 Google Inc. All rights reserved. |
| 3 * | 3 * |
| 4 * Redistribution and use in source and binary forms, with or without | 4 * Redistribution and use in source and binary forms, with or without |
| 5 * modification, are permitted provided that the following conditions are | 5 * modification, are permitted provided that the following conditions are |
| 6 * met: | 6 * met: |
| 7 * | 7 * |
| 8 * * Redistributions of source code must retain the above copyright | 8 * * Redistributions of source code must retain the above copyright |
| 9 * notice, this list of conditions and the following disclaimer. | 9 * notice, this list of conditions and the following disclaimer. |
| 10 * * Redistributions in binary form must reproduce the above | 10 * * Redistributions in binary form must reproduce the above |
| (...skipping 30 matching lines...) Expand all Loading... |
| 41 #include "core/editing/spellcheck/SpellChecker.h" | 41 #include "core/editing/spellcheck/SpellChecker.h" |
| 42 #include "core/frame/FrameView.h" | 42 #include "core/frame/FrameView.h" |
| 43 #include "core/frame/Settings.h" | 43 #include "core/frame/Settings.h" |
| 44 #include "core/frame/VisualViewport.h" | 44 #include "core/frame/VisualViewport.h" |
| 45 #include "core/html/HTMLAnchorElement.h" | 45 #include "core/html/HTMLAnchorElement.h" |
| 46 #include "core/html/HTMLFormElement.h" | 46 #include "core/html/HTMLFormElement.h" |
| 47 #include "core/html/HTMLImageElement.h" | 47 #include "core/html/HTMLImageElement.h" |
| 48 #include "core/html/HTMLInputElement.h" | 48 #include "core/html/HTMLInputElement.h" |
| 49 #include "core/html/HTMLMediaElement.h" | 49 #include "core/html/HTMLMediaElement.h" |
| 50 #include "core/html/HTMLPlugInElement.h" | 50 #include "core/html/HTMLPlugInElement.h" |
| 51 #include "core/input/ContextMenuAllowedScope.h" |
| 51 #include "core/input/EventHandler.h" | 52 #include "core/input/EventHandler.h" |
| 52 #include "core/layout/HitTestResult.h" | 53 #include "core/layout/HitTestResult.h" |
| 53 #include "core/layout/LayoutPart.h" | 54 #include "core/layout/LayoutPart.h" |
| 54 #include "core/loader/DocumentLoader.h" | 55 #include "core/loader/DocumentLoader.h" |
| 55 #include "core/loader/FrameLoader.h" | 56 #include "core/loader/FrameLoader.h" |
| 56 #include "core/loader/HistoryItem.h" | 57 #include "core/loader/HistoryItem.h" |
| 57 #include "core/page/ContextMenuController.h" | 58 #include "core/page/ContextMenuController.h" |
| 58 #include "core/page/Page.h" | 59 #include "core/page/Page.h" |
| 59 #include "platform/ContextMenu.h" | 60 #include "platform/ContextMenu.h" |
| 60 #include "platform/FrameViewBase.h" | 61 #include "platform/FrameViewBase.h" |
| 61 #include "platform/exported/WrappedResourceResponse.h" | 62 #include "platform/exported/WrappedResourceResponse.h" |
| 62 #include "platform/text/TextBreakIterator.h" | 63 #include "platform/text/TextBreakIterator.h" |
| 63 #include "platform/weborigin/KURL.h" | 64 #include "platform/weborigin/KURL.h" |
| 64 #include "platform/wtf/text/WTFString.h" | 65 #include "platform/wtf/text/WTFString.h" |
| 65 #include "public/platform/WebPoint.h" | 66 #include "public/platform/WebPoint.h" |
| 66 #include "public/platform/WebString.h" | 67 #include "public/platform/WebString.h" |
| 67 #include "public/platform/WebURL.h" | 68 #include "public/platform/WebURL.h" |
| 68 #include "public/platform/WebURLResponse.h" | 69 #include "public/platform/WebURLResponse.h" |
| 69 #include "public/platform/WebVector.h" | 70 #include "public/platform/WebVector.h" |
| 70 #include "public/web/WebContextMenuData.h" | 71 #include "public/web/WebContextMenuData.h" |
| 71 #include "public/web/WebFormElement.h" | 72 #include "public/web/WebFormElement.h" |
| 72 #include "public/web/WebFrameClient.h" | 73 #include "public/web/WebFrameClient.h" |
| 73 #include "public/web/WebMenuItemInfo.h" | 74 #include "public/web/WebMenuItemInfo.h" |
| 74 #include "public/web/WebPlugin.h" | 75 #include "public/web/WebPlugin.h" |
| 75 #include "public/web/WebSearchableFormData.h" | 76 #include "public/web/WebSearchableFormData.h" |
| 76 #include "public/web/WebTextCheckClient.h" | 77 #include "public/web/WebTextCheckClient.h" |
| 77 #include "public/web/WebViewClient.h" | 78 #include "public/web/WebViewClient.h" |
| 78 #include "web/ContextMenuAllowedScope.h" | |
| 79 #include "web/WebDataSourceImpl.h" | 79 #include "web/WebDataSourceImpl.h" |
| 80 #include "web/WebLocalFrameImpl.h" | 80 #include "web/WebLocalFrameImpl.h" |
| 81 #include "web/WebPluginContainerImpl.h" | 81 #include "web/WebPluginContainerImpl.h" |
| 82 #include "web/WebViewImpl.h" | 82 #include "web/WebViewImpl.h" |
| 83 | 83 |
| 84 namespace blink { | 84 namespace blink { |
| 85 | 85 |
| 86 // Figure out the URL of a page or subframe. Returns |page_type| as the type, | 86 // Figure out the URL of a page or subframe. Returns |page_type| as the type, |
| 87 // which indicates page or subframe, or ContextNodeType::kNone if the URL could | 87 // which indicates page or subframe, or ContextNodeType::kNone if the URL could |
| 88 // not be determined for some reason. | 88 // not be determined for some reason. |
| (...skipping 72 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 161 } | 161 } |
| 162 | 162 |
| 163 bool ContextMenuClientImpl::ShouldShowContextMenuFromTouch( | 163 bool ContextMenuClientImpl::ShouldShowContextMenuFromTouch( |
| 164 const WebContextMenuData& data) { | 164 const WebContextMenuData& data) { |
| 165 return web_view_->GetPage() | 165 return web_view_->GetPage() |
| 166 ->GetSettings() | 166 ->GetSettings() |
| 167 .GetAlwaysShowContextMenuOnTouch() || | 167 .GetAlwaysShowContextMenuOnTouch() || |
| 168 !data.link_url.IsEmpty() || | 168 !data.link_url.IsEmpty() || |
| 169 data.media_type == WebContextMenuData::kMediaTypeImage || | 169 data.media_type == WebContextMenuData::kMediaTypeImage || |
| 170 data.media_type == WebContextMenuData::kMediaTypeVideo || | 170 data.media_type == WebContextMenuData::kMediaTypeVideo || |
| 171 data.is_editable; | 171 data.is_editable || !data.selected_text.IsEmpty(); |
| 172 } | 172 } |
| 173 | 173 |
| 174 bool ContextMenuClientImpl::ShowContextMenu(const ContextMenu* default_menu, | 174 bool ContextMenuClientImpl::ShowContextMenu(const ContextMenu* default_menu, |
| 175 bool from_touch) { | 175 bool from_touch) { |
| 176 // Displaying the context menu in this function is a big hack as we don't | 176 // Displaying the context menu in this function is a big hack as we don't |
| 177 // have context, i.e. whether this is being invoked via a script or in | 177 // have context, i.e. whether this is being invoked via a script or in |
| 178 // response to user input (Mouse event WM_RBUTTONDOWN, | 178 // response to user input (Mouse event WM_RBUTTONDOWN, |
| 179 // Keyboard events KeyVK_APPS, Shift+F10). Check if this is being invoked | 179 // Keyboard events KeyVK_APPS, Shift+F10). Check if this is being invoked |
| 180 // in response to the above input events before popping up the context menu. | 180 // in response to the above input events before popping up the context menu. |
| 181 if (!ContextMenuAllowedScope::IsContextMenuAllowed()) | 181 if (!ContextMenuAllowedScope::IsContextMenuAllowed()) |
| (...skipping 211 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 393 if (element->type() == InputTypeNames::password) | 393 if (element->type() == InputTypeNames::password) |
| 394 data.input_field_type = WebContextMenuData::kInputFieldTypePassword; | 394 data.input_field_type = WebContextMenuData::kInputFieldTypePassword; |
| 395 else if (element->IsTextField()) | 395 else if (element->IsTextField()) |
| 396 data.input_field_type = WebContextMenuData::kInputFieldTypePlainText; | 396 data.input_field_type = WebContextMenuData::kInputFieldTypePlainText; |
| 397 else | 397 else |
| 398 data.input_field_type = WebContextMenuData::kInputFieldTypeOther; | 398 data.input_field_type = WebContextMenuData::kInputFieldTypeOther; |
| 399 } else { | 399 } else { |
| 400 data.input_field_type = WebContextMenuData::kInputFieldTypeNone; | 400 data.input_field_type = WebContextMenuData::kInputFieldTypeNone; |
| 401 } | 401 } |
| 402 | 402 |
| 403 WebRect focus_webrect; |
| 404 WebRect anchor_webrect; |
| 405 web_view_->SelectionBounds(focus_webrect, anchor_webrect); |
| 406 data.selection_rect = WebRect(focus_webrect.x, focus_webrect.y, |
| 407 anchor_webrect.x + anchor_webrect.width, |
| 408 anchor_webrect.y + anchor_webrect.height); |
| 409 data.from_touch = from_touch; |
| 403 if (from_touch && !ShouldShowContextMenuFromTouch(data)) | 410 if (from_touch && !ShouldShowContextMenuFromTouch(data)) |
| 404 return false; | 411 return false; |
| 405 | 412 |
| 406 selected_web_frame->SetContextMenuNode(r.InnerNodeOrImageMapImage()); | 413 selected_web_frame->SetContextMenuNode(r.InnerNodeOrImageMapImage()); |
| 407 if (!selected_web_frame->Client()) | 414 if (!selected_web_frame->Client()) |
| 408 return false; | 415 return false; |
| 409 | 416 |
| 410 selected_web_frame->Client()->ShowContextMenu(data); | 417 selected_web_frame->Client()->ShowContextMenu(data); |
| 411 return true; | 418 return true; |
| 412 } | 419 } |
| (...skipping 51 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 464 sub_menu_items.Swap(output_items); | 471 sub_menu_items.Swap(output_items); |
| 465 } | 472 } |
| 466 | 473 |
| 467 void ContextMenuClientImpl::PopulateCustomMenuItems( | 474 void ContextMenuClientImpl::PopulateCustomMenuItems( |
| 468 const ContextMenu* default_menu, | 475 const ContextMenu* default_menu, |
| 469 WebContextMenuData* data) { | 476 WebContextMenuData* data) { |
| 470 PopulateSubMenuItems(default_menu->Items(), data->custom_items); | 477 PopulateSubMenuItems(default_menu->Items(), data->custom_items); |
| 471 } | 478 } |
| 472 | 479 |
| 473 } // namespace blink | 480 } // namespace blink |
| OLD | NEW |