| 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" | |
| 10 #include "base/macros.h" | 9 #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" | |
| 13 #include "third_party/WebKit/public/platform/WebCredentialManagerClient.h" | 12 #include "third_party/WebKit/public/platform/WebCredentialManagerClient.h" |
| 14 #include "third_party/WebKit/public/platform/WebCredentialManagerError.h" | 13 #include "third_party/WebKit/public/platform/WebCredentialManagerError.h" |
| 15 #include "third_party/WebKit/public/platform/WebVector.h" | 14 #include "third_party/WebKit/public/platform/WebVector.h" |
| 16 | 15 |
| 17 namespace blink { | 16 namespace blink { |
| 18 class WebCredential; | 17 class WebCredential; |
| 19 class WebURL; | 18 class WebURL; |
| 20 } | 19 } |
| 21 | 20 |
| 22 namespace content { | 21 namespace content { |
| (...skipping 15 matching lines...) Expand all Loading... |
| 38 // Once RenderView is gone away, the instance will be deleted. | 37 // Once RenderView is gone away, the instance will be deleted. |
| 39 // | 38 // |
| 40 // Note that each RenderView's WebView holds a pointer to the | 39 // Note that each RenderView's WebView holds a pointer to the |
| 41 // CredentialManagerClient (set in 'OnRenderViewCreated()') but does not own it. | 40 // CredentialManagerClient (set in 'OnRenderViewCreated()') but does not own it. |
| 42 class CredentialManagerClient : public blink::WebCredentialManagerClient, | 41 class CredentialManagerClient : public blink::WebCredentialManagerClient, |
| 43 public content::RenderViewObserver { | 42 public content::RenderViewObserver { |
| 44 public: | 43 public: |
| 45 explicit CredentialManagerClient(content::RenderView* render_view); | 44 explicit CredentialManagerClient(content::RenderView* render_view); |
| 46 ~CredentialManagerClient() override; | 45 ~CredentialManagerClient() override; |
| 47 | 46 |
| 48 // RenderViewObserver: | 47 // blink::WebCredentialManagerClient: |
| 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: | |
| 61 void dispatchStore( | 48 void dispatchStore( |
| 62 const blink::WebCredential& credential, | 49 const blink::WebCredential& credential, |
| 63 WebCredentialManagerClient::NotificationCallbacks* callbacks) override; | 50 WebCredentialManagerClient::NotificationCallbacks* callbacks) override; |
| 64 void dispatchRequireUserMediation(NotificationCallbacks* callbacks) override; | 51 void dispatchRequireUserMediation(NotificationCallbacks* callbacks) override; |
| 65 void dispatchGet(bool zero_click_only, | 52 void dispatchGet(bool zero_click_only, |
| 66 bool include_passwords, | 53 bool include_passwords, |
| 67 const blink::WebVector<blink::WebURL>& federations, | 54 const blink::WebVector<blink::WebURL>& federations, |
| 68 RequestCallbacks* callbacks) override; | 55 RequestCallbacks* callbacks) override; |
| 69 | 56 |
| 70 private: | 57 private: |
| 71 typedef IDMap<blink::WebCredentialManagerClient::RequestCallbacks, | 58 void ConnectToMojoCMIfNeeded(); |
| 72 IDMapOwnPointer> RequestCallbacksMap; | |
| 73 typedef IDMap<blink::WebCredentialManagerClient::NotificationCallbacks, | |
| 74 IDMapOwnPointer> NotificationCallbacksMap; | |
| 75 | 59 |
| 76 void RespondToNotificationCallback(int request_id, | 60 mojom::CredentialManagerPtr mojo_cm_service_; |
| 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_; | |
| 84 | 61 |
| 85 DISALLOW_COPY_AND_ASSIGN(CredentialManagerClient); | 62 DISALLOW_COPY_AND_ASSIGN(CredentialManagerClient); |
| 86 }; | 63 }; |
| 87 | 64 |
| 88 } // namespace password_manager | 65 } // namespace password_manager |
| 89 | 66 |
| 90 #endif // COMPONENTS_PASSWORD_MANAGER_CONTENT_RENDERER_CREDENTIAL_MANAGER_CLIEN
T_H_ | 67 #endif // COMPONENTS_PASSWORD_MANAGER_CONTENT_RENDERER_CREDENTIAL_MANAGER_CLIEN
T_H_ |
| OLD | NEW |