summaryrefslogtreecommitdiffstats
diff options
context:
space:
mode:
authorxiyuan@chromium.org <xiyuan@chromium.org@0039d316-1c4b-4281-b951-d872f2087c98>2011-08-10 05:38:56 +0000
committerxiyuan@chromium.org <xiyuan@chromium.org@0039d316-1c4b-4281-b951-d872f2087c98>2011-08-10 05:38:56 +0000
commiteb8403c9511fff1ea4224644b559a4eeee1885d9 (patch)
tree99a65a13ae267e956646df8eb503df3d5d7325e2
parent1b5f69a1bc11fe1670f994c80a2ae32247c8e549 (diff)
downloadchromium_src-eb8403c9511fff1ea4224644b559a4eeee1885d9.zip
chromium_src-eb8403c9511fff1ea4224644b559a4eeee1885d9.tar.gz
chromium_src-eb8403c9511fff1ea4224644b559a4eeee1885d9.tar.bz2
[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
-rw-r--r--chrome/browser/chromeos/login/webui_login_display_host.h1
-rw-r--r--chrome/browser/chromeos/login/webui_login_view.cc26
-rw-r--r--chrome/browser/chromeos/login/webui_login_view.h15
-rw-r--r--chrome/browser/chromeos/tab_first_render_watcher.cc54
-rw-r--r--chrome/browser/chromeos/tab_first_render_watcher.h55
-rw-r--r--chrome/chrome_browser.gypi2
6 files changed, 150 insertions, 3 deletions
diff --git a/chrome/browser/chromeos/login/webui_login_display_host.h b/chrome/browser/chromeos/login/webui_login_display_host.h
index 2d5f124..9983acc 100644
--- a/chrome/browser/chromeos/login/webui_login_display_host.h
+++ b/chrome/browser/chromeos/login/webui_login_display_host.h
@@ -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_;
diff --git a/chrome/browser/chromeos/login/webui_login_view.cc b/chrome/browser/chromeos/login/webui_login_view.cc
index 5091cb1..ba4c0af 100644
--- a/chrome/browser/chromeos/login/webui_login_view.cc
+++ b/chrome/browser/chromeos/login/webui_login_view.cc
@@ -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);
diff --git a/chrome/browser/chromeos/login/webui_login_view.h b/chrome/browser/chromeos/login/webui_login_view.h
index 20c02f1..2c5b13b 100644
--- a/chrome/browser/chromeos/login/webui_login_view.h
+++ b/chrome/browser/chromeos/login/webui_login_view.h
@@ -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);
};
diff --git a/chrome/browser/chromeos/tab_first_render_watcher.cc b/chrome/browser/chromeos/tab_first_render_watcher.cc
new file mode 100644
index 0000000..fecb253
--- /dev/null
+++ b/chrome/browser/chromeos/tab_first_render_watcher.cc
@@ -0,0 +1,54 @@
+// 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
diff --git a/chrome/browser/chromeos/tab_first_render_watcher.h b/chrome/browser/chromeos/tab_first_render_watcher.h
new file mode 100644
index 0000000..9f87051
--- /dev/null
+++ b/chrome/browser/chromeos/tab_first_render_watcher.h
@@ -0,0 +1,55 @@
+// 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_
diff --git a/chrome/chrome_browser.gypi b/chrome/chrome_browser.gypi
index b30f1cb..10546bd 100644
--- a/chrome/chrome_browser.gypi
+++ b/chrome/chrome_browser.gypi
@@ -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',