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

Side by Side Diff: components/password_manager/content/renderer/credential_manager_client.h

Issue 1762603002: Switch components/password_manager code from IPC messages to Mojo. (Closed) Base URL: https://chromium.googlesource.com/chromium/src.git@master
Patch Set: Impl done, unit_tests and browser_tests not ready yet 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 unified diff | Download patch
OLDNEW
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 {
23 class RenderView; 22 class RenderView;
24 } 23 }
25 24
26 namespace password_manager { 25 namespace password_manager {
27 26
28 struct CredentialInfo; 27 struct CredentialInfo;
29 28
30 // The CredentialManagerClient implements the Blink platform interface 29 // The CredentialManagerClient implements the Blink platform interface
31 // WebCredentialManagerClient, and acts as an intermediary between Blink-side 30 // WebCredentialManagerClient, and acts as an intermediary between Blink-side
32 // calls to 'navigator.credential.*' and the password manager internals which 31 // calls to 'navigator.credential.*' and the password manager internals which
33 // live in the browser process. 32 // live in the browser process.
34 // 33 //
35 // One instance of CredentialManagerClient is created per RenderView, 34 // One instance of CredentialManagerClient is created per RenderView,
36 // acts as RenderViewObserver so it can send messages to the browser process, 35 // acts as RenderViewObserver so it can send messages to the browser process,
37 // and route responses to itself. 36 // and route responses to itself.
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.
41 //
42 // For now still inherit RenderViewObserver here just to keep liftcycle with
vabr (Chromium) 2016/03/09 16:26:30 nit: Frankly, nobody will periodically check on th
leonhsl(Using Gerrit) 2016/03/10 06:42:42 Done. Removed the comments. Actually I noticed tha
43 // RenderView. Maybe later we can consider move
44 // password_manager/content/renderer into Blink, to attach this instance's
45 // lifecycle with blink::WebView and access mojo CrendentialManager
46 // from Blink there?
42 class CredentialManagerClient : public blink::WebCredentialManagerClient, 47 class CredentialManagerClient : public blink::WebCredentialManagerClient,
43 public content::RenderViewObserver { 48 public content::RenderViewObserver {
44 public: 49 public:
45 explicit CredentialManagerClient(content::RenderView* render_view); 50 explicit CredentialManagerClient(content::RenderView* render_view);
46 ~CredentialManagerClient() override; 51 ~CredentialManagerClient() override;
47 52
48 // RenderViewObserver: 53 // 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( 54 void dispatchStore(
62 const blink::WebCredential& credential, 55 const blink::WebCredential& credential,
63 WebCredentialManagerClient::NotificationCallbacks* callbacks) override; 56 WebCredentialManagerClient::NotificationCallbacks* callbacks) override;
64 void dispatchRequireUserMediation(NotificationCallbacks* callbacks) override; 57 void dispatchRequireUserMediation(NotificationCallbacks* callbacks) override;
65 void dispatchGet(bool zero_click_only, 58 void dispatchGet(bool zero_click_only,
66 bool include_passwords, 59 bool include_passwords,
67 const blink::WebVector<blink::WebURL>& federations, 60 const blink::WebVector<blink::WebURL>& federations,
68 RequestCallbacks* callbacks) override; 61 RequestCallbacks* callbacks) override;
69 62
70 private: 63 private:
71 typedef IDMap<blink::WebCredentialManagerClient::RequestCallbacks, 64 void ConnectToMojoCMIfNeeded();
72 IDMapOwnPointer> RequestCallbacksMap;
73 typedef IDMap<blink::WebCredentialManagerClient::NotificationCallbacks,
74 IDMapOwnPointer> NotificationCallbacksMap;
75 65
76 void RespondToNotificationCallback(int request_id, 66 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 67
85 DISALLOW_COPY_AND_ASSIGN(CredentialManagerClient); 68 DISALLOW_COPY_AND_ASSIGN(CredentialManagerClient);
86 }; 69 };
87 70
88 } // namespace password_manager 71 } // namespace password_manager
89 72
90 #endif // COMPONENTS_PASSWORD_MANAGER_CONTENT_RENDERER_CREDENTIAL_MANAGER_CLIEN T_H_ 73 #endif // COMPONENTS_PASSWORD_MANAGER_CONTENT_RENDERER_CREDENTIAL_MANAGER_CLIEN T_H_
OLDNEW

Powered by Google App Engine
This is Rietveld 408576698