Commit 7497152b authored by jonross's avatar jonross Committed by Commit bot

Export ScreenOrientationProvider

Move ScreenOrientationProvider and ScreenOrientationDispatcherHost from content/browser/screen_orientation/ to content/public/browser/ to expose them to other libraries. This will allow Ash to use them to implement the ScreenOrientationProvider on Chrome OS. Created an implementation of ScreenOrientationDispatcherHost.
BUG=396760

Review URL: https://codereview.chromium.org/508603003

Cr-Commit-Position: refs/heads/master@{#294819}
parent f10031e0
......@@ -32,7 +32,6 @@
#include "content/browser/renderer_host/render_view_host_impl.h"
#include "content/browser/renderer_host/render_widget_host_impl.h"
#include "content/browser/renderer_host/render_widget_host_view_android.h"
#include "content/browser/screen_orientation/screen_orientation_dispatcher_host.h"
#include "content/browser/transition_request_manager.h"
#include "content/browser/web_contents/web_contents_view_android.h"
#include "content/common/frame_messages.h"
......@@ -43,6 +42,7 @@
#include "content/public/browser/browser_thread.h"
#include "content/public/browser/favicon_status.h"
#include "content/public/browser/render_frame_host.h"
#include "content/public/browser/screen_orientation_dispatcher_host.h"
#include "content/public/browser/ssl_host_state_delegate.h"
#include "content/public/browser/web_contents.h"
#include "content/public/common/content_client.h"
......
......@@ -2,50 +2,50 @@
// Use of this source code is governed by a BSD-style license that can be
// found in the LICENSE file.
#include "content/browser/screen_orientation/screen_orientation_dispatcher_host.h"
#include "content/browser/screen_orientation/screen_orientation_dispatcher_host_impl.h"
#include "content/browser/screen_orientation/screen_orientation_provider.h"
#include "content/common/screen_orientation_messages.h"
#include "content/public/browser/render_frame_host.h"
#include "content/public/browser/render_process_host.h"
#include "content/public/browser/render_view_host.h"
#include "content/public/browser/render_widget_host.h"
#include "content/public/browser/screen_orientation_provider.h"
#include "content/public/browser/web_contents.h"
#include "third_party/WebKit/public/platform/WebScreenInfo.h"
namespace content {
ScreenOrientationDispatcherHost::LockInformation::LockInformation(
ScreenOrientationDispatcherHostImpl::LockInformation::LockInformation(
int request_id, int process_id, int routing_id)
: request_id(request_id),
process_id(process_id),
routing_id(routing_id) {
}
ScreenOrientationDispatcherHost::ScreenOrientationDispatcherHost(
ScreenOrientationDispatcherHostImpl::ScreenOrientationDispatcherHostImpl(
WebContents* web_contents)
: WebContentsObserver(web_contents),
current_lock_(NULL) {
provider_.reset(ScreenOrientationProvider::Create(this, web_contents));
}
ScreenOrientationDispatcherHost::~ScreenOrientationDispatcherHost() {
ScreenOrientationDispatcherHostImpl::~ScreenOrientationDispatcherHostImpl() {
ResetCurrentLock();
}
void ScreenOrientationDispatcherHost::ResetCurrentLock() {
void ScreenOrientationDispatcherHostImpl::ResetCurrentLock() {
if (current_lock_) {
delete current_lock_;
current_lock_ = 0;
}
}
bool ScreenOrientationDispatcherHost::OnMessageReceived(
bool ScreenOrientationDispatcherHostImpl::OnMessageReceived(
const IPC::Message& message,
RenderFrameHost* render_frame_host) {
bool handled = true;
IPC_BEGIN_MESSAGE_MAP_WITH_PARAM(ScreenOrientationDispatcherHost, message,
IPC_BEGIN_MESSAGE_MAP_WITH_PARAM(ScreenOrientationDispatcherHostImpl, message,
render_frame_host)
IPC_MESSAGE_HANDLER(ScreenOrientationHostMsg_LockRequest, OnLockRequest)
IPC_MESSAGE_HANDLER(ScreenOrientationHostMsg_Unlock, OnUnlockRequest)
......@@ -56,7 +56,7 @@ bool ScreenOrientationDispatcherHost::OnMessageReceived(
}
RenderFrameHost*
ScreenOrientationDispatcherHost::GetRenderFrameHostForRequestID(
ScreenOrientationDispatcherHostImpl::GetRenderFrameHostForRequestID(
int request_id) {
if (!current_lock_ || current_lock_->request_id != request_id)
return NULL;
......@@ -65,7 +65,7 @@ ScreenOrientationDispatcherHost::GetRenderFrameHostForRequestID(
current_lock_->routing_id);
}
void ScreenOrientationDispatcherHost::NotifyLockSuccess(int request_id) {
void ScreenOrientationDispatcherHostImpl::NotifyLockSuccess(int request_id) {
RenderFrameHost* render_frame_host =
GetRenderFrameHostForRequestID(request_id);
if (!render_frame_host)
......@@ -76,7 +76,7 @@ void ScreenOrientationDispatcherHost::NotifyLockSuccess(int request_id) {
ResetCurrentLock();
}
void ScreenOrientationDispatcherHost::NotifyLockError(
void ScreenOrientationDispatcherHostImpl::NotifyLockError(
int request_id, blink::WebLockOrientationError error) {
RenderFrameHost* render_frame_host =
GetRenderFrameHostForRequestID(request_id);
......@@ -86,7 +86,7 @@ void ScreenOrientationDispatcherHost::NotifyLockError(
NotifyLockError(request_id, render_frame_host, error);
}
void ScreenOrientationDispatcherHost::NotifyLockError(
void ScreenOrientationDispatcherHostImpl::NotifyLockError(
int request_id,
RenderFrameHost* render_frame_host,
blink::WebLockOrientationError error) {
......@@ -95,12 +95,12 @@ void ScreenOrientationDispatcherHost::NotifyLockError(
ResetCurrentLock();
}
void ScreenOrientationDispatcherHost::OnOrientationChange() {
void ScreenOrientationDispatcherHostImpl::OnOrientationChange() {
if (provider_)
provider_->OnOrientationChange();
}
void ScreenOrientationDispatcherHost::OnLockRequest(
void ScreenOrientationDispatcherHostImpl::OnLockRequest(
RenderFrameHost* render_frame_host,
blink::WebScreenOrientationLockType orientation,
int request_id) {
......@@ -122,7 +122,7 @@ void ScreenOrientationDispatcherHost::OnLockRequest(
provider_->LockOrientation(request_id, orientation);
}
void ScreenOrientationDispatcherHost::OnUnlockRequest(
void ScreenOrientationDispatcherHostImpl::OnUnlockRequest(
RenderFrameHost* render_frame_host) {
if (current_lock_) {
NotifyLockError(current_lock_->request_id, render_frame_host,
......
......@@ -2,15 +2,13 @@
// Use of this source code is governed by a BSD-style license that can be
// found in the LICENSE file.
#ifndef CONTENT_BROWSER_SCREEN_ORIENTATION_SCREEN_ORIENTATION_DISPATCHER_HOST_H_
#define CONTENT_BROWSER_SCREEN_ORIENTATION_SCREEN_ORIENTATION_DISPATCHER_HOST_H_
#ifndef CONTENT_BROWSER_SCREEN_ORIENTATION_SCREEN_ORIENTATION_DISPATCHER_HOST_IMPL_H_
#define CONTENT_BROWSER_SCREEN_ORIENTATION_SCREEN_ORIENTATION_DISPATCHER_HOST_IMPL_H_
#include "base/id_map.h"
#include "content/public/browser/render_frame_host.h"
#include "content/public/browser/screen_orientation_dispatcher_host.h"
#include "content/public/browser/web_contents_observer.h"
#include "third_party/WebKit/public/platform/WebLockOrientationError.h"
#include "third_party/WebKit/public/platform/WebScreenOrientationLockType.h"
#include "third_party/WebKit/public/platform/WebScreenOrientationType.h"
namespace content {
......@@ -21,28 +19,23 @@ class WebContents;
// ScreenOrientationDispatcherHost receives lock and unlock requests from the
// RenderFrames and dispatch them to the ScreenOrientationProvider. It also
// make sure that the right RenderFrame get replied for each lock request.
class CONTENT_EXPORT ScreenOrientationDispatcherHost
: public WebContentsObserver {
class CONTENT_EXPORT ScreenOrientationDispatcherHostImpl
: public ScreenOrientationDispatcherHost,
public WebContentsObserver {
public:
explicit ScreenOrientationDispatcherHost(WebContents* web_contents);
virtual ~ScreenOrientationDispatcherHost();
explicit ScreenOrientationDispatcherHostImpl(WebContents* web_contents);
virtual ~ScreenOrientationDispatcherHostImpl();
// WebContentsObserver
// ScreenOrientationDispatcherHost:
virtual void NotifyLockSuccess(int request_id) OVERRIDE;
virtual void NotifyLockError(int request_id,
blink::WebLockOrientationError error) OVERRIDE;
virtual void OnOrientationChange() OVERRIDE;
// WebContentsObserver:
virtual bool OnMessageReceived(const IPC::Message&,
RenderFrameHost* render_frame_host) OVERRIDE;
// Notifies that the lock with the given |request_id| has succeeded.
// The renderer process will be notified that the lock succeeded only if
// |request_id| matches the |current_lock_|.
void NotifyLockSuccess(int request_id);
// Notifies that the lock with the given |request_id| has failed.
// The renderer process will be notified that the lock succeeded only if
// |request_id| matches the |current_lock_|.
void NotifyLockError(int request_id, blink::WebLockOrientationError error);
void OnOrientationChange();
private:
void OnLockRequest(RenderFrameHost* render_frame_host,
blink::WebScreenOrientationLockType orientation,
......@@ -69,9 +62,9 @@ class CONTENT_EXPORT ScreenOrientationDispatcherHost
// current_lock_ will be NULL if there are no current lock.
LockInformation* current_lock_;
DISALLOW_COPY_AND_ASSIGN(ScreenOrientationDispatcherHost);
DISALLOW_COPY_AND_ASSIGN(ScreenOrientationDispatcherHostImpl);
};
} // namespace content
#endif // CONTENT_BROWSER_SCREEN_ORIENTATION_SCREEN_ORIENTATION_DISPATCHER_HOST_H_
#endif // CONTENT_BROWSER_SCREEN_ORIENTATION_SCREEN_ORIENTATION_DISPATCHER_HOST_IMPL_H_
......@@ -5,10 +5,10 @@
#include "content/browser/screen_orientation/screen_orientation_provider_android.h"
#include "content/browser/android/content_view_core_impl.h"
#include "content/browser/screen_orientation/screen_orientation_dispatcher_host.h"
#include "content/browser/web_contents/web_contents_impl.h"
#include "content/public/browser/render_view_host.h"
#include "content/public/browser/render_widget_host.h"
#include "content/public/browser/screen_orientation_dispatcher_host.h"
#include "jni/ScreenOrientationProvider_jni.h"
#include "third_party/WebKit/public/platform/WebLockOrientationError.h"
#include "third_party/WebKit/public/platform/WebScreenInfo.h"
......
......@@ -8,11 +8,12 @@
#include <jni.h>
#include "base/compiler_specific.h"
#include "content/browser/screen_orientation/screen_orientation_provider.h"
#include "content/public/browser/screen_orientation_provider.h"
#include "content/public/browser/web_contents_observer.h"
namespace content {
class ScreenOrientationDispatcherHost;
class WebContentsImpl;
class ScreenOrientationProviderAndroid : public ScreenOrientationProvider,
......
......@@ -48,7 +48,7 @@
#include "content/browser/renderer_host/render_view_host_impl.h"
#include "content/browser/renderer_host/render_widget_host_impl.h"
#include "content/browser/renderer_host/render_widget_host_view_base.h"
#include "content/browser/screen_orientation/screen_orientation_dispatcher_host.h"
#include "content/browser/screen_orientation/screen_orientation_dispatcher_host_impl.h"
#include "content/browser/site_instance_impl.h"
#include "content/browser/web_contents/web_contents_view_guest.h"
#include "content/browser/webui/generic_handler.h"
......@@ -77,6 +77,7 @@
#include "content/public/browser/notification_service.h"
#include "content/public/browser/render_widget_host_iterator.h"
#include "content/public/browser/resource_request_details.h"
#include "content/public/browser/screen_orientation_dispatcher_host.h"
#include "content/public/browser/storage_partition.h"
#include "content/public/browser/user_metrics.h"
#include "content/public/browser/web_contents_delegate.h"
......@@ -1203,7 +1204,7 @@ void WebContentsImpl::Init(const WebContents::CreateParams& params) {
midi_dispatcher_host_.reset(new MidiDispatcherHost(this));
screen_orientation_dispatcher_host_.reset(
new ScreenOrientationDispatcherHost(this));
new ScreenOrientationDispatcherHostImpl(this));
#if defined(OS_ANDROID)
date_time_chooser_.reset(new DateTimeChooserAndroid());
......
......@@ -190,6 +190,8 @@
'public/browser/resource_request_info.h',
'public/browser/resource_throttle.h',
'public/browser/save_page_type.h',
'public/browser/screen_orientation_dispatcher_host.h',
'public/browser/screen_orientation_provider.h',
'public/browser/service_worker_context.h',
'public/browser/service_worker_usage_info.cc',
'public/browser/service_worker_usage_info.h',
......@@ -1116,11 +1118,10 @@
'browser/resource_context_impl.h',
'browser/safe_util_win.cc',
'browser/safe_util_win.h',
'browser/screen_orientation/screen_orientation_dispatcher_host.cc',
'browser/screen_orientation/screen_orientation_dispatcher_host.h',
'browser/screen_orientation/screen_orientation_dispatcher_host_impl.cc',
'browser/screen_orientation/screen_orientation_dispatcher_host_impl.h',
'browser/screen_orientation/screen_orientation_message_filter_android.h',
'browser/screen_orientation/screen_orientation_message_filter_android.cc',
'browser/screen_orientation/screen_orientation_provider.h',
'browser/screen_orientation/screen_orientation_provider_android.h',
'browser/screen_orientation/screen_orientation_provider_android.cc',
'browser/service_worker/embedded_worker_instance.cc',
......
// Copyright 2014 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 CONTENT_PUBLIC_BROWSER_SCREEN_ORIENTATION_DISPATCHER_HOST_H_
#define CONTENT_PUBLIC_BROWSER_SCREEN_ORIENTATION_DISPATCHER_HOST_H_
#include "content/common/content_export.h"
#include "third_party/WebKit/public/platform/WebLockOrientationError.h"
namespace content {
// ScreenOrientationDispatcherHost receives lock and unlock requests from the
// RenderFrames and dispatch them to the ScreenOrientationProvider. It also
// make sure that the right RenderFrame get replied for each lock request.
class CONTENT_EXPORT ScreenOrientationDispatcherHost {
public:
virtual ~ScreenOrientationDispatcherHost() {}
// Notifies that the lock with the given |request_id| has succeeded.
// The renderer process will be notified that the lock succeeded only if
// |request_id| matches the current lock information.
virtual void NotifyLockSuccess(int request_id) = 0;
// Notifies that the lock with the given |request_id| has failed.
// The renderer process will be notified that the lock succeeded only if
// |request_id| matches the current lock information.
virtual void NotifyLockError(int request_id,
blink::WebLockOrientationError error) = 0;
virtual void OnOrientationChange() = 0;
};
} // namespace content
#endif // CONTENT_PUBLIC_BROWSER_SCREEN_ORIENTATION_DISPATCHER_HOST_H_
......@@ -2,10 +2,11 @@
// Use of this source code is governed by a BSD-style license that can be
// found in the LICENSE file.
#ifndef CONTENT_BROWSER_SCREEN_ORIENTATION_SCREEN_ORIENTATION_PROVIDER_H_
#define CONTENT_BROWSER_SCREEN_ORIENTATION_SCREEN_ORIENTATION_PROVIDER_H_
#ifndef CONTENT_PUBLIC_BROWSER_SCREEN_ORIENTATION_PROVIDER_H_
#define CONTENT_PUBLIC_BROWSER_SCREEN_ORIENTATION_PROVIDER_H_
#include "base/macros.h"
#include "content/common/content_export.h"
#include "third_party/WebKit/public/platform/WebScreenOrientationLockType.h"
namespace content {
......@@ -15,7 +16,7 @@ class WebContents;
// Interface that needs to be implemented by any backend that wants to handle
// screen orientation lock/unlock.
class ScreenOrientationProvider {
class CONTENT_EXPORT ScreenOrientationProvider {
public:
// Lock the screen orientation to |orientations|.
virtual void LockOrientation(
......@@ -32,7 +33,7 @@ class ScreenOrientationProvider {
virtual ~ScreenOrientationProvider() {}
protected:
friend class ScreenOrientationDispatcherHost;
friend class ScreenOrientationDispatcherHostImpl;
static ScreenOrientationProvider* Create(
ScreenOrientationDispatcherHost* dispatcher_host,
......@@ -54,4 +55,4 @@ ScreenOrientationProvider* ScreenOrientationProvider::Create(
} // namespace content
#endif // CONTENT_BROWSER_SCREEN_ORIENTATION_SCREEN_ORIENTATION_PROVIDER_H_
#endif // CONTENT_PUBLIC_BROWSER_SCREEN_ORIENTATION_PROVIDER_H_
Markdown is supported
0%
or
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment