summaryrefslogtreecommitdiffstats
diff options
context:
space:
mode:
authordarin@chromium.org <darin@chromium.org@0039d316-1c4b-4281-b951-d872f2087c98>2009-10-07 05:50:28 +0000
committerdarin@chromium.org <darin@chromium.org@0039d316-1c4b-4281-b951-d872f2087c98>2009-10-07 05:50:28 +0000
commit952cb7063b41fc2afaa9d1c265d38158b0e7d3e0 (patch)
treea454f8e01ee6ce946e475f8451ba4e1fd1407007
parent71cd6a943b2b677adabbafdd12b2e024106e78f6 (diff)
downloadchromium_src-952cb7063b41fc2afaa9d1c265d38158b0e7d3e0.zip
chromium_src-952cb7063b41fc2afaa9d1c265d38158b0e7d3e0.tar.gz
chromium_src-952cb7063b41fc2afaa9d1c265d38158b0e7d3e0.tar.bz2
Move MediaPlayerAction to WebMediaPlayerAction. Switch to an enum and a
boolean to express the action. R=ajwong BUG=10033 TEST=none Review URL: http://codereview.chromium.org/251103 git-svn-id: svn://svn.chromium.org/chrome/trunk/src@28236 0039d316-1c4b-4281-b951-d872f2087c98
-rw-r--r--chrome/browser/renderer_host/render_view_host.cc8
-rw-r--r--chrome/browser/renderer_host/render_view_host.h9
-rw-r--r--chrome/browser/tab_contents/render_view_context_menu.cc49
-rw-r--r--chrome/browser/tab_contents/render_view_context_menu.h12
-rw-r--r--chrome/common/render_messages.h34
-rw-r--r--chrome/common/render_messages_internal.h9
-rw-r--r--chrome/common/webkit_param_traits.h39
-rw-r--r--chrome/renderer/render_view.cc12
-rw-r--r--chrome/renderer/render_view.h5
-rw-r--r--webkit/api/public/WebMediaPlayerAction.h55
-rw-r--r--webkit/api/public/WebView.h8
-rw-r--r--webkit/glue/media_player_action.h28
-rw-r--r--webkit/glue/webview.h7
-rw-r--r--webkit/glue/webview_impl.cc64
-rw-r--r--webkit/glue/webview_impl.h6
-rw-r--r--webkit/webkit.gyp1
16 files changed, 192 insertions, 154 deletions
diff --git a/chrome/browser/renderer_host/render_view_host.cc b/chrome/browser/renderer_host/render_view_host.cc
index 667faa4..fdc6d0e 100644
--- a/chrome/browser/renderer_host/render_view_host.cc
+++ b/chrome/browser/renderer_host/render_view_host.cc
@@ -55,6 +55,7 @@ using WebKit::WebDragOperationNone;
using WebKit::WebDragOperationsMask;
using WebKit::WebFindOptions;
using WebKit::WebInputEvent;
+using WebKit::WebMediaPlayerAction;
using WebKit::WebTextDirection;
namespace {
@@ -1339,11 +1340,10 @@ void RenderViewHost::OnMsgShowModalHTMLDialog(
delegate_->ShowModalHTMLDialog(url, width, height, json_arguments, reply_msg);
}
-void RenderViewHost::MediaPlayerActionAt(int x,
- int y,
- const MediaPlayerAction& action) {
+void RenderViewHost::MediaPlayerActionAt(const gfx::Point& location,
+ const WebMediaPlayerAction& action) {
// TODO(ajwong): Which thread should run this? Does it matter?
- Send(new ViewMsg_MediaPlayerActionAt(routing_id(), x, y, action));
+ Send(new ViewMsg_MediaPlayerActionAt(routing_id(), location, action));
}
void RenderViewHost::OnMsgPasswordFormsSeen(
diff --git a/chrome/browser/renderer_host/render_view_host.h b/chrome/browser/renderer_host/render_view_host.h
index 37f1215..76b7460 100644
--- a/chrome/browser/renderer_host/render_view_host.h
+++ b/chrome/browser/renderer_host/render_view_host.h
@@ -47,6 +47,10 @@ class AutofillForm;
struct WebApplicationInfo;
}
+namespace WebKit {
+struct WebMediaPlayerAction;
+}
+
//
// RenderViewHost
//
@@ -299,8 +303,9 @@ class RenderViewHost : public RenderWidgetHost,
void ModalHTMLDialogClosed(IPC::Message* reply_msg,
const std::string& json_retval);
- // Send an action to the media player element located at |x|, |y|.
- void MediaPlayerActionAt(int x, int y, const MediaPlayerAction& action);
+ // Send an action to the media player element located at |location|.
+ void MediaPlayerActionAt(const gfx::Point& location,
+ const WebKit::WebMediaPlayerAction& action);
// Copies the image at the specified point.
void CopyImageAt(int x, int y);
diff --git a/chrome/browser/tab_contents/render_view_context_menu.cc b/chrome/browser/tab_contents/render_view_context_menu.cc
index 1f4a6ac..7c51158 100644
--- a/chrome/browser/tab_contents/render_view_context_menu.cc
+++ b/chrome/browser/tab_contents/render_view_context_menu.cc
@@ -29,7 +29,9 @@
#include "chrome/common/url_constants.h"
#include "grit/generated_resources.h"
#include "net/base/escape.h"
-#include "webkit/glue/media_player_action.h"
+#include "webkit/api/public/WebMediaPlayerAction.h"
+
+using WebKit::WebMediaPlayerAction;
namespace {
@@ -543,43 +545,38 @@ void RenderViewContextMenu::ExecuteItemCommand(int id) {
case IDS_CONTENT_CONTEXT_PLAY:
UserMetrics::RecordAction(L"MediaContextMenu_Play", profile_);
- MediaPlayerActionAt(params_.x,
- params_.y,
- MediaPlayerAction(MediaPlayerAction::PLAY));
+ MediaPlayerActionAt(gfx::Point(params_.x, params_.y),
+ WebMediaPlayerAction(
+ WebMediaPlayerAction::Play, true));
break;
case IDS_CONTENT_CONTEXT_PAUSE:
UserMetrics::RecordAction(L"MediaContextMenu_Pause", profile_);
- MediaPlayerActionAt(params_.x,
- params_.y,
- MediaPlayerAction(MediaPlayerAction::PAUSE));
+ MediaPlayerActionAt(gfx::Point(params_.x, params_.y),
+ WebMediaPlayerAction(
+ WebMediaPlayerAction::Play, false));
break;
case IDS_CONTENT_CONTEXT_MUTE:
UserMetrics::RecordAction(L"MediaContextMenu_Mute", profile_);
- MediaPlayerActionAt(params_.x,
- params_.y,
- MediaPlayerAction(MediaPlayerAction::MUTE));
+ MediaPlayerActionAt(gfx::Point(params_.x, params_.y),
+ WebMediaPlayerAction(
+ WebMediaPlayerAction::Mute, true));
break;
case IDS_CONTENT_CONTEXT_UNMUTE:
UserMetrics::RecordAction(L"MediaContextMenu_Unmute", profile_);
- MediaPlayerActionAt(params_.x,
- params_.y,
- MediaPlayerAction(MediaPlayerAction::UNMUTE));
+ MediaPlayerActionAt(gfx::Point(params_.x, params_.y),
+ WebMediaPlayerAction(
+ WebMediaPlayerAction::Mute, false));
break;
case IDS_CONTENT_CONTEXT_LOOP:
UserMetrics::RecordAction(L"MediaContextMenu_Loop", profile_);
- if (ItemIsChecked(IDS_CONTENT_CONTEXT_LOOP)) {
- MediaPlayerActionAt(params_.x,
- params_.y,
- MediaPlayerAction(MediaPlayerAction::NO_LOOP));
- } else {
- MediaPlayerActionAt(params_.x,
- params_.y,
- MediaPlayerAction(MediaPlayerAction::LOOP));
- }
+ MediaPlayerActionAt(gfx::Point(params_.x, params_.y),
+ WebMediaPlayerAction(
+ WebMediaPlayerAction::Loop,
+ !ItemIsChecked(IDS_CONTENT_CONTEXT_LOOP)));
break;
case IDS_CONTENT_CONTEXT_BACK:
@@ -809,8 +806,8 @@ void RenderViewContextMenu::WriteURLToClipboard(const GURL& url) {
}
void RenderViewContextMenu::MediaPlayerActionAt(
- int x,
- int y,
- const MediaPlayerAction& action) {
- source_tab_contents_->render_view_host()->MediaPlayerActionAt(x, y, action);
+ const gfx::Point& location,
+ const WebMediaPlayerAction& action) {
+ source_tab_contents_->render_view_host()->MediaPlayerActionAt(
+ location, action);
}
diff --git a/chrome/browser/tab_contents/render_view_context_menu.h b/chrome/browser/tab_contents/render_view_context_menu.h
index 82a1778..bd14f8c 100644
--- a/chrome/browser/tab_contents/render_view_context_menu.h
+++ b/chrome/browser/tab_contents/render_view_context_menu.h
@@ -12,7 +12,14 @@
class Profile;
class TabContents;
-struct MediaPlayerAction;
+
+namespace gfx {
+class Point;
+}
+
+namespace WebKit {
+struct WebMediaPlayerAction;
+}
class RenderViewContextMenu {
public:
@@ -97,7 +104,8 @@ class RenderViewContextMenu {
// Writes the specified text/url to the system clipboard
void WriteURLToClipboard(const GURL& url);
- void MediaPlayerActionAt(int x, int y, const MediaPlayerAction& action);
+ void MediaPlayerActionAt(const gfx::Point& location,
+ const WebKit::WebMediaPlayerAction& action);
bool IsDevCommandEnabled(int id) const;
diff --git a/chrome/common/render_messages.h b/chrome/common/render_messages.h
index afce5d9..5a6b335 100644
--- a/chrome/common/render_messages.h
+++ b/chrome/common/render_messages.h
@@ -37,7 +37,6 @@
#include "webkit/glue/autofill_form.h"
#include "webkit/glue/context_menu.h"
#include "webkit/glue/form_data.h"
-#include "webkit/glue/media_player_action.h"
#include "webkit/glue/password_form.h"
#include "webkit/glue/password_form_dom_manager.h"
#include "webkit/glue/resource_loader_bridge.h"
@@ -953,39 +952,6 @@ struct ParamTraits<ContextMenuParams> {
}
};
-template <>
-struct ParamTraits<MediaPlayerAction> {
- typedef MediaPlayerAction param_type;
- static void Write(Message* m, const param_type& p) {
- WriteParam(m, p.command);
- }
- static bool Read(const Message* m, void** iter, param_type* p) {
- return
- ReadParam(m, iter, &p->command);
- }
- static void Log(const param_type& p, std::wstring* l) {
- std::wstring event = L"";
- if (!p.command) {
- l->append(L"NONE");
- } else {
- l->append(L"(");
- if (p.command & MediaPlayerAction::PLAY)
- l->append(L"PLAY|");
- if (p.command & MediaPlayerAction::PAUSE)
- l->append(L"PAUSE|");
- if (p.command & MediaPlayerAction::MUTE)
- l->append(L"MUTE|");
- if (p.command & MediaPlayerAction::UNMUTE)
- l->append(L"UNMUTE|");
- if (p.command & MediaPlayerAction::LOOP)
- l->append(L"LOOP|");
- if (p.command & MediaPlayerAction::NO_LOOP)
- l->append(L"NO_LOOP|");
- l->append(L")");
- }
- }
-};
-
// Traits for ViewHostMsg_PaintRect_Params structure to pack/unpack.
template <>
struct ParamTraits<ViewHostMsg_PaintRect_Params> {
diff --git a/chrome/common/render_messages_internal.h b/chrome/common/render_messages_internal.h
index 006118e..9ec8ca9 100644
--- a/chrome/common/render_messages_internal.h
+++ b/chrome/common/render_messages_internal.h
@@ -93,11 +93,10 @@ IPC_BEGIN_MESSAGES(View)
RendererPreferences)
// Tells the renderer to perform the given action on the media player
- // located at |x|, |y|.
- IPC_MESSAGE_ROUTED3(ViewMsg_MediaPlayerActionAt,
- int32 /* x */,
- int32 /* y */,
- MediaPlayerAction)
+ // located at the given point.
+ IPC_MESSAGE_ROUTED2(ViewMsg_MediaPlayerActionAt,
+ gfx::Point, /* location */
+ WebKit::WebMediaPlayerAction)
// Tells the render view to close.
IPC_MESSAGE_ROUTED0(ViewMsg_Close)
diff --git a/chrome/common/webkit_param_traits.h b/chrome/common/webkit_param_traits.h
index 335ba9e..8a32741 100644
--- a/chrome/common/webkit_param_traits.h
+++ b/chrome/common/webkit_param_traits.h
@@ -30,6 +30,7 @@
#include "webkit/api/public/WebDragOperation.h"
#include "webkit/api/public/WebFindOptions.h"
#include "webkit/api/public/WebInputEvent.h"
+#include "webkit/api/public/WebMediaPlayerAction.h"
#include "webkit/api/public/WebScreenInfo.h"
#include "webkit/api/public/WebTextDirection.h"
@@ -304,7 +305,7 @@ struct ParamTraits<WebKit::WebTextDirection> {
};
template <>
- struct ParamTraits<WebKit::WebDragOperation> {
+struct ParamTraits<WebKit::WebDragOperation> {
typedef WebKit::WebDragOperation param_type;
static void Write(Message* m, const param_type& p) {
m->WriteInt(p);
@@ -320,6 +321,42 @@ template <>
}
};
+template <>
+struct ParamTraits<WebKit::WebMediaPlayerAction> {
+ typedef WebKit::WebMediaPlayerAction param_type;
+ static void Write(Message* m, const param_type& p) {
+ WriteParam(m, static_cast<int>(p.type));
+ WriteParam(m, p.enable);
+ }
+ static bool Read(const Message* m, void** iter, param_type* r) {
+ int temp;
+ if (!ReadParam(m, iter, &temp))
+ return false;
+ r->type = static_cast<param_type::Type>(temp);
+ return ReadParam(m, iter, &r->enable);
+ }
+ static void Log(const param_type& p, std::wstring* l) {
+ l->append(L"(");
+ switch (p.type) {
+ case WebKit::WebMediaPlayerAction::Play:
+ l->append(L"Play");
+ break;
+ case WebKit::WebMediaPlayerAction::Mute:
+ l->append(L"Mute");
+ break;
+ case WebKit::WebMediaPlayerAction::Loop:
+ l->append(L"Loop");
+ break;
+ default:
+ l->append(L"Unknown");
+ break;
+ }
+ l->append(L", ");
+ LogParam(p.enable, l);
+ l->append(L")");
+ }
+};
+
} // namespace IPC
#endif // CHROME_COMMON_WEBKIT_PARAM_TRAITS_H_
diff --git a/chrome/renderer/render_view.cc b/chrome/renderer/render_view.cc
index 7afabfe..a6c8cb5 100644
--- a/chrome/renderer/render_view.cc
+++ b/chrome/renderer/render_view.cc
@@ -123,6 +123,7 @@ using WebKit::WebForm;
using WebKit::WebFrame;
using WebKit::WebHistoryItem;
using WebKit::WebMediaPlayer;
+using WebKit::WebMediaPlayerAction;
using WebKit::WebMediaPlayerClient;
using WebKit::WebNavigationPolicy;
using WebKit::WebNavigationType;
@@ -3032,13 +3033,10 @@ void RenderView::OnSetRendererPrefs(const RendererPreferences& renderer_prefs) {
#endif
}
-void RenderView::OnMediaPlayerActionAt(int x,
- int y,
- const MediaPlayerAction& action) {
- if (!webview())
- return;
-
- webview()->MediaPlayerActionAt(x, y, action);
+void RenderView::OnMediaPlayerActionAt(const gfx::Point& location,
+ const WebMediaPlayerAction& action) {
+ if (webview())
+ webview()->performMediaPlayerAction(action, location);
}
void RenderView::OnNotifyRendererViewType(ViewType::Type type) {
diff --git a/chrome/renderer/render_view.h b/chrome/renderer/render_view.h
index 266a8ed..42237b8 100644
--- a/chrome/renderer/render_view.h
+++ b/chrome/renderer/render_view.h
@@ -609,9 +609,8 @@ class RenderView : public RenderWidget,
void OnEnableViewSourceMode();
void OnEnableIntrinsicWidthChangedMode();
void OnSetRendererPrefs(const RendererPreferences& renderer_prefs);
- void OnMediaPlayerActionAt(int x,
- int y,
- const MediaPlayerAction& action);
+ void OnMediaPlayerActionAt(const gfx::Point& location,
+ const WebKit::WebMediaPlayerAction& action);
void OnNotifyRendererViewType(ViewType::Type view_type);
void OnUpdateBrowserWindowId(int window_id);
void OnExecuteCode(int request_id,
diff --git a/webkit/api/public/WebMediaPlayerAction.h b/webkit/api/public/WebMediaPlayerAction.h
new file mode 100644
index 0000000..199b599
--- /dev/null
+++ b/webkit/api/public/WebMediaPlayerAction.h
@@ -0,0 +1,55 @@
+/*
+ * 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 WebMediaPlayerAction_h
+#define WebMediaPlayerAction_h
+
+namespace WebKit {
+
+ struct WebMediaPlayerAction {
+ enum Type {
+ Unknown,
+ Play,
+ Mute,
+ Loop
+ };
+
+ Type type;
+ bool enable;
+
+ WebMediaPlayerAction()
+ : type(Unknown), enable(false) { }
+ WebMediaPlayerAction(Type type, bool enable)
+ : type(type), enable(enable) { }
+ };
+
+} // namespace WebKit
+
+#endif
diff --git a/webkit/api/public/WebView.h b/webkit/api/public/WebView.h
index bf7896d..4b1437f 100644
--- a/webkit/api/public/WebView.h
+++ b/webkit/api/public/WebView.h
@@ -41,6 +41,7 @@ namespace WebKit {
class WebSettings;
class WebString;
class WebViewClient;
+ struct WebMediaPlayerAction;
struct WebPoint;
class WebView : public WebWidget {
@@ -141,6 +142,13 @@ namespace WebKit {
virtual void zoomDefault() = 0;
+ // Media ---------------------------------------------------------------
+
+ // Performs the specified action on the node at the given location.
+ virtual void performMediaPlayerAction(
+ const WebMediaPlayerAction&, const WebPoint& location) = 0;
+
+
// Data exchange -------------------------------------------------------
// Copy to the clipboard the image located at a particular point in the
diff --git a/webkit/glue/media_player_action.h b/webkit/glue/media_player_action.h
deleted file mode 100644
index b4506fd..0000000
--- a/webkit/glue/media_player_action.h
+++ /dev/null
@@ -1,28 +0,0 @@
-// Copyright (c) 2009 The Chromium Authors. All rights reserved.
-// Use of this source code is governed by a BSD-style license that can be
-// found in the LICENSE file.
-
-#ifndef WEBKIT_GLUE_MEDIA_PLAYER_ACTION_H_
-#define WEBKIT_GLUE_MEDIA_PLAYER_ACTION_H_
-
-// Commands that can be sent to the MediaPlayer via a WebView.
-struct MediaPlayerAction {
- enum CommandTypeBit {
- NONE = 0x0,
- PLAY = 0x1,
- PAUSE = 0x2,
- MUTE = 0x4,
- UNMUTE = 0x8,
- LOOP = 0x10,
- NO_LOOP = 0x20,
- };
-
- // A bitfield representing the actions that the context menu should execute
- // on the originating node.
- int32 command;
-
- MediaPlayerAction() : command(NONE) {}
- explicit MediaPlayerAction(int c) : command(c) {}
-};
-
-#endif // WEBKIT_GLUE_MEDIA_PLAYER_ACTION_H_
diff --git a/webkit/glue/webview.h b/webkit/glue/webview.h
index cf290cb..c5c299c 100644
--- a/webkit/glue/webview.h
+++ b/webkit/glue/webview.h
@@ -23,7 +23,6 @@ struct WebPoint;
class GURL;
class WebDevToolsAgent;
class WebViewDelegate;
-struct MediaPlayerAction;
//
// @class WebView
@@ -81,12 +80,6 @@ class WebView : public WebKit::WebView {
// Returns development tools agent instance belonging to this view.
virtual WebDevToolsAgent* GetWebDevToolsAgent() = 0;
- // Performs an action from a context menu for the node at the given
- // location.
- virtual void MediaPlayerActionAt(int x,
- int y,
- const MediaPlayerAction& action) = 0;
-
private:
DISALLOW_COPY_AND_ASSIGN(WebView);
};
diff --git a/webkit/glue/webview_impl.cc b/webkit/glue/webview_impl.cc
index 9234e25..6e98ccc 100644
--- a/webkit/glue/webview_impl.cc
+++ b/webkit/glue/webview_impl.cc
@@ -63,6 +63,7 @@ MSVC_POP_WARNING();
#include "base/message_loop.h"
#include "webkit/api/public/WebDragData.h"
#include "webkit/api/public/WebInputEvent.h"
+#include "webkit/api/public/WebMediaPlayerAction.h"
#include "webkit/api/public/WebPoint.h"
#include "webkit/api/public/WebRect.h"
#include "webkit/api/public/WebString.h"
@@ -72,7 +73,6 @@ MSVC_POP_WARNING();
#include "webkit/glue/glue_serialize.h"
#include "webkit/glue/glue_util.h"
#include "webkit/glue/image_resource_fetcher.h"
-#include "webkit/glue/media_player_action.h"
#include "webkit/glue/searchable_form_data.h"
#include "webkit/glue/webdevtoolsagent_impl.h"
#include "webkit/glue/webkit_glue.h"
@@ -104,6 +104,7 @@ using WebKit::WebFrame;
using WebKit::WebFrameClient;
using WebKit::WebInputEvent;
using WebKit::WebKeyboardEvent;
+using WebKit::WebMediaPlayerAction;
using WebKit::WebMouseEvent;
using WebKit::WebMouseWheelEvent;
using WebKit::WebNavigationPolicy;
@@ -1417,6 +1418,36 @@ void WebViewImpl::zoomDefault() {
main_frame()->frame()->isZoomFactorTextOnly());
}
+void WebViewImpl::performMediaPlayerAction(const WebMediaPlayerAction& action,
+ const WebPoint& location) {
+ HitTestResult result =
+ HitTestResultForWindowPos(webkit_glue::WebPointToIntPoint(location));
+ WTF::RefPtr<WebCore::Node> node = result.innerNonSharedNode();
+ if (!node->hasTagName(WebCore::HTMLNames::videoTag) &&
+ !node->hasTagName(WebCore::HTMLNames::audioTag))
+ return;
+
+ WTF::RefPtr<WebCore::HTMLMediaElement> media_element =
+ static_pointer_cast<WebCore::HTMLMediaElement>(node);
+ switch (action.type) {
+ case WebMediaPlayerAction::Play:
+ if (action.enable) {
+ media_element->play();
+ } else {
+ media_element->pause();
+ }
+ break;
+ case WebMediaPlayerAction::Mute:
+ media_element->setMuted(action.enable);
+ break;
+ case WebMediaPlayerAction::Loop:
+ media_element->setLoop(action.enable);
+ break;
+ default:
+ ASSERT_NOT_REACHED();
+ }
+}
+
void WebViewImpl::copyImageAt(const WebPoint& point) {
if (!page_.get())
return;
@@ -1716,37 +1747,6 @@ bool WebViewImpl::isTransparent() const {
return is_transparent_;
}
-void WebViewImpl::MediaPlayerActionAt(int x,
- int y,
- const MediaPlayerAction& action) {
- HitTestResult result = HitTestResultForWindowPos(IntPoint(x, y));
-
- WTF::RefPtr<WebCore::Node> node = result.innerNonSharedNode();
- if (node->hasTagName(WebCore::HTMLNames::videoTag) ||
- node->hasTagName(WebCore::HTMLNames::audioTag)) {
- WTF::RefPtr<WebCore::HTMLMediaElement> media_element =
- static_pointer_cast<WebCore::HTMLMediaElement>(node);
- if (action.command & MediaPlayerAction::PLAY) {
- media_element->play();
- }
- if (action.command & MediaPlayerAction::PAUSE) {
- media_element->pause();
- }
- if (action.command & MediaPlayerAction::MUTE) {
- media_element->setMuted(true);
- }
- if (action.command & MediaPlayerAction::UNMUTE) {
- media_element->setMuted(false);
- }
- if (action.command & MediaPlayerAction::LOOP) {
- media_element->setLoop(true);
- }
- if (action.command & MediaPlayerAction::NO_LOOP) {
- media_element->setLoop(false);
- }
- }
-}
-
void WebViewImpl::setIsActive(bool active) {
if (page() && page()->focusController())
page()->focusController()->setActive(active);
diff --git a/webkit/glue/webview_impl.h b/webkit/glue/webview_impl.h
index dee9900..f956042 100644
--- a/webkit/glue/webview_impl.h
+++ b/webkit/glue/webview_impl.h
@@ -106,6 +106,9 @@ class WebViewImpl : public WebView, public base::RefCounted<WebViewImpl> {
virtual void zoomIn(bool text_only);
virtual void zoomOut(bool text_only);
virtual void zoomDefault();
+ virtual void performMediaPlayerAction(
+ const WebKit::WebMediaPlayerAction& action,
+ const WebKit::WebPoint& location);
virtual void copyImageAt(const WebKit::WebPoint& point);
virtual void dragSourceEndedAt(
const WebKit::WebPoint& client_point,
@@ -144,9 +147,6 @@ class WebViewImpl : public WebView, public base::RefCounted<WebViewImpl> {
virtual void SetIgnoreInputEvents(bool new_value);
virtual WebDevToolsAgent* GetWebDevToolsAgent();
WebDevToolsAgentImpl* GetWebDevToolsAgentImpl();
- virtual void MediaPlayerActionAt(int x,
- int y,
- const MediaPlayerAction& action);
// WebViewImpl
diff --git a/webkit/webkit.gyp b/webkit/webkit.gyp
index 9765830..7357fed5 100644
--- a/webkit/webkit.gyp
+++ b/webkit/webkit.gyp
@@ -108,6 +108,7 @@
'api/public/WebKitClient.h',
'api/public/WebLocalizedString.h',
'api/public/WebMediaPlayer.h',
+ 'api/public/WebMediaPlayerAction.h',
'api/public/WebMediaPlayerClient.h',
'api/public/WebMessagePortChannel.h',
'api/public/WebMessagePortChannelClient.h',