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

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: comments Created 5 years, 5 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 <string> 8 #include <string>
9 #include <vector> 9 #include <vector>
10 10
11 #include "base/gtest_prod_util.h"
Garrett Casto 2015/07/07 22:11:09 Looks like this isn't used.
11 #include "base/prefs/pref_member.h" 12 #include "base/prefs/pref_member.h"
12 #include "chrome/browser/ui/passwords/password_manager_presenter.h" 13 #include "chrome/browser/ui/passwords/password_manager_presenter.h"
13 #include "chrome/browser/ui/passwords/password_ui_view.h" 14 #include "chrome/browser/ui/passwords/password_ui_view.h"
14 #include "chrome/browser/ui/webui/options/options_ui.h" 15 #include "chrome/browser/ui/webui/options/options_ui.h"
16 #include "components/password_manager/core/browser/import/password_importer.h"
17 #include "ui/shell_dialogs/select_file_dialog.h"
18
19 class PasswordManagerHandlerTest;
15 20
16 namespace options { 21 namespace options {
17 22
18 // The WebUI based PasswordUIView. Displays passwords in the web ui. 23 // The WebUI based PasswordUIView. Displays passwords in the web ui.
19 class PasswordManagerHandler : public OptionsPageUIHandler, 24 class PasswordManagerHandler : public OptionsPageUIHandler,
20 public PasswordUIView { 25 public PasswordUIView,
26 public ui::SelectFileDialog::Listener {
21 public: 27 public:
22 PasswordManagerHandler(); 28 PasswordManagerHandler();
29 explicit PasswordManagerHandler(PasswordManagerPresenter* presenter);
23 ~PasswordManagerHandler() override; 30 ~PasswordManagerHandler() override;
24 31
32 friend class ::PasswordManagerHandlerTest;
Garrett Casto 2015/07/07 22:11:09 It doesn't actually matter where this is, but gene
33
25 // OptionsPageUIHandler implementation. 34 // OptionsPageUIHandler implementation.
26 void GetLocalizedValues(base::DictionaryValue* localized_strings) override; 35 void GetLocalizedValues(base::DictionaryValue* localized_strings) override;
27 void InitializeHandler() override; 36 void InitializeHandler() override;
28 void InitializePage() override; 37 void InitializePage() override;
29 void RegisterMessages() override; 38 void RegisterMessages() override;
30 39
40 // ui::SelectFileDialog::Listener implementation
41 void FileSelected(const base::FilePath& path,
42 int index,
43 void* params) override;
44
31 // PasswordUIView implementation. 45 // PasswordUIView implementation.
32 Profile* GetProfile() override; 46 Profile* GetProfile() override;
33 void ShowPassword( 47 void ShowPassword(
34 size_t index, 48 size_t index,
35 const std::string& origin_url, 49 const std::string& origin_url,
36 const std::string& username, 50 const std::string& username,
37 const base::string16& password_value) override; 51 const base::string16& password_value) override;
38 void SetPasswordList( 52 void SetPasswordList(
39 const ScopedVector<autofill::PasswordForm>& password_list, 53 const ScopedVector<autofill::PasswordForm>& password_list,
40 bool show_passwords) override; 54 bool show_passwords) override;
(...skipping 12 matching lines...) Expand all
53 void HandleRemoveSavedPassword(const base::ListValue* args); 67 void HandleRemoveSavedPassword(const base::ListValue* args);
54 68
55 // Removes a saved password exception. 69 // Removes a saved password exception.
56 // |value| the entry index to be removed. 70 // |value| the entry index to be removed.
57 void HandleRemovePasswordException(const base::ListValue* args); 71 void HandleRemovePasswordException(const base::ListValue* args);
58 72
59 // Requests the plain text password for an entry to be revealed. 73 // Requests the plain text password for an entry to be revealed.
60 // |index| The index of the entry. 74 // |index| The index of the entry.
61 void HandleRequestShowPassword(const base::ListValue* args); 75 void HandleRequestShowPassword(const base::ListValue* args);
62 76
77 // Import from CSV/JSON file. The steps are:
78 // 1. user click import button -> HandlePasswordImport() ->
79 // start file selector
80 // 2. user selects file -> ImportPasswordFileSeleted() -> read to memory
81 // 3. read completes -> ImportPasswordFileRead() -> store to PasswordStore
82 void HandlePasswordImport(const base::ListValue* args);
83 void ImportPasswordFileSelected(const base::FilePath& path);
84 void ImportPasswordFileRead(password_manager::PasswordImporter::Result result,
85 const std::vector<autofill::PasswordForm>& forms);
86
87 // Export to CSV/JSON file. The steps are:
88 // 1. user click export button -> HandlePasswordExport() ->
89 // check OS password if necessary -> start file selector
90 // 2. user selects file -> ExportPasswordFileSeleted() ->
91 // write to memory buffer -> start write operation
92 // 3. Writing completes -> ExportPaswordFileWritten()
93 void HandlePasswordExport(const base::ListValue* args);
94 void ExportPasswordFileSelected(const base::FilePath& path);
95 void ExportPasswordFileWritten();
96
63 // User pref for storing accept languages. 97 // User pref for storing accept languages.
64 std::string languages_; 98 std::string languages_;
65 99
66 // The PasswordManagerPresenter object owned by the this view. 100 // The PasswordManagerPresenter object owned by the this view.
67 PasswordManagerPresenter password_manager_presenter_; 101 scoped_ptr<PasswordManagerPresenter> password_manager_presenter_;
102
103 // Handle for file picker
104 scoped_refptr<ui::SelectFileDialog> selected_file_dialog_;
68 105
69 DISALLOW_COPY_AND_ASSIGN(PasswordManagerHandler); 106 DISALLOW_COPY_AND_ASSIGN(PasswordManagerHandler);
70 }; 107 };
71 108
72 } // namespace options 109 } // namespace options
73 110
74 #endif // CHROME_BROWSER_UI_WEBUI_OPTIONS_PASSWORD_MANAGER_HANDLER_H_ 111 #endif // CHROME_BROWSER_UI_WEBUI_OPTIONS_PASSWORD_MANAGER_HANDLER_H_
OLDNEW

Powered by Google App Engine
This is Rietveld 408576698