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

Side by Side Diff: chrome/renderer/password_autocomplete_manager.h

Issue 6151011: Introduce RenderView::Observer interface so that RenderView doesn't have to k... (Closed) Base URL: svn://chrome-svn/chrome/trunk/src/
Patch Set: '' Created 9 years, 11 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
1 // Copyright (c) 2010 The Chromium Authors. All rights reserved. 1 // Copyright (c) 2010 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_RENDERER_PASSWORD_AUTOCOMPLETE_MANAGER_H_ 5 #ifndef CHROME_RENDERER_PASSWORD_AUTOCOMPLETE_MANAGER_H_
6 #define CHROME_RENDERER_PASSWORD_AUTOCOMPLETE_MANAGER_H_ 6 #define CHROME_RENDERER_PASSWORD_AUTOCOMPLETE_MANAGER_H_
7 #pragma once 7 #pragma once
8 8
9 #include <map> 9 #include <map>
10 #include <vector> 10 #include <vector>
11 11
12 #include "base/task.h" 12 #include "base/task.h"
13 #include "chrome/renderer/page_click_listener.h" 13 #include "chrome/renderer/page_click_listener.h"
14 #include "chrome/renderer/render_view.h"
14 #include "webkit/glue/password_form_dom_manager.h" 15 #include "webkit/glue/password_form_dom_manager.h"
15 #include "third_party/WebKit/WebKit/chromium/public/WebInputElement.h" 16 #include "third_party/WebKit/WebKit/chromium/public/WebInputElement.h"
16 17
17 class RenderView;
18 namespace WebKit {
19 class WebKeyboardEvent;
20 class WebView;
21 }
22 18
23 // This class is responsible for filling password forms. 19 // This class is responsible for filling password forms.
24 // There is one PasswordAutocompleteManager per RenderView. 20 // There is one PasswordAutocompleteManager per RenderView.
25 class PasswordAutocompleteManager : public PageClickListener { 21 class PasswordAutocompleteManager : public RenderView::Observer,
22 public PageClickListener {
26 public: 23 public:
27 explicit PasswordAutocompleteManager(RenderView* render_view); 24 explicit PasswordAutocompleteManager(RenderView* render_view);
28 virtual ~PasswordAutocompleteManager(); 25 virtual ~PasswordAutocompleteManager();
29 26
30 // Invoked by the renderer when it receives the password info from the
31 // browser. This triggers a password autocomplete (if wait_for_username is
32 // false on |form_data|).
33 void ReceivedPasswordFormFillData(WebKit::WebView* view,
34 const webkit_glue::PasswordFormFillData& form_data);
35
36 // Invoked when the passed frame is closing. Gives us a chance to clear any 27 // Invoked when the passed frame is closing. Gives us a chance to clear any
37 // reference we may have to elements in that frame. 28 // reference we may have to elements in that frame.
38 void FrameClosing(const WebKit::WebFrame* frame); 29 void FrameClosing(const WebKit::WebFrame* frame);
39 30
40 // Fills the password associated with |user_input|, using its current value 31 // Fills the password associated with |user_input|, using its current value
41 // as the actual user name. Returns true if the password field was filled, 32 // as the actual user name. Returns true if the password field was filled,
42 // false otherwise, typically if there was no matching suggestions for the 33 // false otherwise, typically if there was no matching suggestions for the
43 // currently typed username. 34 // currently typed username.
44 bool FillPassword(const WebKit::WebInputElement& user_input); 35 bool FillPassword(const WebKit::WebInputElement& user_input);
45 36
46 // Fills |login_input| and |password| with the most relevant suggestion from 37 // Fills |login_input| and |password| with the most relevant suggestion from
47 // |fill_data| and shows a popup with other suggestions. 38 // |fill_data| and shows a popup with other suggestions.
48 void PerformInlineAutocomplete( 39 void PerformInlineAutocomplete(
49 const WebKit::WebInputElement& username, 40 const WebKit::WebInputElement& username,
50 const WebKit::WebInputElement& password, 41 const WebKit::WebInputElement& password,
51 const webkit_glue::PasswordFormFillData& fill_data); 42 const webkit_glue::PasswordFormFillData& fill_data);
52 43
53 // Scans the given frame for password forms and sends them up to the browser.
54 // If |only_visible| is true, only forms visible in the layout are sent.
55 void SendPasswordForms(WebKit::WebFrame* frame, bool only_visible);
56
57 // WebViewClient editor related calls forwarded by the RenderView. 44 // WebViewClient editor related calls forwarded by the RenderView.
58 // If they return true, it indicates the event was consumed and should not 45 // If they return true, it indicates the event was consumed and should not
59 // be used for any other autofill activity. 46 // be used for any other autofill activity.
60 bool TextFieldDidEndEditing(const WebKit::WebInputElement& element); 47 bool TextFieldDidEndEditing(const WebKit::WebInputElement& element);
61 bool TextDidChangeInTextField(const WebKit::WebInputElement& element); 48 bool TextDidChangeInTextField(const WebKit::WebInputElement& element);
62 void TextFieldHandlingKeyDown(const WebKit::WebInputElement& element, 49 void TextFieldHandlingKeyDown(const WebKit::WebInputElement& element,
63 const WebKit::WebKeyboardEvent& event); 50 const WebKit::WebKeyboardEvent& event);
64 51
65 private: 52 private:
66 struct PasswordInfo { 53 struct PasswordInfo {
67 WebKit::WebInputElement password_field; 54 WebKit::WebInputElement password_field;
68 webkit_glue::PasswordFormFillData fill_data; 55 webkit_glue::PasswordFormFillData fill_data;
69 bool backspace_pressed_last; 56 bool backspace_pressed_last;
70 PasswordInfo() : backspace_pressed_last(false) {} 57 PasswordInfo() : backspace_pressed_last(false) {}
71 }; 58 };
72 typedef std::map<WebKit::WebElement, PasswordInfo> LoginToPasswordInfoMap; 59 typedef std::map<WebKit::WebElement, PasswordInfo> LoginToPasswordInfoMap;
73 60
61 // RenderView::Observer implementation.
62 virtual bool OnMessageReceived(const IPC::Message& message);
63 virtual void DidFinishDocumentLoad(WebKit::WebFrame* frame);
64 virtual void DidFinishLoad(WebKit::WebFrame* frame);
65
74 // PageClickListener implementation: 66 // PageClickListener implementation:
75 virtual bool InputElementClicked(const WebKit::WebInputElement& element, 67 virtual bool InputElementClicked(const WebKit::WebInputElement& element,
76 bool was_focused, 68 bool was_focused,
77 bool is_focused); 69 bool is_focused);
78 70
71 void OnFillPasswordForm(
72 const webkit_glue::PasswordFormFillData& form_data);
73
74 // Scans the given frame for password forms and sends them up to the browser.
75 // If |only_visible| is true, only forms visible in the layout are sent.
76 void SendPasswordForms(WebKit::WebFrame* frame, bool only_visible);
77
79 void GetSuggestions( 78 void GetSuggestions(
80 const webkit_glue::PasswordFormFillData& fill_data, 79 const webkit_glue::PasswordFormFillData& fill_data,
81 const string16& input, 80 const string16& input,
82 std::vector<string16>* suggestions); 81 std::vector<string16>* suggestions);
83 82
84 bool ShowSuggestionPopup( 83 bool ShowSuggestionPopup(
85 const webkit_glue::PasswordFormFillData& fill_data, 84 const webkit_glue::PasswordFormFillData& fill_data,
86 const WebKit::WebInputElement& user_input); 85 const WebKit::WebInputElement& user_input);
87 86
88 bool FillUserNameAndPassword( 87 bool FillUserNameAndPassword(
89 WebKit::WebInputElement* username_element, 88 WebKit::WebInputElement* username_element,
90 WebKit::WebInputElement* password_element, 89 WebKit::WebInputElement* password_element,
91 const webkit_glue::PasswordFormFillData& fill_data, 90 const webkit_glue::PasswordFormFillData& fill_data,
92 bool exact_username_match); 91 bool exact_username_match);
93 92
94 // Convenience method that returns the routing ID of the render view we are
95 // associated with.
96 int GetRoutingID() const;
97
98 // Weak reference.
99 RenderView* render_view_;
100
101 // The logins we have filled so far with their associated info. 93 // The logins we have filled so far with their associated info.
102 LoginToPasswordInfoMap login_to_password_info_; 94 LoginToPasswordInfoMap login_to_password_info_;
103 95
104 ScopedRunnableMethodFactory<PasswordAutocompleteManager> method_factory_; 96 ScopedRunnableMethodFactory<PasswordAutocompleteManager> method_factory_;
105 97
106 DISALLOW_COPY_AND_ASSIGN(PasswordAutocompleteManager); 98 DISALLOW_COPY_AND_ASSIGN(PasswordAutocompleteManager);
107 }; 99 };
108 100
109 #endif // CHROME_RENDERER_PASSWORD_AUTOCOMPLETE_MANAGER_H_ 101 #endif // CHROME_RENDERER_PASSWORD_AUTOCOMPLETE_MANAGER_H_
OLDNEW

Powered by Google App Engine
This is Rietveld 408576698