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

Side by Side Diff: chrome/browser/ui/webui/options/password_manager_handler.h

Issue 1193143003: Enable import/export of passwords into/from Password Manager (Closed) Base URL: https://chromium.googlesource.com/chromium/src.git@master
Patch Set: Removed import-complete dialog. Created 4 years, 9 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
OLDNEW
1 // Copyright 2013 The Chromium Authors. All rights reserved. 1 // Copyright 2013 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_WEBUI_OPTIONS_PASSWORD_MANAGER_HANDLER_H_ 5 #ifndef CHROME_BROWSER_UI_WEBUI_OPTIONS_PASSWORD_MANAGER_HANDLER_H_
6 #define CHROME_BROWSER_UI_WEBUI_OPTIONS_PASSWORD_MANAGER_HANDLER_H_ 6 #define CHROME_BROWSER_UI_WEBUI_OPTIONS_PASSWORD_MANAGER_HANDLER_H_
7 7
8 #include <stddef.h> 8 #include <stddef.h>
9 9
10 #include <string> 10 #include <string>
11 #include <vector> 11 #include <vector>
12 12
13 #include "base/gtest_prod_util.h"
13 #include "base/macros.h" 14 #include "base/macros.h"
14 #include "build/build_config.h" 15 #include "build/build_config.h"
15 #include "chrome/browser/ui/passwords/password_manager_presenter.h" 16 #include "chrome/browser/ui/passwords/password_manager_presenter.h"
16 #include "chrome/browser/ui/passwords/password_ui_view.h" 17 #include "chrome/browser/ui/passwords/password_ui_view.h"
17 #include "chrome/browser/ui/webui/options/options_ui.h" 18 #include "chrome/browser/ui/webui/options/options_ui.h"
19 #include "components/password_manager/core/browser/import/password_importer.h"
18 #include "components/prefs/pref_member.h" 20 #include "components/prefs/pref_member.h"
21 #include "ui/shell_dialogs/select_file_dialog.h"
22
23 class PasswordManagerHandlerTest;
19 24
20 namespace options { 25 namespace options {
21 26
22 // The WebUI based PasswordUIView. Displays passwords in the web ui. 27 // The WebUI based PasswordUIView. Displays passwords in the web ui.
23 class PasswordManagerHandler : public OptionsPageUIHandler, 28 class PasswordManagerHandler : public OptionsPageUIHandler,
24 public PasswordUIView { 29 public PasswordUIView,
30 public ui::SelectFileDialog::Listener {
25 public: 31 public:
26 PasswordManagerHandler(); 32 PasswordManagerHandler();
33 explicit PasswordManagerHandler(PasswordManagerPresenter* presenter);
vabr (Chromium) 2016/03/10 10:53:31 Also, please mark this constructor as "just for te
vabr (Chromium) 2016/03/10 10:53:32 Please change this from taking a raw pointer to ta
xunlu 2016/03/16 07:23:58 Done.
xunlu 2016/03/16 07:23:58 Done.
27 ~PasswordManagerHandler() override; 34 ~PasswordManagerHandler() override;
28 35
29 // OptionsPageUIHandler implementation. 36 // OptionsPageUIHandler implementation.
30 void GetLocalizedValues(base::DictionaryValue* localized_strings) override; 37 void GetLocalizedValues(base::DictionaryValue* localized_strings) override;
31 void InitializeHandler() override; 38 void InitializeHandler() override;
39 void InitializePage() override;
32 void RegisterMessages() override; 40 void RegisterMessages() override;
33 41
42 // ui::SelectFileDialog::Listener implementation
43 void FileSelected(const base::FilePath& path,
44 int index,
45 void* params) override;
46
34 // PasswordUIView implementation. 47 // PasswordUIView implementation.
35 Profile* GetProfile() override; 48 Profile* GetProfile() override;
36 void ShowPassword( 49 void ShowPassword(
37 size_t index, 50 size_t index,
38 const std::string& origin_url, 51 const std::string& origin_url,
39 const std::string& username, 52 const std::string& username,
40 const base::string16& password_value) override; 53 const base::string16& password_value) override;
41 void SetPasswordList( 54 void SetPasswordList(
42 const std::vector<scoped_ptr<autofill::PasswordForm>>& password_list, 55 const std::vector<scoped_ptr<autofill::PasswordForm>>& password_list,
43 bool show_passwords) override; 56 bool show_passwords) override;
44 void SetPasswordExceptionList( 57 void SetPasswordExceptionList(
45 const std::vector<scoped_ptr<autofill::PasswordForm>>& 58 const std::vector<scoped_ptr<autofill::PasswordForm>>&
46 password_exception_list) override; 59 password_exception_list) override;
47 #if !defined(OS_ANDROID) 60 #if !defined(OS_ANDROID)
48 gfx::NativeWindow GetNativeWindow() const override; 61 gfx::NativeWindow GetNativeWindow() const override;
49 #endif 62 #endif
50 private: 63 private:
64 friend class ::PasswordManagerHandlerTest;
vabr (Chromium) 2016/03/10 10:53:31 What private access does the test require? If it i
xunlu 2016/03/16 07:23:58 not just the presenter. It also need to call the f
vabr (Chromium) 2016/03/16 17:48:28 You should be able to call HandlePasswordExport th
xunlu 2016/03/18 21:15:30 * HandlePasswordExport() call removed. * ImportPas
65
51 // Clears and then populates the list of passwords and password exceptions. 66 // Clears and then populates the list of passwords and password exceptions.
52 // Called when the JS PasswordManager object is initialized. 67 // Called when the JS PasswordManager object is initialized.
53 void HandleUpdatePasswordLists(const base::ListValue* args); 68 void HandleUpdatePasswordLists(const base::ListValue* args);
54 69
55 // Removes a saved password entry. 70 // Removes a saved password entry.
56 // |value| the entry index to be removed. 71 // |value| the entry index to be removed.
57 void HandleRemoveSavedPassword(const base::ListValue* args); 72 void HandleRemoveSavedPassword(const base::ListValue* args);
58 73
59 // Removes a saved password exception. 74 // Removes a saved password exception.
60 // |value| the entry index to be removed. 75 // |value| the entry index to be removed.
61 void HandleRemovePasswordException(const base::ListValue* args); 76 void HandleRemovePasswordException(const base::ListValue* args);
62 77
63 // Requests the plain text password for an entry to be revealed. 78 // Requests the plain text password for an entry to be revealed.
64 // |index| The index of the entry. 79 // |index| The index of the entry.
65 void HandleRequestShowPassword(const base::ListValue* args); 80 void HandleRequestShowPassword(const base::ListValue* args);
66 81
82 // Import from CSV/JSON file. The steps are:
83 // 1. user click import button -> HandlePasswordImport() ->
84 // start file selector
85 // 2. user selects file -> ImportPasswordFileSeleted() -> read to memory
86 // 3. read completes -> ImportPasswordFileRead() -> store to PasswordStore
87 void HandlePasswordImport(const base::ListValue* args);
88 void ImportPasswordFileSelected(const base::FilePath& path);
89 void ImportPasswordFileRead(password_manager::PasswordImporter::Result result,
90 const std::vector<autofill::PasswordForm>& forms);
91
92 // Export to CSV/JSON file. The steps are:
93 // 1. user click export button -> HandlePasswordExport() ->
94 // check OS password if necessary -> start file selector
95 // 2. user selects file -> ExportPasswordFileSeleted() ->
96 // write to memory buffer -> start write operation
97 // 3. Writing completes -> completion callback(empty for now);
vabr (Chromium) 2016/03/10 10:53:31 nit: It does not make sense to speak about the unu
xunlu 2016/03/16 07:23:58 Done.
98 void HandlePasswordExport(const base::ListValue* args);
99 void ExportPasswordFileSelected(const base::FilePath& path);
100
67 // User pref for storing accept languages. 101 // User pref for storing accept languages.
68 std::string languages_; 102 std::string languages_;
69 103
70 // The PasswordManagerPresenter object owned by the this view. 104 // The PasswordManagerPresenter object owned by the this view.
71 PasswordManagerPresenter password_manager_presenter_; 105 scoped_ptr<PasswordManagerPresenter> password_manager_presenter_;
106
107 // Handle for file picker
108 scoped_refptr<ui::SelectFileDialog> selected_file_dialog_;
72 109
73 DISALLOW_COPY_AND_ASSIGN(PasswordManagerHandler); 110 DISALLOW_COPY_AND_ASSIGN(PasswordManagerHandler);
74 }; 111 };
75 112
76 } // namespace options 113 } // namespace options
77 114
78 #endif // CHROME_BROWSER_UI_WEBUI_OPTIONS_PASSWORD_MANAGER_HANDLER_H_ 115 #endif // CHROME_BROWSER_UI_WEBUI_OPTIONS_PASSWORD_MANAGER_HANDLER_H_
OLDNEW

Powered by Google App Engine
This is Rietveld 408576698