This source file includes following definitions.
- CreateWebContentsView
- delegate_
- SetContentViewCore
- GetNativeView
- GetContentNativeView
- GetTopLevelNativeWindow
- GetContainerBounds
- SetPageTitle
- OnTabCrashed
- SizeContents
- Focus
- SetInitialFocus
- StoreFocus
- RestoreFocus
- GetDropData
- GetViewBounds
- CreateView
- CreateViewForWidget
- CreateViewForPopupWidget
- RenderViewCreated
- RenderViewSwappedIn
- SetOverscrollControllerEnabled
- ShowContextMenu
- ShowPopupMenu
- HidePopupMenu
- StartDragging
- UpdateDragCursor
- GotFocus
- TakeFocus
#include "content/browser/web_contents/web_contents_view_android.h"
#include "base/logging.h"
#include "content/browser/android/content_view_core_impl.h"
#include "content/browser/frame_host/interstitial_page_impl.h"
#include "content/browser/media/android/browser_media_player_manager.h"
#include "content/browser/renderer_host/render_widget_host_view_android.h"
#include "content/browser/renderer_host/render_view_host_factory.h"
#include "content/browser/renderer_host/render_view_host_impl.h"
#include "content/browser/web_contents/web_contents_impl.h"
#include "content/public/browser/web_contents_delegate.h"
namespace content {
WebContentsViewPort* CreateWebContentsView(
WebContentsImpl* web_contents,
WebContentsViewDelegate* delegate,
RenderViewHostDelegateView** render_view_host_delegate_view) {
WebContentsViewAndroid* rv = new WebContentsViewAndroid(
web_contents, delegate);
*render_view_host_delegate_view = rv;
return rv;
}
WebContentsViewAndroid::WebContentsViewAndroid(
WebContentsImpl* web_contents,
WebContentsViewDelegate* delegate)
: web_contents_(web_contents),
content_view_core_(NULL),
delegate_(delegate) {
}
WebContentsViewAndroid::~WebContentsViewAndroid() {
}
void WebContentsViewAndroid::SetContentViewCore(
ContentViewCoreImpl* content_view_core) {
content_view_core_ = content_view_core;
RenderWidgetHostViewAndroid* rwhv = static_cast<RenderWidgetHostViewAndroid*>(
web_contents_->GetRenderWidgetHostView());
if (rwhv)
rwhv->SetContentViewCore(content_view_core_);
if (web_contents_->ShowingInterstitialPage()) {
rwhv = static_cast<RenderWidgetHostViewAndroid*>(
static_cast<InterstitialPageImpl*>(
web_contents_->GetInterstitialPage())->
GetRenderViewHost()->GetView());
if (rwhv)
rwhv->SetContentViewCore(content_view_core_);
}
}
gfx::NativeView WebContentsViewAndroid::GetNativeView() const {
return content_view_core_ ? content_view_core_->GetViewAndroid() : NULL;
}
gfx::NativeView WebContentsViewAndroid::GetContentNativeView() const {
return content_view_core_ ? content_view_core_->GetViewAndroid() : NULL;
}
gfx::NativeWindow WebContentsViewAndroid::GetTopLevelNativeWindow() const {
return content_view_core_ ? content_view_core_->GetWindowAndroid() : NULL;
}
void WebContentsViewAndroid::GetContainerBounds(gfx::Rect* out) const {
RenderWidgetHostView* rwhv = web_contents_->GetRenderWidgetHostView();
if (rwhv)
*out = rwhv->GetViewBounds();
}
void WebContentsViewAndroid::SetPageTitle(const base::string16& title) {
if (content_view_core_)
content_view_core_->SetTitle(title);
}
void WebContentsViewAndroid::OnTabCrashed(base::TerminationStatus status,
int error_code) {
RenderViewHostImpl* rvh = static_cast<RenderViewHostImpl*>(
web_contents_->GetRenderViewHost());
if (rvh->media_player_manager())
rvh->media_player_manager()->DestroyAllMediaPlayers();
if (content_view_core_)
content_view_core_->OnTabCrashed();
}
void WebContentsViewAndroid::SizeContents(const gfx::Size& size) {
RenderWidgetHostView* rwhv = web_contents_->GetRenderWidgetHostView();
if (rwhv)
rwhv->SetSize(size);
}
void WebContentsViewAndroid::Focus() {
if (web_contents_->ShowingInterstitialPage())
web_contents_->GetInterstitialPage()->Focus();
else
web_contents_->GetRenderWidgetHostView()->Focus();
}
void WebContentsViewAndroid::SetInitialFocus() {
if (web_contents_->FocusLocationBarByDefault())
web_contents_->SetFocusToLocationBar(false);
else
Focus();
}
void WebContentsViewAndroid::StoreFocus() {
NOTIMPLEMENTED();
}
void WebContentsViewAndroid::RestoreFocus() {
NOTIMPLEMENTED();
}
DropData* WebContentsViewAndroid::GetDropData() const {
NOTIMPLEMENTED();
return NULL;
}
gfx::Rect WebContentsViewAndroid::GetViewBounds() const {
RenderWidgetHostView* rwhv = web_contents_->GetRenderWidgetHostView();
if (rwhv)
return rwhv->GetViewBounds();
else
return gfx::Rect();
}
void WebContentsViewAndroid::CreateView(
const gfx::Size& initial_size, gfx::NativeView context) {
}
RenderWidgetHostView* WebContentsViewAndroid::CreateViewForWidget(
RenderWidgetHost* render_widget_host) {
if (render_widget_host->GetView()) {
DCHECK(RenderViewHostFactory::has_factory());
return render_widget_host->GetView();
}
RenderWidgetHostImpl* rwhi = RenderWidgetHostImpl::From(render_widget_host);
RenderWidgetHostView* view = new RenderWidgetHostViewAndroid(
rwhi, content_view_core_);
return view;
}
RenderWidgetHostView* WebContentsViewAndroid::CreateViewForPopupWidget(
RenderWidgetHost* render_widget_host) {
return RenderWidgetHostViewPort::CreateViewForWidget(render_widget_host);
}
void WebContentsViewAndroid::RenderViewCreated(RenderViewHost* host) {
}
void WebContentsViewAndroid::RenderViewSwappedIn(RenderViewHost* host) {
}
void WebContentsViewAndroid::SetOverscrollControllerEnabled(bool enabled) {
}
void WebContentsViewAndroid::ShowContextMenu(
RenderFrameHost* render_frame_host, const ContextMenuParams& params) {
if (delegate_)
delegate_->ShowContextMenu(render_frame_host, params);
}
void WebContentsViewAndroid::ShowPopupMenu(
const gfx::Rect& bounds,
int item_height,
double item_font_size,
int selected_item,
const std::vector<MenuItem>& items,
bool right_aligned,
bool allow_multiple_selection) {
if (content_view_core_) {
content_view_core_->ShowSelectPopupMenu(
items, selected_item, allow_multiple_selection);
}
}
void WebContentsViewAndroid::HidePopupMenu() {
}
void WebContentsViewAndroid::StartDragging(
const DropData& drop_data,
blink::WebDragOperationsMask allowed_ops,
const gfx::ImageSkia& image,
const gfx::Vector2d& image_offset,
const DragEventSourceInfo& event_info) {
NOTIMPLEMENTED();
}
void WebContentsViewAndroid::UpdateDragCursor(blink::WebDragOperation op) {
NOTIMPLEMENTED();
}
void WebContentsViewAndroid::GotFocus() {
}
void WebContentsViewAndroid::TakeFocus(bool reverse) {
if (web_contents_->GetDelegate() &&
web_contents_->GetDelegate()->TakeFocus(web_contents_, reverse))
return;
web_contents_->GetRenderWidgetHostView()->Focus();
}
}