summaryrefslogtreecommitdiffstats
path: root/chrome/renderer/render_widget_fullscreen.cc
blob: 5a233f3a75dfa423baad5d7c45cd6e384251028b (plain)
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
// Copyright (c) 2010 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.

#include "chrome/renderer/render_widget_fullscreen.h"

#include "chrome/common/render_messages.h"
#include "chrome/renderer/render_thread.h"
#include "third_party/WebKit/WebKit/chromium/public/WebWidget.h"

using WebKit::WebWidget;

// static
RenderWidgetFullscreen* RenderWidgetFullscreen::Create(
    int32 opener_id, RenderThreadBase* render_thread,
    WebKit::WebPopupType popup_type) {
  DCHECK_NE(MSG_ROUTING_NONE, opener_id);
  scoped_refptr<RenderWidgetFullscreen> widget(new RenderWidgetFullscreen(
      render_thread, popup_type));
  widget->Init(opener_id);
  return widget.release();
}

WebWidget* RenderWidgetFullscreen::CreateWebWidget() {
  // TODO(boliu): Handle full screen render widgets here.
  return RenderWidget::CreateWebWidget(this);
}

void RenderWidgetFullscreen::Init(int32 opener_id) {
  DCHECK(!webwidget_);

  RenderWidget::DoInit(
      opener_id,
      CreateWebWidget(),
      new ViewHostMsg_CreateFullscreenWidget(
          opener_id, popup_type_, &routing_id_));
}

void RenderWidgetFullscreen::show(WebKit::WebNavigationPolicy) {
  DCHECK(!did_show_) << "received extraneous Show call";
  DCHECK_NE(MSG_ROUTING_NONE, routing_id_);
  DCHECK_NE(MSG_ROUTING_NONE, opener_id_);

  if (!did_show_) {
    did_show_ = true;
    Send(new ViewHostMsg_ShowFullscreenWidget(opener_id_, routing_id_));
    SetPendingWindowRect(initial_pos_);
  }
}

RenderWidgetFullscreen::RenderWidgetFullscreen(RenderThreadBase* render_thread,
                                               WebKit::WebPopupType popup_type)
    : RenderWidget(render_thread, popup_type) {
}