| OLD | NEW |
| 1 // Copyright 2014 The Chromium Authors. All rights reserved. | 1 // Copyright 2014 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 COMPONENTS_PASSWORD_MANAGER_CONTENT_RENDERER_CREDENTIAL_MANAGER_CLIENT_H
_ | 5 #ifndef COMPONENTS_PASSWORD_MANAGER_CONTENT_RENDERER_CREDENTIAL_MANAGER_CLIENT_H
_ |
| 6 #define COMPONENTS_PASSWORD_MANAGER_CONTENT_RENDERER_CREDENTIAL_MANAGER_CLIENT_H
_ | 6 #define COMPONENTS_PASSWORD_MANAGER_CONTENT_RENDERER_CREDENTIAL_MANAGER_CLIENT_H
_ |
| 7 | 7 |
| 8 #include "base/compiler_specific.h" | 8 #include "base/compiler_specific.h" |
| 9 #include "base/id_map.h" |
| 9 #include "base/macros.h" | 10 #include "base/macros.h" |
| 10 #include "components/password_manager/content/public/interfaces/credential_manag
er.mojom.h" | |
| 11 #include "content/public/renderer/render_view_observer.h" | 11 #include "content/public/renderer/render_view_observer.h" |
| 12 #include "ipc/ipc_listener.h" |
| 12 #include "third_party/WebKit/public/platform/WebCredentialManagerClient.h" | 13 #include "third_party/WebKit/public/platform/WebCredentialManagerClient.h" |
| 13 #include "third_party/WebKit/public/platform/WebCredentialManagerError.h" | 14 #include "third_party/WebKit/public/platform/WebCredentialManagerError.h" |
| 14 #include "third_party/WebKit/public/platform/WebVector.h" | 15 #include "third_party/WebKit/public/platform/WebVector.h" |
| 15 | 16 |
| 16 namespace blink { | 17 namespace blink { |
| 17 class WebCredential; | 18 class WebCredential; |
| 18 class WebURL; | 19 class WebURL; |
| 19 } | 20 } |
| 20 | 21 |
| 21 namespace content { | 22 namespace content { |
| (...skipping 15 matching lines...) Expand all Loading... |
| 37 // Once RenderView is gone away, the instance will be deleted. | 38 // Once RenderView is gone away, the instance will be deleted. |
| 38 // | 39 // |
| 39 // Note that each RenderView's WebView holds a pointer to the | 40 // Note that each RenderView's WebView holds a pointer to the |
| 40 // CredentialManagerClient (set in 'OnRenderViewCreated()') but does not own it. | 41 // CredentialManagerClient (set in 'OnRenderViewCreated()') but does not own it. |
| 41 class CredentialManagerClient : public blink::WebCredentialManagerClient, | 42 class CredentialManagerClient : public blink::WebCredentialManagerClient, |
| 42 public content::RenderViewObserver { | 43 public content::RenderViewObserver { |
| 43 public: | 44 public: |
| 44 explicit CredentialManagerClient(content::RenderView* render_view); | 45 explicit CredentialManagerClient(content::RenderView* render_view); |
| 45 ~CredentialManagerClient() override; | 46 ~CredentialManagerClient() override; |
| 46 | 47 |
| 47 // blink::WebCredentialManagerClient: | 48 // RenderViewObserver: |
| 49 bool OnMessageReceived(const IPC::Message& message) override; |
| 50 |
| 51 // Message handlers for messages from the browser process: |
| 52 virtual void OnAcknowledgeStore(int request_id); |
| 53 virtual void OnAcknowledgeRequireUserMediation(int request_id); |
| 54 virtual void OnSendCredential(int request_id, |
| 55 const CredentialInfo& credential_info); |
| 56 virtual void OnRejectCredentialRequest( |
| 57 int request_id, |
| 58 blink::WebCredentialManagerError error); |
| 59 |
| 60 // blink::WebCredentialManager: |
| 48 void dispatchStore( | 61 void dispatchStore( |
| 49 const blink::WebCredential& credential, | 62 const blink::WebCredential& credential, |
| 50 WebCredentialManagerClient::NotificationCallbacks* callbacks) override; | 63 WebCredentialManagerClient::NotificationCallbacks* callbacks) override; |
| 51 void dispatchRequireUserMediation(NotificationCallbacks* callbacks) override; | 64 void dispatchRequireUserMediation(NotificationCallbacks* callbacks) override; |
| 52 void dispatchGet(bool zero_click_only, | 65 void dispatchGet(bool zero_click_only, |
| 53 bool include_passwords, | 66 bool include_passwords, |
| 54 const blink::WebVector<blink::WebURL>& federations, | 67 const blink::WebVector<blink::WebURL>& federations, |
| 55 RequestCallbacks* callbacks) override; | 68 RequestCallbacks* callbacks) override; |
| 56 | 69 |
| 57 private: | 70 private: |
| 58 void ConnectToMojoCMIfNeeded(); | 71 typedef IDMap<blink::WebCredentialManagerClient::RequestCallbacks, |
| 72 IDMapOwnPointer> RequestCallbacksMap; |
| 73 typedef IDMap<blink::WebCredentialManagerClient::NotificationCallbacks, |
| 74 IDMapOwnPointer> NotificationCallbacksMap; |
| 59 | 75 |
| 60 mojom::CredentialManagerPtr mojo_cm_service_; | 76 void RespondToNotificationCallback(int request_id, |
| 77 NotificationCallbacksMap* map); |
| 78 |
| 79 // Track the various blink::WebCredentialManagerClient::*Callbacks objects |
| 80 // generated from Blink. This class takes ownership of these objects. |
| 81 NotificationCallbacksMap store_callbacks_; |
| 82 NotificationCallbacksMap require_user_mediation_callbacks_; |
| 83 RequestCallbacksMap get_callbacks_; |
| 61 | 84 |
| 62 DISALLOW_COPY_AND_ASSIGN(CredentialManagerClient); | 85 DISALLOW_COPY_AND_ASSIGN(CredentialManagerClient); |
| 63 }; | 86 }; |
| 64 | 87 |
| 65 } // namespace password_manager | 88 } // namespace password_manager |
| 66 | 89 |
| 67 #endif // COMPONENTS_PASSWORD_MANAGER_CONTENT_RENDERER_CREDENTIAL_MANAGER_CLIEN
T_H_ | 90 #endif // COMPONENTS_PASSWORD_MANAGER_CONTENT_RENDERER_CREDENTIAL_MANAGER_CLIEN
T_H_ |
| OLD | NEW |