diff options
author | yaar@chromium.org <yaar@chromium.org@0039d316-1c4b-4281-b951-d872f2087c98> | 2009-10-09 18:17:44 +0000 |
---|---|---|
committer | yaar@chromium.org <yaar@chromium.org@0039d316-1c4b-4281-b951-d872f2087c98> | 2009-10-09 18:17:44 +0000 |
commit | 79e3744bbbb0867f4e356eab96703d425b3fad40 (patch) | |
tree | 790f3464f1636e542b15b2a5de852cbb6c5f9c41 | |
parent | 9068747c5591866480bd0888e571cc548d6be546 (diff) | |
download | chromium_src-79e3744bbbb0867f4e356eab96703d425b3fad40.zip chromium_src-79e3744bbbb0867f4e356eab96703d425b3fad40.tar.gz chromium_src-79e3744bbbb0867f4e356eab96703d425b3fad40.tar.bz2 |
Moving ShowContextMenu out of WebView_delegate and into WebViewClient
(Part of the Webkit API refactoring effort).
Review URL: http://codereview.chromium.org/265011
git-svn-id: svn://svn.chromium.org/chrome/trunk/src@28567 0039d316-1c4b-4281-b951-d872f2087c98
-rw-r--r-- | chrome/browser/tab_contents/render_view_context_menu.cc | 114 | ||||
-rw-r--r-- | chrome/browser/tab_contents/render_view_context_menu.h | 8 | ||||
-rw-r--r-- | chrome/common/render_messages.h | 65 | ||||
-rw-r--r-- | chrome/common/webkit_param_traits.h | 15 | ||||
-rw-r--r-- | chrome/renderer/print_web_view_helper.h | 14 | ||||
-rw-r--r-- | chrome/renderer/render_view.cc | 41 | ||||
-rw-r--r-- | chrome/renderer/render_view.h | 17 | ||||
-rw-r--r-- | webkit/api/public/WebContextMenuData.h | 118 | ||||
-rw-r--r-- | webkit/api/public/WebViewClient.h | 6 | ||||
-rw-r--r-- | webkit/glue/context_menu.h | 109 | ||||
-rw-r--r-- | webkit/glue/context_menu_client_impl.cc | 153 | ||||
-rw-r--r-- | webkit/glue/webview_delegate.h | 43 | ||||
-rw-r--r-- | webkit/tools/test_shell/test_webview_delegate.cc | 30 | ||||
-rw-r--r-- | webkit/tools/test_shell/test_webview_delegate.h | 24 | ||||
-rw-r--r-- | webkit/webkit.gyp | 1 |
15 files changed, 334 insertions, 424 deletions
diff --git a/chrome/browser/tab_contents/render_view_context_menu.cc b/chrome/browser/tab_contents/render_view_context_menu.cc index 7c51158..be80fda 100644 --- a/chrome/browser/tab_contents/render_view_context_menu.cc +++ b/chrome/browser/tab_contents/render_view_context_menu.cc @@ -30,7 +30,9 @@ #include "grit/generated_resources.h" #include "net/base/escape.h" #include "webkit/api/public/WebMediaPlayerAction.h" +#include "webkit/api/public/WebContextMenuData.h" +using WebKit::WebContextMenuData; using WebKit::WebMediaPlayerAction; namespace { @@ -66,44 +68,55 @@ RenderViewContextMenu::~RenderViewContextMenu() { // Menu construction functions ------------------------------------------------- void RenderViewContextMenu::Init() { - InitMenu(params_.node_type, params_.media_params); + InitMenu(); DoInit(); } -void RenderViewContextMenu::InitMenu(ContextNodeType node_type, - ContextMenuMediaParams media_params) { - if (node_type.type & ContextNodeType::PAGE) - AppendPageItems(); - if (node_type.type & ContextNodeType::FRAME) - AppendFrameItems(); - if (node_type.type & ContextNodeType::LINK) - AppendLinkItems(); - - if (node_type.type & ContextNodeType::IMAGE) { - if (node_type.type & ContextNodeType::LINK) - AppendSeparator(); - AppendImageItems(); +void RenderViewContextMenu::InitMenu() { + + bool has_link = !params_.link_url.is_empty(); + bool has_selection = !params_.selection_text.empty(); + + // When no special node or text is selected and selection has no link, + // show page items. + if (params_.media_type == WebContextMenuData::MediaTypeNone && + !has_link && + !params_.is_editable && + !has_selection) { + // If context is in subframe, show subframe options instead. + if (!params_.frame_url.is_empty()) { + AppendFrameItems(); + } else if (!params_.page_url.is_empty()) { + AppendPageItems(); + } } - if (node_type.type & ContextNodeType::VIDEO) { - if (node_type.type & ContextNodeType::LINK) + if (has_link) { + AppendLinkItems(); + if (params_.media_type != WebContextMenuData::MediaTypeNone) AppendSeparator(); - AppendVideoItems(media_params); } - if (node_type.type & ContextNodeType::AUDIO) { - if (node_type.type & ContextNodeType::LINK) - AppendSeparator(); - AppendAudioItems(media_params); + switch (params_.media_type) { + case WebContextMenuData::MediaTypeNone: + break; + case WebContextMenuData::MediaTypeImage: + AppendImageItems(); + break; + case WebContextMenuData::MediaTypeVideo: + AppendVideoItems(); + break; + case WebContextMenuData::MediaTypeAudio: + AppendAudioItems(); + break; } - if (node_type.type & ContextNodeType::EDITABLE) + if (params_.is_editable) AppendEditableItems(); - else if (node_type.type & ContextNodeType::SELECTION || - node_type.type & ContextNodeType::LINK) + else if (has_selection || has_link) AppendCopyItem(); - if (node_type.type & ContextNodeType::SELECTION) + if (has_selection) AppendSearchProvider(); AppendDeveloperItems(); @@ -138,33 +151,31 @@ void RenderViewContextMenu::AppendImageItems() { AppendMenuItem(IDS_CONTENT_CONTEXT_OPENIMAGENEWTAB); } -void RenderViewContextMenu::AppendAudioItems( - ContextMenuMediaParams media_params) { - AppendMediaItems(media_params); +void RenderViewContextMenu::AppendAudioItems() { + AppendMediaItems(); AppendSeparator(); AppendMenuItem(IDS_CONTENT_CONTEXT_SAVEAUDIOAS); AppendMenuItem(IDS_CONTENT_CONTEXT_COPYAUDIOLOCATION); AppendMenuItem(IDS_CONTENT_CONTEXT_OPENAUDIONEWTAB); } -void RenderViewContextMenu::AppendVideoItems( - ContextMenuMediaParams media_params) { - AppendMediaItems(media_params); +void RenderViewContextMenu::AppendVideoItems() { + AppendMediaItems(); AppendSeparator(); AppendMenuItem(IDS_CONTENT_CONTEXT_SAVEVIDEOAS); AppendMenuItem(IDS_CONTENT_CONTEXT_COPYVIDEOLOCATION); AppendMenuItem(IDS_CONTENT_CONTEXT_OPENVIDEONEWTAB); } -void RenderViewContextMenu::AppendMediaItems( - ContextMenuMediaParams media_params) { - if (media_params.player_state & ContextMenuMediaParams::PAUSED) { +void RenderViewContextMenu::AppendMediaItems() { + int media_flags = params_.media_flags; + if (media_flags & WebContextMenuData::MediaPaused) { AppendMenuItem(IDS_CONTENT_CONTEXT_PLAY); } else { AppendMenuItem(IDS_CONTENT_CONTEXT_PAUSE); } - if (media_params.player_state & ContextMenuMediaParams::MUTED) { + if (media_flags & WebContextMenuData::MediaMuted) { AppendMenuItem(IDS_CONTENT_CONTEXT_UNMUTE); } else { AppendMenuItem(IDS_CONTENT_CONTEXT_MUTE); @@ -352,15 +363,16 @@ bool RenderViewContextMenu::IsItemCommandEnabled(int id) const { case IDS_CONTENT_CONTEXT_PLAY: case IDS_CONTENT_CONTEXT_PAUSE: case IDS_CONTENT_CONTEXT_LOOP: - return (params_.media_params.player_state & - ContextMenuMediaParams::IN_ERROR) == 0; + return (params_.media_flags & + WebContextMenuData::MediaInError) == 0; // Mute and unmute should also be disabled if the player has no audio. case IDS_CONTENT_CONTEXT_MUTE: case IDS_CONTENT_CONTEXT_UNMUTE: - return params_.media_params.has_audio && - (params_.media_params.player_state & - ContextMenuMediaParams::IN_ERROR) == 0; + return (params_.media_flags & + WebContextMenuData::MediaHasAudio) != 0 && + (params_.media_flags & + WebContextMenuData::MediaInError) == 0; case IDS_CONTENT_CONTEXT_SAVESCREENSHOTAS: // TODO(ajwong): Enable save screenshot after we actually implement @@ -374,8 +386,8 @@ bool RenderViewContextMenu::IsItemCommandEnabled(int id) const { case IDS_CONTENT_CONTEXT_SAVEAUDIOAS: case IDS_CONTENT_CONTEXT_SAVEVIDEOAS: - return (params_.media_params.player_state & - ContextMenuMediaParams::CAN_SAVE) && + return (params_.media_flags & + WebContextMenuData::MediaCanSave) && params_.src_url.is_valid() && URLRequest::IsHandledURL(params_.src_url); @@ -400,25 +412,25 @@ bool RenderViewContextMenu::IsItemCommandEnabled(int id) const { return params_.frame_url.is_valid(); case IDS_CONTENT_CONTEXT_UNDO: - return !!(params_.edit_flags & ContextNodeType::CAN_UNDO); + return !!(params_.edit_flags & WebContextMenuData::CanUndo); case IDS_CONTENT_CONTEXT_REDO: - return !!(params_.edit_flags & ContextNodeType::CAN_REDO); + return !!(params_.edit_flags & WebContextMenuData::CanRedo); case IDS_CONTENT_CONTEXT_CUT: - return !!(params_.edit_flags & ContextNodeType::CAN_CUT); + return !!(params_.edit_flags & WebContextMenuData::CanCut); case IDS_CONTENT_CONTEXT_COPY: - return !!(params_.edit_flags & ContextNodeType::CAN_COPY); + return !!(params_.edit_flags & WebContextMenuData::CanCopy); case IDS_CONTENT_CONTEXT_PASTE: - return !!(params_.edit_flags & ContextNodeType::CAN_PASTE); + return !!(params_.edit_flags & WebContextMenuData::CanPaste); case IDS_CONTENT_CONTEXT_DELETE: - return !!(params_.edit_flags & ContextNodeType::CAN_DELETE); + return !!(params_.edit_flags & WebContextMenuData::CanDelete); case IDS_CONTENT_CONTEXT_SELECTALL: - return !!(params_.edit_flags & ContextNodeType::CAN_SELECT_ALL); + return !!(params_.edit_flags & WebContextMenuData::CanSelectAll); case IDS_CONTENT_CONTEXT_OPENLINKOFFTHERECORD: return !profile_->IsOffTheRecord() && params_.link_url.is_valid(); @@ -457,8 +469,8 @@ bool RenderViewContextMenu::IsItemCommandEnabled(int id) const { bool RenderViewContextMenu::ItemIsChecked(int id) const { // See if the video is set to looping. if (id == IDS_CONTENT_CONTEXT_LOOP) { - return (params_.media_params.player_state & - ContextMenuMediaParams::LOOP) != 0; + return (params_.media_flags & + WebContextMenuData::MediaLoop) != 0; } // Check box for 'Check the Spelling of this field'. diff --git a/chrome/browser/tab_contents/render_view_context_menu.h b/chrome/browser/tab_contents/render_view_context_menu.h index bd14f8c..7a4bbc8 100644 --- a/chrome/browser/tab_contents/render_view_context_menu.h +++ b/chrome/browser/tab_contents/render_view_context_menu.h @@ -33,7 +33,7 @@ class RenderViewContextMenu { void Init(); protected: - void InitMenu(ContextNodeType node, ContextMenuMediaParams media_params); + void InitMenu(); // Functions to be implemented by platform-specific subclasses --------------- @@ -80,9 +80,9 @@ class RenderViewContextMenu { void AppendDeveloperItems(); void AppendLinkItems(); void AppendImageItems(); - void AppendAudioItems(ContextMenuMediaParams media_params); - void AppendVideoItems(ContextMenuMediaParams media_params); - void AppendMediaItems(ContextMenuMediaParams media_params); + void AppendAudioItems(); + void AppendVideoItems(); + void AppendMediaItems(); void AppendPageItems(); void AppendFrameItems(); void AppendCopyItem(); diff --git a/chrome/common/render_messages.h b/chrome/common/render_messages.h index 5a6b335..59dc1ac 100644 --- a/chrome/common/render_messages.h +++ b/chrome/common/render_messages.h @@ -557,47 +557,6 @@ struct ParamTraits<FilterPolicy::Type> { }; template <> -struct ParamTraits<ContextNodeType> { - typedef ContextNodeType param_type; - static void Write(Message* m, const param_type& p) { - m->WriteInt(p.type); - } - static bool Read(const Message* m, void** iter, param_type* p) { - int type; - if (!m->ReadInt(iter, &type)) - return false; - *p = ContextNodeType(type); - return true; - } - static void Log(const param_type& p, std::wstring* l) { - std::wstring event = L""; - - if (!p.type) { - event.append(L"NONE"); - } else { - event.append(L"("); - if (p.type & ContextNodeType::PAGE) - event.append(L"PAGE|"); - if (p.type & ContextNodeType::FRAME) - event.append(L"FRAME|"); - if (p.type & ContextNodeType::LINK) - event.append(L"LINK|"); - if (p.type & ContextNodeType::IMAGE) - event.append(L"IMAGE|"); - if (p.type & ContextNodeType::SELECTION) - event.append(L"SELECTION|"); - if (p.type & ContextNodeType::EDITABLE) - event.append(L"EDITABLE|"); - if (p.type & ContextNodeType::MISSPELLED_WORD) - event.append(L"MISSPELLED_WORD|"); - event.append(L")"); - } - - LogParam(event, l); - } -}; - -template <> struct ParamTraits<webkit_glue::WebAccessibility::InParams> { typedef webkit_glue::WebAccessibility::InParams param_type; static void Write(Message* m, const param_type& p) { @@ -894,24 +853,10 @@ struct ParamTraits<ViewHostMsg_FrameNavigate_Params> { }; template <> -struct ParamTraits<ContextMenuMediaParams> { - typedef ContextMenuMediaParams param_type; - static void Write(Message* m, const param_type& p) { - WriteParam(m, p.player_state); - WriteParam(m, p.has_audio); - } - static bool Read(const Message* m, void** iter, param_type* p) { - return - ReadParam(m, iter, &p->player_state) && - ReadParam(m, iter, &p->has_audio); - } -}; - -template <> struct ParamTraits<ContextMenuParams> { typedef ContextMenuParams param_type; static void Write(Message* m, const param_type& p) { - WriteParam(m, p.node_type); + WriteParam(m, p.media_type); WriteParam(m, p.x); WriteParam(m, p.y); WriteParam(m, p.link_url); @@ -919,18 +864,19 @@ struct ParamTraits<ContextMenuParams> { WriteParam(m, p.src_url); WriteParam(m, p.page_url); WriteParam(m, p.frame_url); - WriteParam(m, p.media_params); + WriteParam(m, p.media_flags); WriteParam(m, p.selection_text); WriteParam(m, p.misspelled_word); WriteParam(m, p.dictionary_suggestions); WriteParam(m, p.spellcheck_enabled); + WriteParam(m, p.is_editable); WriteParam(m, p.edit_flags); WriteParam(m, p.security_info); WriteParam(m, p.frame_charset); } static bool Read(const Message* m, void** iter, param_type* p) { return - ReadParam(m, iter, &p->node_type) && + ReadParam(m, iter, &p->media_type) && ReadParam(m, iter, &p->x) && ReadParam(m, iter, &p->y) && ReadParam(m, iter, &p->link_url) && @@ -938,11 +884,12 @@ struct ParamTraits<ContextMenuParams> { ReadParam(m, iter, &p->src_url) && ReadParam(m, iter, &p->page_url) && ReadParam(m, iter, &p->frame_url) && - ReadParam(m, iter, &p->media_params) && + ReadParam(m, iter, &p->media_flags) && ReadParam(m, iter, &p->selection_text) && ReadParam(m, iter, &p->misspelled_word) && ReadParam(m, iter, &p->dictionary_suggestions) && ReadParam(m, iter, &p->spellcheck_enabled) && + ReadParam(m, iter, &p->is_editable) && ReadParam(m, iter, &p->edit_flags) && ReadParam(m, iter, &p->security_info) && ReadParam(m, iter, &p->frame_charset); diff --git a/chrome/common/webkit_param_traits.h b/chrome/common/webkit_param_traits.h index 8a32741..dacaf08 100644 --- a/chrome/common/webkit_param_traits.h +++ b/chrome/common/webkit_param_traits.h @@ -27,6 +27,7 @@ #include "webkit/api/public/WebCache.h" #include "webkit/api/public/WebCompositionCommand.h" #include "webkit/api/public/WebConsoleMessage.h" +#include "webkit/api/public/WebContextMenuData.h" #include "webkit/api/public/WebDragOperation.h" #include "webkit/api/public/WebFindOptions.h" #include "webkit/api/public/WebInputEvent.h" @@ -357,6 +358,20 @@ struct ParamTraits<WebKit::WebMediaPlayerAction> { } }; +template <> + struct ParamTraits<WebKit::WebContextMenuData::MediaType> { + typedef WebKit::WebContextMenuData::MediaType param_type; + static void Write(Message* m, const param_type& p) { + m->WriteInt(p); + } + static bool Read(const Message* m, void** iter, param_type* r) { + int temp; + bool res = m->ReadInt(iter, &temp); + *r = static_cast<param_type>(temp); + return res; + } +}; + } // namespace IPC #endif // CHROME_COMMON_WEBKIT_PARAM_TRAITS_H_ diff --git a/chrome/renderer/print_web_view_helper.h b/chrome/renderer/print_web_view_helper.h index 5c14475..893552d 100644 --- a/chrome/renderer/print_web_view_helper.h +++ b/chrome/renderer/print_web_view_helper.h @@ -169,6 +169,12 @@ class PrintWebViewHelper : public WebViewDelegate { virtual bool isShowingSpellingUI() { return false; } virtual void updateSpellingUIWithMisspelledWord( const WebKit::WebString& word) {} + virtual bool runFileChooser( + bool multi_select, const WebKit::WebString& title, + const WebKit::WebString& initial_value, + WebKit::WebFileChooserCompletion* chooser_completion) { + return false; + } virtual void runModalAlertDialog( WebKit::WebFrame* frame, const WebKit::WebString& message) {} virtual bool runModalConfirmDialog( @@ -183,12 +189,8 @@ class PrintWebViewHelper : public WebViewDelegate { WebKit::WebFrame* frame, const WebKit::WebString& message) { return true; } - virtual bool runFileChooser( - bool multi_select, const WebKit::WebString& title, - const WebKit::WebString& initial_value, - WebKit::WebFileChooserCompletion* chooser_completion) { - return false; - } + virtual void showContextMenu( + WebKit::WebFrame* frame, const WebKit::WebContextMenuData& data) {} virtual void setStatusText(const WebKit::WebString& text) {} virtual void setMouseOverURL(const WebKit::WebURL& url) {} virtual void setToolTipText( diff --git a/chrome/renderer/render_view.cc b/chrome/renderer/render_view.cc index 4a5d2d4..86dab30 100644 --- a/chrome/renderer/render_view.cc +++ b/chrome/renderer/render_view.cc @@ -79,6 +79,7 @@ #include "webkit/appcache/appcache_interfaces.h" #include "webkit/default_plugin/default_plugin_shared.h" #include "webkit/glue/glue_serialize.h" +#include "webkit/glue/glue_util.h" #include "webkit/glue/dom_operations.h" #include "webkit/glue/dom_serializer.h" #include "webkit/glue/image_decoder.h" @@ -113,6 +114,7 @@ using webkit_glue::SearchableFormData; using WebKit::WebColor; using WebKit::WebColorName; using WebKit::WebConsoleMessage; +using WebKit::WebContextMenuData; using WebKit::WebData; using WebKit::WebDataSource; using WebKit::WebDragData; @@ -1623,6 +1625,11 @@ bool RenderView::runModalBeforeUnloadDialog( return success; } +void RenderView::showContextMenu( + WebFrame* frame, const WebContextMenuData& data) { + Send(new ViewHostMsg_ContextMenu(routing_id_, ContextMenuParams(data))); +} + void RenderView::setStatusText(const WebString& text) { } @@ -2497,40 +2504,6 @@ void RenderView::SyncNavigationState() { routing_id_, page_id_, webkit_glue::HistoryItemToString(item))); } -void RenderView::ShowContextMenu(WebView* webview, - ContextNodeType node_type, - int x, - int y, - const GURL& link_url, - const GURL& src_url, - const GURL& page_url, - const GURL& frame_url, - const ContextMenuMediaParams& media_params, - const std::wstring& selection_text, - const std::wstring& misspelled_word, - int edit_flags, - const std::string& security_info, - const std::string& frame_charset) { - ContextMenuParams params; - params.node_type = node_type; - params.x = x; - params.y = y; - params.src_url = src_url; - params.link_url = link_url; - params.unfiltered_link_url = link_url; - params.page_url = page_url; - params.frame_url = frame_url; - params.media_params = media_params; - params.selection_text = selection_text; - params.misspelled_word = misspelled_word; - params.spellcheck_enabled = - webview->focusedFrame()->isContinuousSpellCheckingEnabled(); - params.edit_flags = edit_flags; - params.security_info = security_info; - params.frame_charset = frame_charset; - Send(new ViewHostMsg_ContextMenu(routing_id_, params)); -} - bool RenderView::DownloadImage(int id, const GURL& image_url, int image_size) { // Make sure webview was not shut down. if (!webview()) diff --git a/chrome/renderer/render_view.h b/chrome/renderer/render_view.h index 10822a5..72e8f6b 100644 --- a/chrome/renderer/render_view.h +++ b/chrome/renderer/render_view.h @@ -36,6 +36,7 @@ #include "third_party/skia/include/core/SkBitmap.h" #include "testing/gtest/include/gtest/gtest_prod.h" #include "webkit/api/public/WebConsoleMessage.h" +#include "webkit/api/public/WebContextMenuData.h" #include "webkit/api/public/WebFrameClient.h" #include "webkit/api/public/WebTextDirection.h" #include "webkit/glue/dom_serializer_delegate.h" @@ -177,20 +178,6 @@ class RenderView : public RenderWidget, virtual void OnMissingPluginStatus( WebPluginDelegateProxy* delegate, int status); - virtual void ShowContextMenu(WebView* webview, - ContextNodeType node_type, - int x, - int y, - const GURL& link_url, - const GURL& src_url, - const GURL& page_url, - const GURL& frame_url, - const ContextMenuMediaParams& media_params, - const std::wstring& selection_text, - const std::wstring& misspelled_word, - int edit_flags, - const std::string& security_info, - const std::string& frame_charset); virtual WebDevToolsAgentDelegate* GetWebDevToolsAgentDelegate(); virtual bool WasOpenedByUserGesture() const; virtual void FocusAccessibilityObject(WebCore::AccessibilityObject* acc_obj); @@ -256,6 +243,8 @@ class RenderView : public RenderWidget, const WebKit::WebString& default_value, WebKit::WebString* actual_value); virtual bool runModalBeforeUnloadDialog( WebKit::WebFrame* frame, const WebKit::WebString& message); + virtual void showContextMenu( + WebKit::WebFrame* frame, const WebKit::WebContextMenuData& data); virtual void setStatusText(const WebKit::WebString& text); virtual void setMouseOverURL(const WebKit::WebURL& url); virtual void setToolTipText( diff --git a/webkit/api/public/WebContextMenuData.h b/webkit/api/public/WebContextMenuData.h new file mode 100644 index 0000000..24a26b1 --- /dev/null +++ b/webkit/api/public/WebContextMenuData.h @@ -0,0 +1,118 @@ +/* + * Copyright (C) 2009 Google Inc. All rights reserved. + * + * Redistribution and use in source and binary forms, with or without + * modification, are permitted provided that the following conditions are + * met: + * + * * Redistributions of source code must retain the above copyright + * notice, this list of conditions and the following disclaimer. + * * Redistributions in binary form must reproduce the above + * copyright notice, this list of conditions and the following disclaimer + * in the documentation and/or other materials provided with the + * distribution. + * * Neither the name of Google Inc. nor the names of its + * contributors may be used to endorse or promote products derived from + * this software without specific prior written permission. + * + * THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS + * "AS IS" AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT + * LIMITED TO, THE IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR + * A PARTICULAR PURPOSE ARE DISCLAIMED. IN NO EVENT SHALL THE COPYRIGHT + * OWNER OR CONTRIBUTORS BE LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL, + * SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT + * LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; LOSS OF USE, + * DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND ON ANY + * THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT + * (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE + * OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE. + */ + +#ifndef WebContextMenuData_h +#define WebContextMenuData_h + +#include "WebPoint.h" +#include "WebString.h" +#include "WebURL.h" + +namespace WebKit { + + // This struct is passed to WebViewClient::ShowContextMenu. + struct WebContextMenuData { + enum MediaType { + // No special node is in context. + MediaTypeNone, + // An image node is selected. + MediaTypeImage, + // A video node is selected. + MediaTypeVideo, + // An audio node is selected. + MediaTypeAudio, + }; + // The type of media the context menu is being invoked on. + MediaType mediaType; + + // The x and y position of the mouse pointer (relative to the webview). + WebPoint mousePosition; + + // The absolute URL of the link that is in context. + WebURL linkURL; + + // The absolute URL of the image/video/audio that is in context. + WebURL srcURL; + + // The absolute URL of the page in context. + WebURL pageURL; + + // The absolute URL of the subframe in context. + WebURL frameURL; + + // The encoding for the frame in context. + WebString frameEncoding; + + enum MediaFlags { + MediaNone = 0x0, + MediaInError = 0x1, + MediaPaused = 0x2, + MediaMuted = 0x4, + MediaLoop = 0x8, + MediaCanSave = 0x10, + MediaHasAudio = 0x20, + }; + + // Extra attributes describing media elements. + int mediaFlags; + + // The raw text of the selection in context. + WebString selectedText; + + // Whether spell checking is enabled. + bool isSpellCheckingEnabled; + + // The editable (possibily) misspelled word. + WebString misspelledWord; + + // Whether context is editable. + bool isEditable; + + enum EditFlags { + CanDoNone = 0x0, + CanUndo = 0x1, + CanRedo = 0x2, + CanCut = 0x4, + CanCopy = 0x8, + CanPaste = 0x10, + CanDelete = 0x20, + CanSelectAll = 0x40, + }; + + // Which edit operations are available in the context. + int editFlags; + + // Security information for the context. + WebCString securityInfo; + }; + +} // namespace WebKit + +#endif diff --git a/webkit/api/public/WebViewClient.h b/webkit/api/public/WebViewClient.h index 7f9eb70..70e1db0 100644 --- a/webkit/api/public/WebViewClient.h +++ b/webkit/api/public/WebViewClient.h @@ -49,7 +49,7 @@ namespace WebKit { class WebString; class WebWidget; struct WebConsoleMessage; - struct WebContextMenuInfo; + struct WebContextMenuData; struct WebPoint; struct WebPopupMenuInfo; @@ -189,6 +189,10 @@ namespace WebKit { virtual bool runModalBeforeUnloadDialog( WebFrame*, const WebString& message) = 0; + // Shows a context menu with commands relevant to a specific element on + // the a given frame. Additional context data is supplied. + virtual void showContextMenu(WebFrame*, const WebContextMenuData&) = 0; + // UI ------------------------------------------------------------------ // Called when script modifies window.status diff --git a/webkit/glue/context_menu.h b/webkit/glue/context_menu.h index e4b556b..b9937c9 100644 --- a/webkit/glue/context_menu.h +++ b/webkit/glue/context_menu.h @@ -8,87 +8,9 @@ #include <vector> #include "base/basictypes.h" +#include "base/string_util.h" #include "googleurl/src/gurl.h" - -// The type of node that the user may perform a contextual action on -// in the WebView. -struct ContextNodeType { - enum TypeBit { - // No node is selected - NONE = 0x0, - - // The top page is selected - PAGE = 0x1, - - // A subframe page is selected - FRAME = 0x2, - - // A link is selected - LINK = 0x4, - - // An image is selected - IMAGE = 0x8, - - // There is a textual or mixed selection that is selected - SELECTION = 0x10, - - // An editable element is selected - EDITABLE = 0x20, - - // A misspelled word is selected - MISSPELLED_WORD = 0x40, - - // A video node is selected - VIDEO = 0x80, - - // A video node is selected - AUDIO = 0x100, - }; - - enum Capability { - CAN_DO_NONE = 0x0, - CAN_UNDO = 0x1, - CAN_REDO = 0x2, - CAN_CUT = 0x4, - CAN_COPY = 0x8, - CAN_PASTE = 0x10, - CAN_DELETE = 0x20, - CAN_SELECT_ALL = 0x40, - }; - - int32 type; - ContextNodeType() : type(NONE) {} - explicit ContextNodeType(int32 t) : type(t) {} -}; - -// Parameters structure used in ContextMenuParams with attributes needed to -// render the context menu for media elements. -// -// TODO(ajwong): Add support for multiple audio tracks and subtitles. -struct ContextMenuMediaParams { - // Values for the bitfield representing the state of the media player. - // If the state is IN_ERROR, most media controls should disable - // themselves. - enum PlayerStateBit { - NO_STATE = 0x0, - IN_ERROR = 0x1, - PAUSED = 0x2, - MUTED = 0x4, - LOOP = 0x8, - CAN_SAVE = 0x10, - }; - - // A bitfield representing the current state of the player, such as - // playing, muted, etc. - int32 player_state; - - // Whether a playable audio track is present. - bool has_audio; - - ContextMenuMediaParams() - : player_state(NO_STATE), has_audio(false) { - } -}; +#include "webkit/api/public/WebContextMenuData.h" // Parameters structure for ViewHostMsg_ContextMenu. // FIXME(beng): This would be more useful in the future and more efficient @@ -98,7 +20,7 @@ struct ContextMenuMediaParams { // could be used for more contextual actions. struct ContextMenuParams { // This is the type of Context Node that the context menu was invoked on. - ContextNodeType node_type; + WebKit::WebContextMenuData::MediaType media_type; // These values represent the coordinates of the mouse when the context menu // was invoked. Coords are relative to the associated RenderView's origin. @@ -127,7 +49,7 @@ struct ContextMenuParams { // These are the parameters for the media element that the context menu // was invoked on. - ContextMenuMediaParams media_params; + int media_flags; // This is the text of the selection that the context menu was invoked on. std::wstring selection_text; @@ -146,6 +68,9 @@ struct ContextMenuParams { // If editable, flag for whether spell check is enabled or not. bool spellcheck_enabled; + // Whether context is editable. + bool is_editable; + // These flags indicate to the browser whether the renderer believes it is // able to perform the corresponding action. int edit_flags; @@ -155,6 +80,26 @@ struct ContextMenuParams { // The character encoding of the frame on which the menu is invoked. std::string frame_charset; + + ContextMenuParams() {} + + ContextMenuParams(const WebKit::WebContextMenuData& data) + : media_type(data.mediaType), + x(data.mousePosition.x), + y(data.mousePosition.y), + link_url(data.linkURL), + unfiltered_link_url(data.linkURL), + src_url(data.srcURL), + page_url(data.pageURL), + frame_url(data.frameURL), + media_flags(data.mediaFlags), + selection_text(UTF16ToWideHack(data.selectedText)), + misspelled_word(UTF16ToWideHack(data.misspelledWord)), + spellcheck_enabled(data.isSpellCheckingEnabled), + is_editable(data.isEditable), + edit_flags(data.editFlags), + security_info(data.securityInfo), + frame_charset(data.frameEncoding.utf8()) {} }; #endif // WEBKIT_GLUE_CONTEXT_MENU_H_ diff --git a/webkit/glue/context_menu_client_impl.cc b/webkit/glue/context_menu_client_impl.cc index 3a36fc5c..ce735bf 100644 --- a/webkit/glue/context_menu_client_impl.cc +++ b/webkit/glue/context_menu_client_impl.cc @@ -16,11 +16,16 @@ #include "HTMLNames.h" #include "KURL.h" #include "MediaError.h" +#include "PlatformString.h" #include "Widget.h" #undef LOG #include "base/string_util.h" #include "base/word_iterator.h" +#include "webkit/api/public/WebContextMenuData.h" +#include "webkit/api/public/WebFrame.h" +#include "webkit/api/public/WebPoint.h" +#include "webkit/api/public/WebString.h" #include "webkit/api/public/WebURL.h" #include "webkit/api/public/WebURLResponse.h" #include "webkit/api/src/WebDataSourceImpl.h" @@ -29,11 +34,15 @@ #include "webkit/glue/glue_util.h" #include "webkit/glue/webview_impl.h" +using WebKit::WebContextMenuData; using WebKit::WebDataSource; using WebKit::WebDataSourceImpl; +using WebKit::WebFrame; +using WebKit::WebPoint; +using WebKit::WebString; +using WebKit::WebURL; namespace { - // Helper function to determine whether text is a single word or a sentence. bool IsASingleWord(const std::wstring& text) { WordIterator iter(text, WordIterator::BREAK_WORD); @@ -97,7 +106,7 @@ std::wstring GetMisspelledWord(const WebCore::ContextMenu* default_menu, misspelled_word_string = CollapseWhitespace( webkit_glue::StringToStdWString(selected_frame->selectedText()), - false); + false); // If misspelled word is empty, then that portion should not be selected. // Set the selection to that position only, and do not expand. @@ -121,23 +130,18 @@ void ContextMenuClientImpl::contextMenuDestroyed() { // Figure out the URL of a page or subframe. Returns |page_type| as the type, // which indicates page or subframe, or ContextNodeType::NONE if the URL could not // be determined for some reason. -static ContextNodeType GetTypeAndURLFromFrame( - WebCore::Frame* frame, - GURL* url, - ContextNodeType page_node_type) { - ContextNodeType node_type; +static WebURL GetURLFromFrame(WebCore::Frame* frame) { if (frame) { WebCore::DocumentLoader* dl = frame->loader()->documentLoader(); if (dl) { WebDataSource* ds = WebDataSourceImpl::fromDocumentLoader(dl); if (ds) { - node_type = page_node_type; - *url = ds->hasUnreachableURL() ? ds->unreachableURL() + return ds->hasUnreachableURL() ? ds->unreachableURL() : ds->request().url(); } } } - return node_type; + return WebURL(); } WebCore::PlatformMenuDescription @@ -154,101 +158,78 @@ WebCore::PlatformMenuDescription WebCore::HitTestResult r = default_menu->hitTestResult(); WebCore::Frame* selected_frame = r.innerNonSharedNode()->document()->frame(); - WebCore::IntPoint menu_point = - selected_frame->view()->contentsToWindow(r.point()); - - ContextNodeType node_type; + WebContextMenuData data; + WebCore::IntPoint mouse_position = selected_frame->view()->contentsToWindow( + r.point()); + data.mousePosition = webkit_glue::IntPointToWebPoint(mouse_position); // Links, Images, Media tags, and Image/Media-Links take preference over // all else. - WebCore::KURL link_url = r.absoluteLinkURL(); - if (!link_url.isEmpty()) { - node_type.type |= ContextNodeType::LINK; - } - - WebCore::KURL src_url; + data.linkURL = webkit_glue::KURLToWebURL(r.absoluteLinkURL()); - ContextMenuMediaParams media_params; + data.mediaType = WebContextMenuData::MediaTypeNone; if (!r.absoluteImageURL().isEmpty()) { - src_url = r.absoluteImageURL(); - node_type.type |= ContextNodeType::IMAGE; + data.srcURL = webkit_glue::KURLToWebURL(r.absoluteImageURL()); + data.mediaType = WebContextMenuData::MediaTypeImage; } else if (!r.absoluteMediaURL().isEmpty()) { - src_url = r.absoluteMediaURL(); + data.srcURL = webkit_glue::KURLToWebURL(r.absoluteMediaURL()); // We know that if absoluteMediaURL() is not empty, then this is a media // element. WebCore::HTMLMediaElement* media_element = static_cast<WebCore::HTMLMediaElement*>(r.innerNonSharedNode()); if (media_element->hasTagName(WebCore::HTMLNames::videoTag)) { - node_type.type |= ContextNodeType::VIDEO; + data.mediaType = WebContextMenuData::MediaTypeVideo; } else if (media_element->hasTagName(WebCore::HTMLNames::audioTag)) { - node_type.type |= ContextNodeType::AUDIO; + data.mediaType = WebContextMenuData::MediaTypeAudio; } if (media_element->error()) { - media_params.player_state |= ContextMenuMediaParams::IN_ERROR; + data.mediaFlags |= WebContextMenuData::MediaInError; } if (media_element->paused()) { - media_params.player_state |= ContextMenuMediaParams::PAUSED; + data.mediaFlags |= WebContextMenuData::MediaPaused; } if (media_element->muted()) { - media_params.player_state |= ContextMenuMediaParams::MUTED; + data.mediaFlags |= WebContextMenuData::MediaMuted; } if (media_element->loop()) { - media_params.player_state |= ContextMenuMediaParams::LOOP; + data.mediaFlags |= WebContextMenuData::MediaLoop; } if (media_element->supportsSave()) { - media_params.player_state |= ContextMenuMediaParams::CAN_SAVE; + data.mediaFlags |= WebContextMenuData::MediaCanSave; + } + if (media_element->hasAudio()) { + data.mediaFlags |= WebContextMenuData::MediaHasAudio; } - - media_params.has_audio = media_element->hasAudio(); } - // If it's not a link, an image, a media element, or an image/media link, // show a selection menu or a more generic page menu. - std::wstring selection_text_string; - std::wstring misspelled_word_string; - GURL frame_url; - GURL page_url; - std::string security_info; + data.frameEncoding = webkit_glue::StringToWebString( + selected_frame->loader()->encoding()); - std::string frame_charset = WideToASCII( - webkit_glue::StringToStdWString(selected_frame->loader()->encoding())); // Send the frame and page URLs in any case. - ContextNodeType frame_node = ContextNodeType(ContextNodeType::NONE); - ContextNodeType page_node = - GetTypeAndURLFromFrame(webview_->main_frame()->frame(), - &page_url, - ContextNodeType(ContextNodeType::PAGE)); + data.pageURL = GetURLFromFrame(webview_->main_frame()->frame()); if (selected_frame != webview_->main_frame()->frame()) { - frame_node = - GetTypeAndURLFromFrame(selected_frame, - &frame_url, - ContextNodeType(ContextNodeType::FRAME)); + data.frameURL = GetURLFromFrame(selected_frame); } if (r.isSelected()) { - node_type.type |= ContextNodeType::SELECTION; - selection_text_string = CollapseWhitespace( - webkit_glue::StringToStdWString(selected_frame->selectedText()), - false); + data.selectedText = WideToUTF16Hack(CollapseWhitespace( + webkit_glue::StringToStdWString(selected_frame->selectedText()), + false)); } + data.isEditable = false; if (r.isContentEditable()) { - node_type.type |= ContextNodeType::EDITABLE; + data.isEditable = true; if (webview_->GetFocusedWebCoreFrame()->editor()-> isContinuousSpellCheckingEnabled()) { - misspelled_word_string = GetMisspelledWord(default_menu, - selected_frame); - } - } - - if (node_type.type == ContextNodeType::NONE) { - if (selected_frame != webview_->main_frame()->frame()) { - node_type = frame_node; - } else { - node_type = page_node; + data.isSpellCheckingEnabled = true; + // TODO: GetMisspelledWord should move downstream to RenderView. + data.misspelledWord = WideToUTF16Hack( + GetMisspelledWord(default_menu, selected_frame)); } } @@ -256,41 +237,29 @@ WebCore::PlatformMenuDescription WebCore::DocumentLoader* dl = selected_frame->loader()->documentLoader(); WebDataSource* ds = WebDataSourceImpl::fromDocumentLoader(dl); if (ds) - security_info = ds->response().securityInfo(); + data.securityInfo = ds->response().securityInfo(); - int edit_flags = ContextNodeType::CAN_DO_NONE; + // Compute edit flags. + data.editFlags = WebContextMenuData::CanDoNone; if (webview_->GetFocusedWebCoreFrame()->editor()->canUndo()) - edit_flags |= ContextNodeType::CAN_UNDO; + data.editFlags |= WebContextMenuData::CanUndo; if (webview_->GetFocusedWebCoreFrame()->editor()->canRedo()) - edit_flags |= ContextNodeType::CAN_REDO; + data.editFlags |= WebContextMenuData::CanRedo; if (webview_->GetFocusedWebCoreFrame()->editor()->canCut()) - edit_flags |= ContextNodeType::CAN_CUT; + data.editFlags |= WebContextMenuData::CanCut; if (webview_->GetFocusedWebCoreFrame()->editor()->canCopy()) - edit_flags |= ContextNodeType::CAN_COPY; + data.editFlags |= WebContextMenuData::CanCopy; if (webview_->GetFocusedWebCoreFrame()->editor()->canPaste()) - edit_flags |= ContextNodeType::CAN_PASTE; + data.editFlags |= WebContextMenuData::CanPaste; if (webview_->GetFocusedWebCoreFrame()->editor()->canDelete()) - edit_flags |= ContextNodeType::CAN_DELETE; + data.editFlags |= WebContextMenuData::CanDelete; // We can always select all... - edit_flags |= ContextNodeType::CAN_SELECT_ALL; - - WebViewDelegate* d = webview_->delegate(); - if (d) { - d->ShowContextMenu(webview_, - node_type, - menu_point.x(), - menu_point.y(), - webkit_glue::KURLToGURL(link_url), - webkit_glue::KURLToGURL(src_url), - page_url, - frame_url, - media_params, - selection_text_string, - misspelled_word_string, - edit_flags, - security_info, - frame_charset); - } + data.editFlags |= WebContextMenuData::CanSelectAll; + + WebFrame* selected_web_frame = WebFrameImpl::FromFrame(selected_frame); + if (webview_->client()) + webview_->client()->showContextMenu(selected_web_frame, data); + return NULL; } diff --git a/webkit/glue/webview_delegate.h b/webkit/glue/webview_delegate.h index 7eff757..0757b85 100644 --- a/webkit/glue/webview_delegate.h +++ b/webkit/glue/webview_delegate.h @@ -51,7 +51,6 @@ class FilePath; class SkBitmap; class WebDevToolsAgentDelegate; class WebView; -struct ContextMenuMediaParams; // TODO(darin): Eliminate WebViewDelegate in favor of WebViewClient. class WebViewDelegate : public WebKit::WebViewClient { @@ -85,48 +84,6 @@ class WebViewDelegate : public WebKit::WebViewClient { const std::wstring& value) { } - // UIDelegate -------------------------------------------------------------- - - // @abstract Shows a context menu with commands relevant to a specific - // element on the current page. - // @param webview The WebView sending the delegate method. - // @param node_type The type of the node(s) the context menu is being - // invoked on - // @param x The x position of the mouse pointer (relative to the webview) - // @param y The y position of the mouse pointer (relative to the webview) - // @param link_url The absolute URL of the link that contains the node the - // mouse right clicked on - // @param image_url The absolute URL of the image that the mouse right - // clicked on - // @param page_url The URL of the page the mouse right clicked on - // @param frame_url The URL of the subframe the mouse right clicked on - // @param media_params Extra attributed needed by the context menu for - // media elements. - // @param selection_text The raw text of the selection that the mouse right - // clicked on - // @param misspelled_word The editable (possibily) misspelled word - // in the Editor on which dictionary lookup for suggestions will be done. - // @param edit_flags which edit operations the renderer believes are available - // @param security_info - // @param frame_charset which indicates the character encoding of - // the currently focused frame. - virtual void ShowContextMenu(WebView* webview, - ContextNodeType node_type, - int x, - int y, - const GURL& link_url, - const GURL& image_url, - const GURL& page_url, - const GURL& frame_url, - const ContextMenuMediaParams& media_params, - const std::wstring& selection_text, - const std::wstring& misspelled_word, - int edit_flags, - const std::string& security_info, - const std::string& frame_charset) { - } - - // DevTools ---------------------------------------------------------------- virtual WebDevToolsAgentDelegate* GetWebDevToolsAgentDelegate() { diff --git a/webkit/tools/test_shell/test_webview_delegate.cc b/webkit/tools/test_shell/test_webview_delegate.cc index 7b74866..68fc4af 100644 --- a/webkit/tools/test_shell/test_webview_delegate.cc +++ b/webkit/tools/test_shell/test_webview_delegate.cc @@ -21,6 +21,7 @@ #include "base/trace_event.h" #include "net/base/net_errors.h" #include "webkit/api/public/WebConsoleMessage.h" +#include "webkit/api/public/WebContextMenuData.h" #include "webkit/api/public/WebCString.h" #include "webkit/api/public/WebData.h" #include "webkit/api/public/WebDataSource.h" @@ -63,6 +64,7 @@ #endif using WebKit::WebConsoleMessage; +using WebKit::WebContextMenuData; using WebKit::WebData; using WebKit::WebDataSource; using WebKit::WebDragData; @@ -274,25 +276,6 @@ std::string TestWebViewDelegate::GetResourceDescription(uint32 identifier) { return it != resource_identifier_map_.end() ? it->second : "<unknown>"; } -void TestWebViewDelegate::ShowContextMenu( - WebView* webview, - ContextNodeType node_type, - int x, - int y, - const GURL& link_url, - const GURL& image_url, - const GURL& page_url, - const GURL& frame_url, - const ContextMenuMediaParams& media_params, - const std::wstring& selection_text, - const std::wstring& misspelled_word, - int edit_flags, - const std::string& security_info, - const std::string& frame_charset) { - CapturedContextMenuEvent context(node_type, x, y); - captured_context_menu_events_.push_back(context); -} - void TestWebViewDelegate::SetUserStyleSheetEnabled(bool is_enabled) { WebPreferences* prefs = shell_->GetWebPreferences(); prefs->user_style_sheet_enabled = is_enabled; @@ -502,6 +485,15 @@ bool TestWebViewDelegate::runModalBeforeUnloadDialog( return true; // Allow window closure. } +void TestWebViewDelegate::showContextMenu( + WebFrame* frame, const WebContextMenuData& data) { + CapturedContextMenuEvent context(data.mediaType, + data.mousePosition.x, + data.mousePosition.y); + captured_context_menu_events_.push_back(context); +} + + void TestWebViewDelegate::setStatusText(const WebString& text) { if (WebKit::layoutTestMode() && shell_->layout_test_controller()->ShouldDumpStatusCallbacks()) { diff --git a/webkit/tools/test_shell/test_webview_delegate.h b/webkit/tools/test_shell/test_webview_delegate.h index ff51b8b..a5fba55 100644 --- a/webkit/tools/test_shell/test_webview_delegate.h +++ b/webkit/tools/test_shell/test_webview_delegate.h @@ -24,6 +24,7 @@ #include "base/basictypes.h" #include "base/scoped_ptr.h" #include "base/weak_ptr.h" +#include "webkit/api/public/WebContextMenuData.h" #include "webkit/api/public/WebFrameClient.h" #include "webkit/api/public/WebRect.h" #if defined(OS_MACOSX) @@ -38,7 +39,6 @@ #endif #include "webkit/tools/test_shell/test_navigation_controller.h" -struct ContextMenuMediaParams; struct WebPreferences; class GURL; class TestShell; @@ -50,7 +50,7 @@ class TestWebViewDelegate : public WebViewDelegate, public base::SupportsWeakPtr<TestWebViewDelegate> { public: struct CapturedContextMenuEvent { - CapturedContextMenuEvent(ContextNodeType in_node_type, + CapturedContextMenuEvent(int in_node_type, int in_x, int in_y) : node_type(in_node_type), @@ -58,29 +58,13 @@ class TestWebViewDelegate : public WebViewDelegate, y(in_y) { } - ContextNodeType node_type; + int node_type; int x; int y; }; typedef std::vector<CapturedContextMenuEvent> CapturedContextMenuEvents; - // WebViewDelegate - virtual void ShowContextMenu(WebView* webview, - ContextNodeType node_type, - int x, - int y, - const GURL& link_url, - const GURL& image_url, - const GURL& page_url, - const GURL& frame_url, - const ContextMenuMediaParams& media_params, - const std::wstring& selection_text, - const std::wstring& misspelled_word, - int edit_flags, - const std::string& security_info, - const std::string& frame_charset); - // WebKit::WebViewClient virtual WebView* createView(WebKit::WebFrame* creator); virtual WebKit::WebWidget* createPopupMenu(bool activatable); @@ -139,6 +123,8 @@ class TestWebViewDelegate : public WebViewDelegate, const WebKit::WebString& default_value, WebKit::WebString* actual_value); virtual bool runModalBeforeUnloadDialog( WebKit::WebFrame* frame, const WebKit::WebString& message); + virtual void showContextMenu( + WebKit::WebFrame* frame, const WebKit::WebContextMenuData& data); virtual void setStatusText(const WebKit::WebString& text); virtual void setMouseOverURL(const WebKit::WebURL& url) {} virtual void setToolTipText( diff --git a/webkit/webkit.gyp b/webkit/webkit.gyp index d42676e..d961687 100644 --- a/webkit/webkit.gyp +++ b/webkit/webkit.gyp @@ -88,6 +88,7 @@ 'api/public/WebCommon.h', 'api/public/WebCompositionCommand.h', 'api/public/WebConsoleMessage.h', + 'api/public/WebContextMenuData.h', 'api/public/WebCrossOriginPreflightResultCache.h', 'api/public/WebCString.h', 'api/public/WebCursorInfo.h', |