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

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

Issue 10442044: Fix the white flicker of the keyboard overlay when it first appearing. (Closed) Base URL: svn://svn.chromium.org/chrome/trunk/src
Patch Set: '' Created 8 years, 7 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/keyboard_overlay_delegate.cc
diff --git a/chrome/browser/ui/views/keyboard_overlay_delegate.cc b/chrome/browser/ui/views/keyboard_overlay_delegate.cc
index 56bcd6dab69a0441ad3b9b42ebc8e7d2fabf94a9..75e9c0986030befbff1fd039aaf3ae521820c072 100644
--- a/chrome/browser/ui/views/keyboard_overlay_delegate.cc
+++ b/chrome/browser/ui/views/keyboard_overlay_delegate.cc
@@ -7,8 +7,13 @@
#include <algorithm>
#include "base/utf_string_conversions.h"
-#include "chrome/browser/ui/views/web_dialog_view.h"
+#include "chrome/browser/ui/views/keyboard_overlay_dialog_view.h"
#include "chrome/common/url_constants.h"
+#include "content/public/browser/notification_source.h"
+#include "content/public/browser/notification_types.h"
+#include "content/public/browser/render_view_host.h"
+#include "content/public/browser/render_widget_host.h"
+#include "content/public/browser/web_contents.h"
#include "googleurl/src/gurl.h"
#include "grit/generated_resources.h"
#include "ui/base/l10n/l10n_util.h"
@@ -28,12 +33,39 @@ const int kHorizontalMargin = 28;
KeyboardOverlayDelegate::KeyboardOverlayDelegate(const string16& title)
: title_(title),
- view_(NULL) {
+ view_(NULL),
+ loaded_(false) {
}
KeyboardOverlayDelegate::~KeyboardOverlayDelegate() {
}
+void KeyboardOverlayDelegate::Show(KeyboardOverlayDialogView* view) {
+ view_ = view;
+
+ views::Widget* widget = new views::Widget;
+ views::Widget::InitParams params(
+ views::Widget::InitParams::TYPE_WINDOW_FRAMELESS);
+ params.delegate = view;
+ widget->Init(params);
+
+ // Show the widget at the bottom of the work area.
+ gfx::Size size;
+ GetDialogSize(&size);
+ gfx::Rect rect = gfx::Screen::GetMonitorNearestWindow(
oshima 2012/05/25 22:33:20 const gfx::Rect&
mazda 2012/05/25 23:30:37 Done.
+ widget->GetNativeView()).work_area();
+ gfx::Rect bounds((rect.width() - size.width()) / 2,
+ rect.height() - size.height(),
+ size.width(),
+ size.height());
+ widget->SetBounds(bounds);
+
+ widget->Show();
+
+ // Make the widget invisible until the web contents gets ready to display.
+ widget->SetOpacity(0);
+}
+
ui::ModalType KeyboardOverlayDelegate::GetDialogModalType() const {
return ui::MODAL_TYPE_SYSTEM;
}
@@ -66,6 +98,18 @@ std::string KeyboardOverlayDelegate::GetDialogArgs() const {
return "[]";
}
+void KeyboardOverlayDelegate::OnDialogShown(
+ content::WebUI* webui,
+ content::RenderViewHost* render_view_host) {
+ registrar_.Add(this,
+ content::NOTIFICATION_LOAD_COMPLETED_MAIN_FRAME,
+ content::Source<content::WebContents>(
+ webui->GetWebContents()));
+ registrar_.Add(this,
+ content::NOTIFICATION_RENDER_WIDGET_HOST_DID_PAINT,
+ content::Source<content::RenderWidgetHost>(render_view_host));
+}
+
void KeyboardOverlayDelegate::OnDialogClosed(
const std::string& json_retval) {
delete this;
@@ -84,3 +128,27 @@ bool KeyboardOverlayDelegate::HandleContextMenu(
const content::ContextMenuParams& params) {
return true;
}
+
+void KeyboardOverlayDelegate::Observe(
+ int type,
+ const content::NotificationSource& source,
+ const content::NotificationDetails& details) {
+ switch (type) {
+ case content::NOTIFICATION_LOAD_COMPLETED_MAIN_FRAME:
+ registrar_.Remove(this,
+ content::NOTIFICATION_LOAD_COMPLETED_MAIN_FRAME,
+ source);
+ loaded_ = true;
+ break;
+ case content::NOTIFICATION_RENDER_WIDGET_HOST_DID_PAINT:
oshima 2012/05/25 22:33:20 I wonder if we can rely on this notification when
mazda 2012/05/25 23:30:37 Thanks. I'll ask backer.
+ if (!loaded_)
+ break;
+ registrar_.Remove(this,
+ content::NOTIFICATION_RENDER_WIDGET_HOST_DID_PAINT,
+ source);
+ view_->GetWidget()->SetOpacity(255);
+ break;
+ default:
+ NOTREACHED() << "Unknown type: " << type;
+ }
+}
« no previous file with comments | « chrome/browser/ui/views/keyboard_overlay_delegate.h ('k') | chrome/browser/ui/views/keyboard_overlay_dialog_view.cc » ('j') | no next file with comments »

Powered by Google App Engine
This is Rietveld 408576698