Commit eb8403c9 authored by xiyuan@chromium.org's avatar xiyuan@chromium.org

[ChromeOS] Freezes WebUI OOBE/Login window until tab is rendered.

Manually unfreezes hosting window until WebUI OOBE/Login tab is rendered the first time to avoid the white screen when transitioning from boot splash.

This CL is based Oshima's r88345 and I have left a TODO to merge the logic.

BUG=chromium-os:18501
TEST=Verify fix for chromium-os:18501.


Review URL: http://codereview.chromium.org/7607011

git-svn-id: svn://svn.chromium.org/chrome/trunk/src@96132 0039d316-1c4b-4281-b951-d872f2087c98
parent 1b5f69a1
......@@ -51,6 +51,7 @@ class WebUILoginDisplayHost : public BaseLoginDisplayHost {
// Container of the screen we are displaying.
views::Widget* login_window_;
// Container of the view we are displaying.
WebUILoginView* login_view_;
......
......@@ -17,6 +17,7 @@
#include "content/browser/tab_contents/tab_contents.h"
#include "ui/gfx/rect.h"
#include "ui/gfx/size.h"
#include "views/widget/native_widget_gtk.h"
#include "views/widget/widget.h"
namespace {
......@@ -40,7 +41,8 @@ WebUILoginView::WebUILoginView()
: status_area_(NULL),
profile_(NULL),
webui_login_(NULL),
status_window_(NULL) {
status_window_(NULL),
host_window_frozen_(false) {
accel_map_[views::Accelerator(ui::VKEY_Z, false, true, true)] =
kAccelNameAccessibility;
accel_map_[views::Accelerator(ui::VKEY_E, false, true, true)] =
......@@ -64,6 +66,9 @@ void WebUILoginView::Init() {
webui_login_->Init(profile_, NULL);
webui_login_->SetVisible(true);
webui_login_->tab_contents()->set_delegate(this);
tab_watcher_.reset(new TabFirstRenderWatcher(webui_login_->tab_contents(),
this));
}
std::string WebUILoginView::GetClassName() const {
......@@ -94,7 +99,9 @@ gfx::NativeWindow WebUILoginView::GetNativeWindow() const {
}
void WebUILoginView::OnWindowCreated() {
InitStatusArea();
// Freezes host window update until the tab is rendered.
host_window_frozen_ = static_cast<views::NativeWidgetGtk*>(
GetWidget()->native_widget())->SuppressFreezeUpdates();
}
void WebUILoginView::UpdateWindowType() {
......@@ -186,6 +193,21 @@ void WebUILoginView::OnLocaleChanged() {
SchedulePaint();
}
void WebUILoginView::OnTabMainFrameLoaded() {
}
void WebUILoginView::OnTabMainFrameFirstRender() {
InitStatusArea();
if (host_window_frozen_) {
host_window_frozen_ = false;
// Unfreezes the host window since tab is rendereed now.
views::NativeWidgetGtk::UpdateFreezeUpdatesProperty(
GetNativeWindow(), false);
}
}
void WebUILoginView::InitStatusArea() {
DCHECK(status_area_ == NULL);
DCHECK(status_window_ == NULL);
......
......@@ -8,6 +8,7 @@
#include "chrome/browser/chromeos/login/login_html_dialog.h"
#include "chrome/browser/chromeos/status/status_area_host.h"
#include "chrome/browser/chromeos/tab_first_render_watcher.h"
#include "chrome/browser/ui/views/unhandled_keyboard_event_handler.h"
#include "content/browser/tab_contents/tab_contents_delegate.h"
#include "views/view.h"
......@@ -24,6 +25,7 @@ class Widget;
namespace chromeos {
class StatusAreaView;
class TabFirstRenderWatcher;
// View used to render a WebUI supporting Widget. This widget is used for the
// WebUI based start up and lock screens. It contains a StatusAreaView and
......@@ -31,7 +33,8 @@ class StatusAreaView;
class WebUILoginView : public views::View,
public StatusAreaHost,
public TabContentsDelegate,
public chromeos::LoginHtmlDialog::Delegate {
public chromeos::LoginHtmlDialog::Delegate,
public TabFirstRenderWatcher::Delegate {
public:
static const int kStatusAreaCornerPadding;
......@@ -87,6 +90,10 @@ class WebUILoginView : public views::View,
virtual void OnDialogClosed() OVERRIDE;
virtual void OnLocaleChanged() OVERRIDE;
// TabFirstRenderWatcher::Delegate implementation.
virtual void OnTabMainFrameLoaded() OVERRIDE;
virtual void OnTabMainFrameFirstRender() OVERRIDE;
// Creates and adds the status area (separate window).
virtual void InitStatusArea();
......@@ -120,6 +127,12 @@ class WebUILoginView : public views::View,
// Proxy settings dialog that can be invoked from network menu.
scoped_ptr<LoginHtmlDialog> proxy_settings_dialog_;
// Watches webui_login_'s TabContents rendering.
scoped_ptr<TabFirstRenderWatcher> tab_watcher_;
// Whether the host window is frozen.
bool host_window_frozen_;
DISALLOW_COPY_AND_ASSIGN(WebUILoginView);
};
......
// Copyright (c) 2011 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/browser/chromeos/tab_first_render_watcher.h"
#include "content/browser/renderer_host/render_widget_host.h"
#include "content/common/content_notification_types.h"
#include "content/common/notification_details.h"
#include "content/common/notification_source.h"
namespace chromeos {
TabFirstRenderWatcher::TabFirstRenderWatcher(TabContents* tab,
Delegate* delegate)
: state_(NONE),
tab_contents_(tab),
delegate_(delegate) {
registrar_.Add(this,
content::NOTIFICATION_RENDER_VIEW_HOST_CREATED_FOR_TAB,
Source<TabContents>(tab_contents_));
registrar_.Add(this,
content::NOTIFICATION_LOAD_COMPLETED_MAIN_FRAME,
Source<TabContents>(tab_contents_));
}
void TabFirstRenderWatcher::Observe(int type,
const NotificationSource& source, const NotificationDetails& details) {
switch (type) {
case content::NOTIFICATION_RENDER_VIEW_HOST_CREATED_FOR_TAB: {
RenderWidgetHost* rwh = Details<RenderWidgetHost>(details).ptr();
registrar_.Add(this,
content::NOTIFICATION_RENDER_WIDGET_HOST_DID_PAINT,
Source<RenderWidgetHost>(rwh));
break;
}
case content::NOTIFICATION_LOAD_COMPLETED_MAIN_FRAME:
if (state_ == NONE) {
state_ = LOADED;
delegate_->OnTabMainFrameLoaded();
}
break;
case content::NOTIFICATION_RENDER_WIDGET_HOST_DID_PAINT:
if (state_ == LOADED) {
state_ = FIRST_PAINT;
delegate_->OnTabMainFrameFirstRender();
}
break;
default:
NOTREACHED() << "unknown type" << type;
}
}
} // namespace chromeos
// Copyright (c) 2011 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 CHROME_BROWSER_CHROMEOS_TAB_FIRST_RENDER_WATCHER_H_
#define CHROME_BROWSER_CHROMEOS_TAB_FIRST_RENDER_WATCHER_H_
#pragma once
#include "base/compiler_specific.h"
#include "content/common/notification_observer.h"
#include "content/common/notification_registrar.h"
class TabContents;
namespace chromeos {
// This class watches given TabContent's loading and rendering state change.
// TODO(xiyuan): Move this to a proper place and share with HTMLDialogView.
class TabFirstRenderWatcher : public NotificationObserver {
public:
class Delegate {
public:
virtual void OnTabMainFrameLoaded() = 0;
virtual void OnTabMainFrameFirstRender() = 0;
};
TabFirstRenderWatcher(TabContents* tab, Delegate* delegate);
private:
// Overridden from NotificationObserver
virtual void Observe(int type,
const NotificationSource& source,
const NotificationDetails& details) OVERRIDE;
enum State {
NONE,
LOADED, // Renderer loaded the page.
FIRST_PAINT, // 1st paint event after the page is loaded.
};
State state_;
// TabContents that this class watches.
TabContents* tab_contents_;
// Delegate to notify.
Delegate* delegate_;
NotificationRegistrar registrar_;
DISALLOW_COPY_AND_ASSIGN(TabFirstRenderWatcher);
};
} // namespace chromeos
#endif // CHROME_BROWSER_CHROMEOS_TAB_FIRST_RENDER_WATCHER_H_
......@@ -751,6 +751,8 @@
'browser/chromeos/system_key_event_listener.h',
'browser/chromeos/tab_closeable_state_watcher.cc',
'browser/chromeos/tab_closeable_state_watcher.h',
'browser/chromeos/tab_first_render_watcher.cc',
'browser/chromeos/tab_first_render_watcher.h',
'browser/chromeos/update_observer.cc',
'browser/chromeos/update_observer.h',
'browser/chromeos/upgrade_detector_chromeos.cc',
......
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