Chromium Code Reviews
chromiumcodereview-hr@appspot.gserviceaccount.com (chromiumcodereview-hr) | Please choose your nickname with Settings | Help | Chromium Project | Gerrit Changes | Sign out
(6850)

Unified Diff: chrome/browser/ui/views/html_dialog_view.cc

Issue 7024032: Wait showing html dialog until renderer finish painting after page is loaded. (Closed) Base URL: svn://svn.chromium.org/chrome/trunk/src
Patch Set: " Created 9 years, 6 months ago
Use n/p to move between diff chunks; N/P to move between comments. Draft comments are only viewable by you.
Jump to:
View side-by-side diff with in-line comments
Download patch
Index: chrome/browser/ui/views/html_dialog_view.cc
diff --git a/chrome/browser/ui/views/html_dialog_view.cc b/chrome/browser/ui/views/html_dialog_view.cc
index 67341f2131202dc95c68e81a86732ccfdaec7f0b..fe83915e7a1ae869e334768cf28991dfa7cd9dc7 100644
--- a/chrome/browser/ui/views/html_dialog_view.cc
+++ b/chrome/browser/ui/views/html_dialog_view.cc
@@ -10,6 +10,9 @@
#include "chrome/browser/ui/views/window.h"
#include "content/browser/tab_contents/tab_contents.h"
#include "content/common/native_web_keyboard_event.h"
+#include "content/common/notification_details.h"
+#include "content/common/notification_source.h"
+#include "content/common/notification_type.h"
#include "ui/base/keycodes/keyboard_codes.h"
#include "views/events/event.h"
#include "views/widget/root_view.h"
@@ -20,6 +23,8 @@
#include "views/window/native_window_gtk.h"
#endif
+class RenderWidgetHost;
+
namespace browser {
// Declared in browser_dialogs.h so that others don't need to depend on our .h.
@@ -42,6 +47,7 @@ HtmlDialogView::HtmlDialogView(Profile* profile,
HtmlDialogUIDelegate* delegate)
: DOMView(),
HtmlDialogTabContentsDelegate(profile),
+ state_(NONE),
delegate_(delegate) {
}
@@ -66,6 +72,20 @@ bool HtmlDialogView::AcceleratorPressed(const views::Accelerator& accelerator) {
return true;
}
+void HtmlDialogView::ViewHierarchyChanged(
+ bool is_add, View* parent, View* child) {
+ DOMView::ViewHierarchyChanged(is_add, parent, child);
+ if (is_add && GetWidget() && state_ == NONE) {
+ state_ = INITIALIZED;
+#if defined(OS_CHROMEOS)
sky 2011/06/07 15:41:17 Should the ifdefs be OS_LINUX?
oshima 2011/06/07 19:08:58 This make sense only with chromeos wm. Note that t
+ CHECK(
+ static_cast<views::NativeWidgetGtk*>(
+ GetWidget()->native_widget())->SuppressFreezeUpdates());
+#endif
+ RegisterDialogAccelerators();
+ }
+}
+
////////////////////////////////////////////////////////////////////////////////
// HtmlDialogView, views::WindowDelegate implementation:
@@ -222,9 +242,44 @@ void HtmlDialogView::InitDialog() {
// the comment above HtmlDialogUI in its header file for why.
HtmlDialogUI::GetPropertyAccessor().SetProperty(tab_contents_->property_bag(),
this);
+ notification_registrar_.Add(
+ this,
+ NotificationType::RENDER_VIEW_HOST_CREATED_FOR_TAB,
+ Source<TabContents>(tab_contents()));
+ notification_registrar_.Add(
+ this,
+ NotificationType::LOAD_COMPLETED_MAIN_FRAME,
+ Source<TabContents>(tab_contents()));
+
+ DOMView::LoadURL(GetDialogContentURL());
+}
+void HtmlDialogView::Observe(NotificationType type,
+ const NotificationSource& source,
+ const NotificationDetails& details) {
+ if (type == NotificationType::RENDER_VIEW_HOST_CREATED_FOR_TAB) {
sky 2011/06/07 15:41:17 nit: a switch would be more readable here.
oshima 2011/06/07 19:08:58 Done.
+ RenderWidgetHost* rwh = Details<RenderWidgetHost>(details).ptr();
+ notification_registrar_.Add(
+ this,
+ NotificationType::RENDER_WIDGET_HOST_DID_PAINT,
+ Source<RenderWidgetHost>(rwh));
+ return;
+ }
+
+ if (type == NotificationType::LOAD_COMPLETED_MAIN_FRAME &&
+ state_ == INITIALIZED) {
+ state_ = LOADED;
+ } else if (type == NotificationType::RENDER_WIDGET_HOST_DID_PAINT &&
+ state_ == LOADED) {
+ state_ = PAINTED;
+#if defined(OS_CHROMEOS)
+ views::NativeWidgetGtk::UpdateFreezeUpdatesProperty(
+ GTK_WINDOW(GetWidget()->GetNativeView()), false);
+#endif
+ }
+}
+
+void HtmlDialogView::RegisterDialogAccelerators() {
// Pressing the ESC key will close the dialog.
AddAccelerator(views::Accelerator(ui::VKEY_ESCAPE, false, false, false));
-
- DOMView::LoadURL(GetDialogContentURL());
}

Powered by Google App Engine
This is Rietveld 408576698