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

Side by Side 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 unified diff | Download patch | Annotate | Revision Log
OLDNEW
(Empty)
1 // Copyright (c) 2012 The Chromium Authors. All rights reserved.
2 // Use of this source code is governed by a BSD-style license that can be
3 // found in the LICENSE file.
4
5 #include "autofill_popup_view_views.h"
6
7 #include "chrome/browser/autofill/autofill_external_delegate.h"
8 #include "chrome/browser/ui/views/frame/browser_view.h"
9 #include "content/public/browser/render_view_host.h"
10 #include "content/public/browser/web_contents.h"
11 #include "content/public/browser/web_contents_view.h"
12 #include "ui/gfx/canvas.h"
13 #include "ui/gfx/rect.h"
14
15 namespace {
16 const SkColor kPopupBackground = SkColorSetARGB(0xFF, 0x00, 0x00, 0x00);
17 } // namespace
18
19 class AutofillPopupViewViews::AutofillPopupWidget
20 : public views::Widget,
21 public base::SupportsWeakPtr<AutofillPopupWidget> {
22 public:
23 AutofillPopupWidget() {}
24 virtual ~AutofillPopupWidget() {}
25
26 private:
27 DISALLOW_COPY_AND_ASSIGN(AutofillPopupWidget);
28 };
29
30 AutofillPopupViewViews::AutofillPopupViewViews(
31 content::WebContents* web_contents,
32 AutofillExternalDelegate* external_delegate)
33 : AutofillPopupView(web_contents, external_delegate),
34 web_contents_(web_contents) {
35 SetVisible(false);
36 }
37
38 AutofillPopupViewViews::~AutofillPopupViewViews() {
39 }
40
41 void AutofillPopupViewViews::OnPaint(gfx::Canvas* canvas) {
42 // TODO(csharp): Properly draw the popup.
43 canvas->DrawColor(kPopupBackground);
44 }
45
46 void AutofillPopupViewViews::ShowInternal() {
47 if (!popup_) {
48 BrowserView* browser_view = BrowserView::GetBrowserViewForNativeWindow(
49 web_contents_->GetView()->GetTopLevelNativeWindow());
50
51 // The widget is destory by the corresponding NativeWidget, so we use
Ilya Sherman 2012/08/14 19:27:12 nit: "destory" -> "destroyed" (though I kind of l
csharp 2012/08/15 19:39:58 Done.
52 // a weak pointer to hold the reference and don't have to worry about
53 // deletion.
54 popup_ = (new AutofillPopupWidget)->AsWeakPtr();
55 views::Widget::InitParams params(views::Widget::InitParams::TYPE_POPUP);
56 params.can_activate = false;
57 params.transparent = true;
58 params.parent_widget = browser_view->GetWidget();
59 popup_->Init(params);
60 popup_->SetContentsView(this);
61 popup_->Show();
62
63 gfx::Rect client_area;
64 web_contents_->GetContainerBounds(&client_area);
65 popup_->SetBounds(client_area);
66 }
67
68 ResizePopup();
69
70 web_contents_->GetRenderViewHost()->AddKeyboardListener(this);
71
72 SetVisible(true);
73 }
74
75 void AutofillPopupViewViews::HideInternal() {
76 web_contents_->GetRenderViewHost()->RemoveKeyboardListener(this);
77
78 SetVisible(false);
79 }
80
81 void AutofillPopupViewViews::InvalidateRow(size_t row) {
82 // TODO(csharp): invalidate this row.
83 }
84
85 void AutofillPopupViewViews::ResizePopup() {
86 gfx::Rect popup_bounds = element_bounds();
87 popup_bounds.set_y(popup_bounds.y() + popup_bounds.height());
88
89 SetBoundsRect(popup_bounds);
90 }
OLDNEW

Powered by Google App Engine
This is Rietveld 408576698