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

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 popup_closing_(false),
35 external_delegate_(external_delegate),
36 web_contents_(web_contents) {
37 }
38
39 AutofillPopupViewViews::~AutofillPopupViewViews() {
40 if (!popup_closing_ && popup_.get())
41 popup_->Close();
42 external_delegate_->InvalidateView();
43 }
44
45 void AutofillPopupViewViews::OnPaint(gfx::Canvas* canvas) {
46 // TODO(csharp): Properly draw the popup.
47 canvas->DrawColor(kPopupBackground);
48 }
49
50 void AutofillPopupViewViews::WindowClosing() {
51 popup_closing_ = true;
52 }
53
54 void AutofillPopupViewViews::ShowInternal() {
55 if (!popup_.get()) {
56 // The widget is destroyed by the corresponding NativeWidget, so we use
57 // a weak pointer to hold the reference and don't have to worry about
58 // deletion.
59 popup_ = (new AutofillPopupWidget)->AsWeakPtr();
60 views::Widget::InitParams params(views::Widget::InitParams::TYPE_POPUP);
61 params.can_activate = false;
62 params.transparent = true;
63 params.parent = web_contents_->GetView()->GetTopLevelNativeWindow();
64 popup_->Init(params);
65 popup_->SetContentsView(this);
66 popup_->Show();
67
68 gfx::Rect client_area;
69 web_contents_->GetContainerBounds(&client_area);
70 popup_->SetBounds(client_area);
71 }
72
73 ResizePopup();
74
75 web_contents_->GetRenderViewHost()->AddKeyboardListener(this);
76 }
77
78 void AutofillPopupViewViews::HideInternal() {
79 web_contents_->GetRenderViewHost()->RemoveKeyboardListener(this);
80
81 if (popup_.get())
82 popup_->Close();
83 }
84
85 void AutofillPopupViewViews::InvalidateRow(size_t row) {
86 // TODO(csharp): invalidate this row.
87 }
88
89 void AutofillPopupViewViews::ResizePopup() {
90 gfx::Rect popup_bounds = element_bounds();
91 popup_bounds.set_y(popup_bounds.y() + popup_bounds.height());
92
93 SetBoundsRect(popup_bounds);
94 }
OLDNEW

Powered by Google App Engine
This is Rietveld 408576698