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

Unified Diff: chrome/browser/ui/views/autofill/autofill_popup_view_views.cc

Issue 10825324: Start of New Autofill UI for Windows (Closed) Base URL: svn://svn.chromium.org/chrome/trunk/src
Patch Set: Created 8 years, 4 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/autofill/autofill_popup_view_views.cc
diff --git a/chrome/browser/ui/views/autofill/autofill_popup_view_views.cc b/chrome/browser/ui/views/autofill/autofill_popup_view_views.cc
new file mode 100644
index 0000000000000000000000000000000000000000..0c887f3f5b602f6734b150f415c1709c54844054
--- /dev/null
+++ b/chrome/browser/ui/views/autofill/autofill_popup_view_views.cc
@@ -0,0 +1,88 @@
+// Copyright (c) 2012 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 "autofill_popup_view_views.h"
+
+#include "chrome/browser/autofill/autofill_external_delegate.h"
+#include "chrome/browser/ui/views/frame/browser_view.h"
+#include "content/public/browser/render_view_host.h"
+#include "content/public/browser/web_contents.h"
+#include "content/public/browser/web_contents_view.h"
+#include "ui/gfx/canvas.h"
+#include "ui/gfx/rect.h"
+
+namespace {
+const SkColor kPopupBackground = SkColorSetARGB(0xFF, 0x00, 0x00, 0x00);
+} // namespace
+
+class AutofillPopupViewViews::AutofillPopupWidget
+ : public views::Widget,
+ public base::SupportsWeakPtr<AutofillPopupWidget> {
+ public:
+ AutofillPopupWidget() {}
+ virtual ~AutofillPopupWidget() {}
+
+ private:
+ DISALLOW_COPY_AND_ASSIGN(AutofillPopupWidget);
+};
+
+AutofillPopupViewViews::AutofillPopupViewViews(
+ content::WebContents* web_contents,
+ AutofillExternalDelegate* external_delegate)
+ : AutofillPopupView(web_contents, external_delegate),
+ render_view_host_(web_contents->GetRenderViewHost()),
+ web_contents_(web_contents) {
+ SetVisible(false);
+}
+
+AutofillPopupViewViews::~AutofillPopupViewViews() {
+}
+
+void AutofillPopupViewViews::OnPaint(gfx::Canvas* canvas) {
+ // TODO(csharp): Properly draw the popup.
+ canvas->DrawColor(kPopupBackground);
+}
+
+void AutofillPopupViewViews::ShowInternal() {
+ if (popup_ == NULL) {
Ilya Sherman 2012/08/14 05:12:09 nit: if (!popup_) {
csharp 2012/08/14 19:06:13 Done.
+ BrowserView* browser_view = BrowserView::GetBrowserViewForNativeWindow(
+ web_contents_->GetView()->GetTopLevelNativeWindow());
+
+ popup_ = (new AutofillPopupWidget)->AsWeakPtr();
Ilya Sherman 2012/08/14 05:12:09 nit: Please add a brief comment here about the lif
csharp 2012/08/14 19:06:13 Comment added, let me know if it needs more detail
+ views::Widget::InitParams params(views::Widget::InitParams::TYPE_POPUP);
+ params.can_activate = false;
+ params.transparent = true;
+ params.parent_widget = browser_view->GetWidget();
+ popup_->Init(params);
+ popup_->SetContentsView(this);
+ popup_->Show();
+
+ gfx::Rect client_area;
+ web_contents_->GetContainerBounds(&client_area);
+ popup_->SetBounds(client_area);
+ }
+
+ ResizePopup();
+
+ render_view_host_->AddKeyboardListener(this);
+
+ SetVisible(true);
+}
+
+void AutofillPopupViewViews::HideInternal() {
+ render_view_host_->RemoveKeyboardListener(this);
+
+ SetVisible(false);
+}
+
+void AutofillPopupViewViews::InvalidateRow(size_t row) {
+ // TODO(csharp): invalidate this row.
+}
+
+void AutofillPopupViewViews::ResizePopup() {
+ gfx::Rect popup_bounds = element_bounds();
+ popup_bounds.set_y(popup_bounds.y() + element_bounds().height());
Ilya Sherman 2012/08/14 05:12:09 nit: It's a little weird to use popup_bounds.y() a
csharp 2012/08/14 19:06:13 Done.
+
+ SetBoundsRect(popup_bounds);
+}

Powered by Google App Engine
This is Rietveld 408576698