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

Side by Side Diff: chrome/browser/ui/autofill/password_generation_popup_controller_impl.h

Issue 707173004: Refactor Autofill for out of process iframes (OOPIF). (Closed) Base URL: https://chromium.googlesource.com/chromium/src.git@master
Patch Set: mem leak Created 6 years 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
OLDNEW
1 // Copyright 2014 The Chromium Authors. All rights reserved. 1 // Copyright 2014 The Chromium Authors. All rights reserved.
2 // Use of this source code is governed by a BSD-style license that can be 2 // Use of this source code is governed by a BSD-style license that can be
3 // found in the LICENSE file. 3 // found in the LICENSE file.
4 4
5 #ifndef CHROME_BROWSER_UI_AUTOFILL_PASSWORD_GENERATION_POPUP_CONTROLLER_IMPL_H_ 5 #ifndef CHROME_BROWSER_UI_AUTOFILL_PASSWORD_GENERATION_POPUP_CONTROLLER_IMPL_H_
6 #define CHROME_BROWSER_UI_AUTOFILL_PASSWORD_GENERATION_POPUP_CONTROLLER_IMPL_H_ 6 #define CHROME_BROWSER_UI_AUTOFILL_PASSWORD_GENERATION_POPUP_CONTROLLER_IMPL_H_
7 7
8 #include <string> 8 #include <string>
9 9
10 #include "base/basictypes.h" 10 #include "base/basictypes.h"
11 #include "base/memory/weak_ptr.h" 11 #include "base/memory/weak_ptr.h"
12 #include "chrome/browser/ui/autofill/password_generation_popup_controller.h" 12 #include "chrome/browser/ui/autofill/password_generation_popup_controller.h"
13 #include "chrome/browser/ui/autofill/popup_controller_common.h" 13 #include "chrome/browser/ui/autofill/popup_controller_common.h"
14 #include "components/autofill/core/common/password_form.h" 14 #include "components/autofill/core/common/password_form.h"
15 #include "ui/gfx/native_widget_types.h" 15 #include "ui/gfx/native_widget_types.h"
16 #include "ui/gfx/range/range.h" 16 #include "ui/gfx/range/range.h"
17 #include "ui/gfx/rect.h" 17 #include "ui/gfx/rect.h"
18 #include "ui/gfx/rect_f.h" 18 #include "ui/gfx/rect_f.h"
19 19
20 namespace content { 20 namespace content {
21 struct NativeWebKeyboardEvent; 21 struct NativeWebKeyboardEvent;
22 class WebContents; 22 class WebContents;
23 } 23 }
24 24
25 namespace password_manager { 25 namespace password_manager {
26 class PasswordManager; 26 class PasswordManager;
27 class PasswordManagerDriver;
27 } 28 }
28 29
29 namespace autofill { 30 namespace autofill {
30 31
31 class PasswordGenerator; 32 class PasswordGenerator;
32 class PasswordGenerationPopupObserver; 33 class PasswordGenerationPopupObserver;
33 class PasswordGenerationPopupView; 34 class PasswordGenerationPopupView;
34 35
35 // This class controls a PasswordGenerationPopupView. It is responsible for 36 // This class controls a PasswordGenerationPopupView. It is responsible for
36 // determining the location of the popup, handling keypress events while the 37 // determining the location of the popup, handling keypress events while the
37 // popup is active, and notifying both the renderer and the password manager 38 // popup is active, and notifying both the renderer and the password manager
38 // if the password is accepted. 39 // if the password is accepted.
39 class PasswordGenerationPopupControllerImpl 40 class PasswordGenerationPopupControllerImpl
40 : public PasswordGenerationPopupController { 41 : public PasswordGenerationPopupController {
41 public: 42 public:
42 // Create a controller or return |previous| if it is suitable. Will hide 43 // Create a controller or return |previous| if it is suitable. Will hide
43 // |previous| if it is not returned. |bounds| is the bounds of the element 44 // |previous| if it is not returned. |bounds| is the bounds of the element
44 // that we are showing the dropdown for in screen space. |form| is the 45 // that we are showing the dropdown for in screen space. |form| is the
45 // identifier for the form that we are filling, and is used to notify 46 // identifier for the form that we are filling, and is used to notify
46 // |password_manager| if the password is generated. |max_length| is used to 47 // |password_manager| if the password is generated. |max_length| is used to
47 // determine the length of the password shown. If not NULL, |observer| will 48 // determine the length of the password shown. If not NULL, |observer| will
48 // be notified of changes of the popup state. 49 // be notified of changes of the popup state.
49 static base::WeakPtr<PasswordGenerationPopupControllerImpl> GetOrCreate( 50 static base::WeakPtr<PasswordGenerationPopupControllerImpl> GetOrCreate(
50 base::WeakPtr<PasswordGenerationPopupControllerImpl> previous, 51 base::WeakPtr<PasswordGenerationPopupControllerImpl> previous,
51 const gfx::RectF& bounds, 52 const gfx::RectF& bounds,
52 const PasswordForm& form, 53 const PasswordForm& form,
53 int max_length, 54 int max_length,
54 password_manager::PasswordManager* password_manager, 55 password_manager::PasswordManager* password_manager,
56 password_manager::PasswordManagerDriver* driver,
55 PasswordGenerationPopupObserver* observer, 57 PasswordGenerationPopupObserver* observer,
56 content::WebContents* web_contents, 58 content::WebContents* web_contents,
57 gfx::NativeView container_view); 59 gfx::NativeView container_view);
58 ~PasswordGenerationPopupControllerImpl() override; 60 ~PasswordGenerationPopupControllerImpl() override;
59 61
60 // Create a PasswordGenerationPopupView if one doesn't already exist. 62 // Create a PasswordGenerationPopupView if one doesn't already exist.
61 // If |display_password| is true, a generated password is shown that can be 63 // If |display_password| is true, a generated password is shown that can be
62 // selected by the user. Otherwise just the text explaining generated 64 // selected by the user. Otherwise just the text explaining generated
63 // passwords is shown. Idempotent. 65 // passwords is shown. Idempotent.
64 void Show(bool display_password); 66 void Show(bool display_password);
65 67
66 // Hides the popup and destroys |this|. 68 // Hides the popup and destroys |this|.
67 void HideAndDestroy(); 69 void HideAndDestroy();
68 70
69 // Accessors. 71 // Accessors.
70 content::WebContents* web_contents() { 72 content::WebContents* web_contents() {
71 return controller_common_.web_contents(); 73 return controller_common_.web_contents();
72 } 74 }
73 75
74 protected: 76 protected:
75 PasswordGenerationPopupControllerImpl( 77 PasswordGenerationPopupControllerImpl(
76 const gfx::RectF& bounds, 78 const gfx::RectF& bounds,
77 const PasswordForm& form, 79 const PasswordForm& form,
78 int max_length, 80 int max_length,
79 password_manager::PasswordManager* password_manager, 81 password_manager::PasswordManager* password_manager,
82 password_manager::PasswordManagerDriver* driver,
80 PasswordGenerationPopupObserver* observer, 83 PasswordGenerationPopupObserver* observer,
81 content::WebContents* web_contents, 84 content::WebContents* web_contents,
82 gfx::NativeView container_view); 85 gfx::NativeView container_view);
83 86
84 // Handle to the popup. May be NULL if popup isn't showing. 87 // Handle to the popup. May be NULL if popup isn't showing.
85 PasswordGenerationPopupView* view_; 88 PasswordGenerationPopupView* view_;
86 89
87 private: 90 private:
88 // PasswordGenerationPopupController implementation: 91 // PasswordGenerationPopupController implementation:
89 void Hide() override; 92 void Hide() override;
(...skipping 24 matching lines...) Expand all
114 117
115 // Accept password if it's selected. 118 // Accept password if it's selected.
116 bool PossiblyAcceptPassword(); 119 bool PossiblyAcceptPassword();
117 120
118 // Get desired size of popup. Height depends on width because we do text 121 // Get desired size of popup. Height depends on width because we do text
119 // wrapping. 122 // wrapping.
120 void CalculateBounds(); 123 void CalculateBounds();
121 124
122 PasswordForm form_; 125 PasswordForm form_;
123 password_manager::PasswordManager* password_manager_; 126 password_manager::PasswordManager* password_manager_;
127 password_manager::PasswordManagerDriver* driver_;
124 128
125 // May be NULL. 129 // May be NULL.
126 PasswordGenerationPopupObserver* observer_; 130 PasswordGenerationPopupObserver* observer_;
127 131
128 // Controls how passwords are generated. 132 // Controls how passwords are generated.
129 scoped_ptr<PasswordGenerator> generator_; 133 scoped_ptr<PasswordGenerator> generator_;
130 134
131 // Contains common popup functionality. 135 // Contains common popup functionality.
132 PopupControllerCommon controller_common_; 136 PopupControllerCommon controller_common_;
133 137
(...skipping 12 matching lines...) Expand all
146 gfx::Rect popup_bounds_; 150 gfx::Rect popup_bounds_;
147 151
148 base::WeakPtrFactory<PasswordGenerationPopupControllerImpl> weak_ptr_factory_; 152 base::WeakPtrFactory<PasswordGenerationPopupControllerImpl> weak_ptr_factory_;
149 153
150 DISALLOW_COPY_AND_ASSIGN(PasswordGenerationPopupControllerImpl); 154 DISALLOW_COPY_AND_ASSIGN(PasswordGenerationPopupControllerImpl);
151 }; 155 };
152 156
153 } // namespace autofill 157 } // namespace autofill
154 158
155 #endif // CHROME_BROWSER_UI_AUTOFILL_PASSWORD_GENERATION_POPUP_CONTROLLER_IMPL_ H_ 159 #endif // CHROME_BROWSER_UI_AUTOFILL_PASSWORD_GENERATION_POPUP_CONTROLLER_IMPL_ H_
OLDNEW

Powered by Google App Engine
This is Rietveld 408576698