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

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/ui/views/autofill/autofill_external_delegate_views.h"
8 #include "content/public/browser/render_view_host.h"
9 #include "content/public/browser/web_contents.h"
10 #include "content/public/browser/web_contents_view.h"
11 #include "ui/gfx/canvas.h"
12 #include "ui/gfx/rect.h"
13 #include "ui/views/widget/widget.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 AutofillExternalDelegateViews* external_delegate)
33 : AutofillPopupView(web_contents, external_delegate),
34 external_delegate_(external_delegate),
35 web_contents_(web_contents) {
36 }
37
38 AutofillPopupViewViews::~AutofillPopupViewViews() {
39 if (popup_.get())
40 popup_->Close();
41 external_delegate_->InvalidateView();
42 }
43
44 void AutofillPopupViewViews::OnPaint(gfx::Canvas* canvas) {
45 // TODO(csharp): Properly draw the popup.
46 canvas->DrawColor(kPopupBackground);
47 }
48
49 void AutofillPopupViewViews::ShowInternal() {
50 if (!popup_.get()) {
51 // The widget is destroyed by the corresponding NativeWidget, so we use
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 = web_contents_->GetView()->GetTopLevelNativeWindow();
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
73 void AutofillPopupViewViews::HideInternal() {
74 web_contents_->GetRenderViewHost()->RemoveKeyboardListener(this);
75
76 if (popup_.get())
77 popup_->Hide();
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