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

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
sky 2012/08/28 15:51:37 The ownership is still slightly wrong here. Rememb
csharp 2012/08/29 17:19:38 Ok, I removed the weak_ptr support. InvalidateView
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.delegate = this;
62 params.can_activate = false;
63 params.transparent = true;
64 params.parent = web_contents_->GetView()->GetTopLevelNativeWindow();
65 popup_->Init(params);
66 popup_->SetContentsView(this);
67 popup_->Show();
68
69 gfx::Rect client_area;
70 web_contents_->GetContainerBounds(&client_area);
71 popup_->SetBounds(client_area);
72 }
73
74 ResizePopup();
75
76 web_contents_->GetRenderViewHost()->AddKeyboardListener(this);
77 }
78
79 void AutofillPopupViewViews::HideInternal() {
80 web_contents_->GetRenderViewHost()->RemoveKeyboardListener(this);
81
82 if (popup_.get())
83 popup_->Close();
84 }
85
86 void AutofillPopupViewViews::InvalidateRow(size_t row) {
87 // TODO(csharp): invalidate this row.
88 }
89
90 void AutofillPopupViewViews::ResizePopup() {
91 gfx::Rect popup_bounds = element_bounds();
92 popup_bounds.set_y(popup_bounds.y() + popup_bounds.height());
93
94 SetBoundsRect(popup_bounds);
95 }
OLDNEW
« no previous file with comments | « chrome/browser/ui/views/autofill/autofill_popup_view_views.h ('k') | chrome/chrome_browser.gypi » ('j') | no next file with comments »

Powered by Google App Engine
This is Rietveld 408576698