Pin Chrome's shortcut to the Win10 Start menu on install and OS upgrade.
[chromium-blink-merge.git] / chrome / browser / extensions / api / passwords_private / passwords_private_delegate.h
blob37017240c319f87b39dd4f46d505e9375d4e99a0
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.
5 #ifndef CHROME_BROWSER_EXTENSIONS_API_PASSWORDS_PRIVATE_PASSWORDS_PRIVATE_DELEGATE_H_
6 #define CHROME_BROWSER_EXTENSIONS_API_PASSWORDS_PRIVATE_PASSWORDS_PRIVATE_DELEGATE_H_
8 #include <map>
9 #include <string>
10 #include <vector>
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"
22 class Profile;
24 namespace base {
25 class Value;
28 namespace content {
29 class WebContents;
32 namespace extensions {
34 // Delegate used by the chrome.passwordsPrivate API to facilitate removing saved
35 // passwords and password exceptions and to notify listeners when these values
36 // have changed.
37 class PasswordsPrivateDelegate : public KeyedService {
38 public:
39 ~PasswordsPrivateDelegate() override {}
41 // An interface used to notify clients (observers) of this object that
42 // saved passwords, password exceptions, and plaintext passwords are ready to
43 // be consumed by the UI. Register an observer via
44 // PasswordsPrivateDelegate::AddObserver().
45 class Observer {
46 public:
47 virtual void OnSavedPasswordsListChanged(const std::vector<linked_ptr<
48 api::passwords_private::PasswordUiEntry>>& entries) {}
49 virtual void OnPasswordExceptionsListChanged(
50 const std::vector<std::string>& exceptions) {}
51 virtual void OnPlaintextPasswordFetched(
52 const std::string& origin_url,
53 const std::string& username,
54 const std::string& plaintext_password) {}
56 protected:
57 virtual ~Observer() {}
60 // Adds |observer| to be notified when password data changes.
61 virtual void AddObserver(Observer* observer) = 0;
63 // Removes |observer| from the observer list.
64 virtual void RemoveObserver(Observer* observer) = 0;
66 // Removes the saved password entry corresponding to |origin_url| and
67 // |username|.
68 // |origin_url| The human-readable origin for the URL where the password is
69 // used/ should be obtained using GetHumanReadableOrigin().
70 // |username| The username used in conjunction with the saved password.
71 virtual void RemoveSavedPassword(
72 const std::string& origin_url, const std::string& username) = 0;
74 // Removes the saved password exception entry corresponding to
75 // |exception_url|.
76 // |exception_url| The URL corresponding to the exception to remove; should
77 // be obtained using GetHumanReadableOrigin().
78 virtual void RemovePasswordException(const std::string& exception_url) = 0;
80 // Requests the plain text password for entry corresponding to |origin_url|
81 // and |username|.
82 // |origin_url| The human-readable origin for the URL where the password is
83 // used; should be obtained using GetHumanReadableOrigin().
84 // |username| The username used in conjunction with the saved password.
85 // |native_window| The Chrome host window; will be used to show an OS-level
86 // authentication dialog if necessary.
87 virtual void RequestShowPassword(const std::string& origin_url,
88 const std::string& username,
89 content::WebContents* web_contents) = 0;
92 } // namespace extensions
94 #endif // CHROME_BROWSER_EXTENSIONS_API_PASSWORDS_PRIVATE_PASSWORDS_PRIVATE_DELEGATE_H_