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

Unified 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 side-by-side diff with in-line comments
Download patch
Index: chrome/browser/ui/webui/options/password_manager_handler.h
diff --git a/chrome/browser/ui/webui/options/password_manager_handler.h b/chrome/browser/ui/webui/options/password_manager_handler.h
index d8ed6c04d282f3f14d94055c33210c7875812362..a1a24ce2248363d3fd37a5e7a9b3644e373f4a2a 100644
--- a/chrome/browser/ui/webui/options/password_manager_handler.h
+++ b/chrome/browser/ui/webui/options/password_manager_handler.h
@@ -10,27 +10,40 @@
#include <string>
#include <vector>
+#include "base/gtest_prod_util.h"
#include "base/macros.h"
#include "build/build_config.h"
#include "chrome/browser/ui/passwords/password_manager_presenter.h"
#include "chrome/browser/ui/passwords/password_ui_view.h"
#include "chrome/browser/ui/webui/options/options_ui.h"
+#include "components/password_manager/core/browser/import/password_importer.h"
#include "components/prefs/pref_member.h"
+#include "ui/shell_dialogs/select_file_dialog.h"
+
+class PasswordManagerHandlerTest;
namespace options {
// The WebUI based PasswordUIView. Displays passwords in the web ui.
class PasswordManagerHandler : public OptionsPageUIHandler,
- public PasswordUIView {
+ public PasswordUIView,
+ public ui::SelectFileDialog::Listener {
public:
PasswordManagerHandler();
+ 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.
~PasswordManagerHandler() override;
// OptionsPageUIHandler implementation.
void GetLocalizedValues(base::DictionaryValue* localized_strings) override;
void InitializeHandler() override;
+ void InitializePage() override;
void RegisterMessages() override;
+ // ui::SelectFileDialog::Listener implementation
+ void FileSelected(const base::FilePath& path,
+ int index,
+ void* params) override;
+
// PasswordUIView implementation.
Profile* GetProfile() override;
void ShowPassword(
@@ -48,6 +61,8 @@ class PasswordManagerHandler : public OptionsPageUIHandler,
gfx::NativeWindow GetNativeWindow() const override;
#endif
private:
+ 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
+
// Clears and then populates the list of passwords and password exceptions.
// Called when the JS PasswordManager object is initialized.
void HandleUpdatePasswordLists(const base::ListValue* args);
@@ -64,11 +79,33 @@ class PasswordManagerHandler : public OptionsPageUIHandler,
// |index| The index of the entry.
void HandleRequestShowPassword(const base::ListValue* args);
+ // Import from CSV/JSON file. The steps are:
+ // 1. user click import button -> HandlePasswordImport() ->
+ // start file selector
+ // 2. user selects file -> ImportPasswordFileSeleted() -> read to memory
+ // 3. read completes -> ImportPasswordFileRead() -> store to PasswordStore
+ void HandlePasswordImport(const base::ListValue* args);
+ void ImportPasswordFileSelected(const base::FilePath& path);
+ void ImportPasswordFileRead(password_manager::PasswordImporter::Result result,
+ const std::vector<autofill::PasswordForm>& forms);
+
+ // Export to CSV/JSON file. The steps are:
+ // 1. user click export button -> HandlePasswordExport() ->
+ // check OS password if necessary -> start file selector
+ // 2. user selects file -> ExportPasswordFileSeleted() ->
+ // write to memory buffer -> start write operation
+ // 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.
+ void HandlePasswordExport(const base::ListValue* args);
+ void ExportPasswordFileSelected(const base::FilePath& path);
+
// User pref for storing accept languages.
std::string languages_;
// The PasswordManagerPresenter object owned by the this view.
- PasswordManagerPresenter password_manager_presenter_;
+ scoped_ptr<PasswordManagerPresenter> password_manager_presenter_;
+
+ // Handle for file picker
+ scoped_refptr<ui::SelectFileDialog> selected_file_dialog_;
DISALLOW_COPY_AND_ASSIGN(PasswordManagerHandler);
};

Powered by Google App Engine
This is Rietveld 408576698