summaryrefslogtreecommitdiffstats
path: root/chrome
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 /chrome
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
Diffstat (limited to 'chrome')
-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
9 files changed, 93 insertions, 84 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,