summaryrefslogtreecommitdiffstats
path: root/webkit
diff options
context:
space:
mode:
authoryaar@chromium.org <yaar@chromium.org@0039d316-1c4b-4281-b951-d872f2087c98>2009-10-09 18:17:44 +0000
committeryaar@chromium.org <yaar@chromium.org@0039d316-1c4b-4281-b951-d872f2087c98>2009-10-09 18:17:44 +0000
commit79e3744bbbb0867f4e356eab96703d425b3fad40 (patch)
tree790f3464f1636e542b15b2a5de852cbb6c5f9c41 /webkit
parent9068747c5591866480bd0888e571cc548d6be546 (diff)
downloadchromium_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
Diffstat (limited to 'webkit')
-rw-r--r--webkit/api/public/WebContextMenuData.h118
-rw-r--r--webkit/api/public/WebViewClient.h6
-rw-r--r--webkit/glue/context_menu.h109
-rw-r--r--webkit/glue/context_menu_client_impl.cc153
-rw-r--r--webkit/glue/webview_delegate.h43
-rw-r--r--webkit/tools/test_shell/test_webview_delegate.cc30
-rw-r--r--webkit/tools/test_shell/test_webview_delegate.h24
-rw-r--r--webkit/webkit.gyp1
8 files changed, 228 insertions, 256 deletions
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',