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

Side by Side Diff: chrome/browser/extensions/api/passwords_private/passwords_private_delegate.h

Issue 1142693003: Implement the chrome.passwordsPrivate API. (Closed) Base URL: https://chromium.googlesource.com/chromium/src.git@master
Patch Set: Respond to comments. Created 5 years, 7 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
(Empty)
1 // Copyright 2015 The Chromium Authors. All rights reserved.
2 // Use of this source code is governed by a BSD-style license that can be
3 // found in the LICENSE file.
4
5 #ifndef CHROME_BROWSER_EXTENSIONS_API_PASSWORDS_PRIVATE_PASSWORDS_PRIVATE_DELEGA TE_H_
6 #define CHROME_BROWSER_EXTENSIONS_API_PASSWORDS_PRIVATE_PASSWORDS_PRIVATE_DELEGA TE_H_
7
8 #include <map>
9 #include <string>
10 #include <vector>
11
12 #include "base/callback.h"
13 #include "base/macros.h"
14 #include "base/memory/scoped_ptr.h"
15 #include "base/observer_list_threadsafe.h"
16 #include "chrome/browser/ui/passwords/password_manager_presenter.h"
17 #include "chrome/browser/ui/passwords/password_ui_view.h"
18 #include "chrome/common/extensions/api/passwords_private.h"
19 #include "components/keyed_service/core/keyed_service.h"
20 #include "extensions/browser/extension_function.h"
21
22 class Profile;
23
24 namespace base {
25 class Value;
26 }
27
28 namespace extensions {
29
30 // Delegate used by the chrome.passwordsPrivate API to facilitate removing saved
31 // passwords and password exceptions and to notify listeners when these values
32 // have changed.
33 class PasswordsPrivateDelegate : public KeyedService {
34 public:
35 ~PasswordsPrivateDelegate() override {}
36
37 // An interface used to notify clients (observers) of this object that
38 // saved passwords, password exceptions, and plaintext passwords are ready to
39 // be consumed by the UI. Register an observer via
40 // PasswordsPrivateDelegate::AddObserver().
41 class Observer {
42 public:
43 virtual void OnSavedPasswordsListChanged(const std::vector<linked_ptr<
44 api::passwords_private::PasswordUiEntry>>& entries) {}
45 virtual void OnPasswordExceptionsListChanged(
46 const std::vector<std::string>& exceptions) {}
47 virtual void OnPlaintextPasswordFetched(
48 const std::string& origin_url,
49 const std::string& username,
50 const std::string& password_value) {}
51
52 protected:
53 virtual ~Observer() {}
54 };
55
56 // Adds |observer| to be notified when password data changes.
57 virtual void AddObserver(Observer* observer) = 0;
58
59 // Removes |observer| from the observer list.
60 virtual void RemoveObserver(Observer* observer) = 0;
61
62 // Removes the saved password entry corresponding to |origin_url| and
63 // |username|.
64 // |origin_url| The human-readable origin for the URL where the password is
65 // used/ should be obtained using GetHumanReadableOrigin().
66 // |username| The username used in conjunction with the saved password.
67 virtual void RemoveSavedPassword(
68 const std::string& origin_url, const std::string& username) = 0;
69
70 // Removes the saved password exception entry corresponding to
71 // |exception_url|.
72 // |exception_url| The URL corresponding to the exception to remove; should
73 // be obtained using GetHumanReadableOrigin().
74 virtual void RemovePasswordException(const std::string& exception_url) = 0;
75
76 // Requests the plain text password for entry corresponding to |origin_url|
77 // and |username|.
78 // |origin_url| The human-readable origin for the URL where the password is
79 // used; should be obtained using GetHumanReadableOrigin().
80 // |username| The username used in conjunction with the saved password.
81 // |native_window| The Chrome host window; will be used to show an OS-level
82 // authentication dialog if necessary.
83 virtual void RequestShowPassword(
84 const std::string& origin_url,
85 const std::string& username,
86 const gfx::NativeWindow& native_window) = 0;
87 };
88
89 } // namespace extensions
90
91 #endif // CHROME_BROWSER_EXTENSIONS_API_PASSWORDS_PRIVATE_PASSWORDS_PRIVATE_DEL EGATE_H_
OLDNEW

Powered by Google App Engine
This is Rietveld 408576698