15821806d5e7f356e8fa4b058a389a808ea183019Torne (Richard Coles)// Copyright (c) 2012 The Chromium Authors. All rights reserved.
25821806d5e7f356e8fa4b058a389a808ea183019Torne (Richard Coles)// Use of this source code is governed by a BSD-style license that can be
35821806d5e7f356e8fa4b058a389a808ea183019Torne (Richard Coles)// found in the LICENSE file.
45821806d5e7f356e8fa4b058a389a808ea183019Torne (Richard Coles)
55821806d5e7f356e8fa4b058a389a808ea183019Torne (Richard Coles)#include "content/renderer/render_widget_fullscreen.h"
65821806d5e7f356e8fa4b058a389a808ea183019Torne (Richard Coles)
75821806d5e7f356e8fa4b058a389a808ea183019Torne (Richard Coles)#include "content/common/view_messages.h"
87d4cd473f85ac64c3747c96c277f9e506a0d2246Torne (Richard Coles)#include "third_party/WebKit/public/web/WebWidget.h"
95821806d5e7f356e8fa4b058a389a808ea183019Torne (Richard Coles)
105821806d5e7f356e8fa4b058a389a808ea183019Torne (Richard Coles)using WebKit::WebWidget;
115821806d5e7f356e8fa4b058a389a808ea183019Torne (Richard Coles)
125821806d5e7f356e8fa4b058a389a808ea183019Torne (Richard Coles)namespace content {
135821806d5e7f356e8fa4b058a389a808ea183019Torne (Richard Coles)
145821806d5e7f356e8fa4b058a389a808ea183019Torne (Richard Coles)void RenderWidgetFullscreen::show(WebKit::WebNavigationPolicy) {
155821806d5e7f356e8fa4b058a389a808ea183019Torne (Richard Coles)  DCHECK(!did_show_) << "received extraneous Show call";
165821806d5e7f356e8fa4b058a389a808ea183019Torne (Richard Coles)  DCHECK_NE(MSG_ROUTING_NONE, routing_id_);
175821806d5e7f356e8fa4b058a389a808ea183019Torne (Richard Coles)  DCHECK_NE(MSG_ROUTING_NONE, opener_id_);
185821806d5e7f356e8fa4b058a389a808ea183019Torne (Richard Coles)
195821806d5e7f356e8fa4b058a389a808ea183019Torne (Richard Coles)  if (!did_show_) {
205821806d5e7f356e8fa4b058a389a808ea183019Torne (Richard Coles)    did_show_ = true;
215821806d5e7f356e8fa4b058a389a808ea183019Torne (Richard Coles)    Send(new ViewHostMsg_ShowFullscreenWidget(opener_id_, routing_id_));
225821806d5e7f356e8fa4b058a389a808ea183019Torne (Richard Coles)    SetPendingWindowRect(initial_pos_);
235821806d5e7f356e8fa4b058a389a808ea183019Torne (Richard Coles)  }
245821806d5e7f356e8fa4b058a389a808ea183019Torne (Richard Coles)}
255821806d5e7f356e8fa4b058a389a808ea183019Torne (Richard Coles)
265821806d5e7f356e8fa4b058a389a808ea183019Torne (Richard Coles)RenderWidgetFullscreen::RenderWidgetFullscreen(
275821806d5e7f356e8fa4b058a389a808ea183019Torne (Richard Coles)    const WebKit::WebScreenInfo& screen_info)
285821806d5e7f356e8fa4b058a389a808ea183019Torne (Richard Coles)    : RenderWidget(WebKit::WebPopupTypeNone, screen_info, false) {
295821806d5e7f356e8fa4b058a389a808ea183019Torne (Richard Coles)}
305821806d5e7f356e8fa4b058a389a808ea183019Torne (Richard Coles)
315821806d5e7f356e8fa4b058a389a808ea183019Torne (Richard Coles)RenderWidgetFullscreen::~RenderWidgetFullscreen() {}
325821806d5e7f356e8fa4b058a389a808ea183019Torne (Richard Coles)
335821806d5e7f356e8fa4b058a389a808ea183019Torne (Richard Coles)WebWidget* RenderWidgetFullscreen::CreateWebWidget() {
345821806d5e7f356e8fa4b058a389a808ea183019Torne (Richard Coles)  // TODO(boliu): Handle full screen render widgets here.
355821806d5e7f356e8fa4b058a389a808ea183019Torne (Richard Coles)  return RenderWidget::CreateWebWidget(this);
365821806d5e7f356e8fa4b058a389a808ea183019Torne (Richard Coles)}
375821806d5e7f356e8fa4b058a389a808ea183019Torne (Richard Coles)
382a99a7e74a7f215066514fe81d2bfa6639d9edddTorne (Richard Coles)bool RenderWidgetFullscreen::Init(int32 opener_id) {
395821806d5e7f356e8fa4b058a389a808ea183019Torne (Richard Coles)  DCHECK(!webwidget_);
405821806d5e7f356e8fa4b058a389a808ea183019Torne (Richard Coles)
412a99a7e74a7f215066514fe81d2bfa6639d9edddTorne (Richard Coles)  return RenderWidget::DoInit(
425821806d5e7f356e8fa4b058a389a808ea183019Torne (Richard Coles)      opener_id,
435821806d5e7f356e8fa4b058a389a808ea183019Torne (Richard Coles)      CreateWebWidget(),
445821806d5e7f356e8fa4b058a389a808ea183019Torne (Richard Coles)      new ViewHostMsg_CreateFullscreenWidget(
455821806d5e7f356e8fa4b058a389a808ea183019Torne (Richard Coles)          opener_id, &routing_id_, &surface_id_));
465821806d5e7f356e8fa4b058a389a808ea183019Torne (Richard Coles)}
475821806d5e7f356e8fa4b058a389a808ea183019Torne (Richard Coles)
485821806d5e7f356e8fa4b058a389a808ea183019Torne (Richard Coles)}  // namespace content
49