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

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

Issue 533493004: Credential Manager: Refactor password_manager::CredentialManagerClient. (Closed) Base URL: https://chromium.googlesource.com/chromium/src.git@master
Patch Set: Explicit. Created 6 years, 3 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/basictypes.h" 8 #include "base/basictypes.h"
9 #include "base/compiler_specific.h" 9 #include "base/compiler_specific.h"
10 #include "base/id_map.h" 10 #include "base/id_map.h"
11 #include "content/public/renderer/render_process_observer.h" 11 #include "content/public/renderer/render_view_observer.h"
12 #include "ipc/ipc_listener.h" 12 #include "ipc/ipc_listener.h"
13 #include "third_party/WebKit/public/platform/WebCredentialManagerClient.h" 13 #include "third_party/WebKit/public/platform/WebCredentialManagerClient.h"
14 #include "third_party/WebKit/public/platform/WebVector.h" 14 #include "third_party/WebKit/public/platform/WebVector.h"
15 15
16 namespace blink { 16 namespace blink {
17 class WebCredential; 17 class WebCredential;
18 class WebURL; 18 class WebURL;
19 } 19 }
20 20
21 namespace content { 21 namespace content {
(...skipping 16 matching lines...) Expand all
38 // to send messages to the browser process, and to route responses to itself. 38 // to send messages to the browser process, and to route responses to itself.
39 // 39 //
40 // When the render thread is shut down (or the client is destructed), the 40 // When the render thread is shut down (or the client is destructed), the
41 // routing is removed, the pointer is cleared, and any pending responses are 41 // routing is removed, the pointer is cleared, and any pending responses are
42 // rejected. 42 // rejected.
43 // 43 //
44 // Note that each RenderView's WebView holds a pointer to the 44 // Note that each RenderView's WebView holds a pointer to the
45 // CredentialManagerClient (set in 'OnRenderViewCreated()'). The client is 45 // CredentialManagerClient (set in 'OnRenderViewCreated()'). The client is
46 // guaranteed to outlive the views that point to it. 46 // guaranteed to outlive the views that point to it.
47 class CredentialManagerClient : public blink::WebCredentialManagerClient, 47 class CredentialManagerClient : public blink::WebCredentialManagerClient,
48 public content::RenderProcessObserver, 48 public content::RenderViewObserver {
49 public IPC::Listener {
50 public: 49 public:
51 CredentialManagerClient(); 50 explicit CredentialManagerClient(content::RenderView* render_view);
52 virtual ~CredentialManagerClient(); 51 virtual ~CredentialManagerClient();
53 52
54 // When a RenderView is created, we need to set this object as its client. 53 // RenderViewObserver:
55 void OnRenderViewCreated(content::RenderView*);
56
57 // content::RenderProcessObserver:
58 virtual void OnRenderProcessShutdown() OVERRIDE;
59
60 // IPC::Listener:
61 virtual bool OnMessageReceived(const IPC::Message& message) OVERRIDE; 54 virtual bool OnMessageReceived(const IPC::Message& message) OVERRIDE;
62 55
63 // Message handlers for messages from the browser process: 56 // Message handlers for messages from the browser process:
64 virtual void OnAcknowledgeFailedSignIn(int request_id); 57 virtual void OnAcknowledgeFailedSignIn(int request_id);
65 virtual void OnAcknowledgeSignedIn(int request_id); 58 virtual void OnAcknowledgeSignedIn(int request_id);
66 virtual void OnAcknowledgeSignedOut(int request_id); 59 virtual void OnAcknowledgeSignedOut(int request_id);
67 virtual void OnSendCredential(int request_id, 60 virtual void OnSendCredential(int request_id,
68 const CredentialInfo& credential_info); 61 const CredentialInfo& credential_info);
69 62
70 // blink::WebCredentialManager: 63 // blink::WebCredentialManager:
71 virtual void dispatchFailedSignIn( 64 virtual void dispatchFailedSignIn(
72 const blink::WebCredential& credential, 65 const blink::WebCredential& credential,
73 WebCredentialManagerClient::NotificationCallbacks* callbacks) OVERRIDE; 66 WebCredentialManagerClient::NotificationCallbacks* callbacks) OVERRIDE;
74 virtual void dispatchSignedIn( 67 virtual void dispatchSignedIn(
75 const blink::WebCredential& credential, 68 const blink::WebCredential& credential,
76 WebCredentialManagerClient::NotificationCallbacks* callbacks) OVERRIDE; 69 WebCredentialManagerClient::NotificationCallbacks* callbacks) OVERRIDE;
77 virtual void dispatchSignedOut(NotificationCallbacks* callbacks) OVERRIDE; 70 virtual void dispatchSignedOut(NotificationCallbacks* callbacks) OVERRIDE;
78 virtual void dispatchRequest( 71 virtual void dispatchRequest(
79 bool zero_click_only, 72 bool zero_click_only,
80 const blink::WebVector<blink::WebURL>& federations, 73 const blink::WebVector<blink::WebURL>& federations,
81 RequestCallbacks* callbacks) OVERRIDE; 74 RequestCallbacks* callbacks) OVERRIDE;
82 75
83 protected:
84 virtual int GetRoutingID();
85
86 private: 76 private:
87 typedef IDMap<blink::WebCredentialManagerClient::RequestCallbacks, 77 typedef IDMap<blink::WebCredentialManagerClient::RequestCallbacks,
88 IDMapOwnPointer> RequestCallbacksMap; 78 IDMapOwnPointer> RequestCallbacksMap;
89 typedef IDMap<blink::WebCredentialManagerClient::NotificationCallbacks, 79 typedef IDMap<blink::WebCredentialManagerClient::NotificationCallbacks,
90 IDMapOwnPointer> NotificationCallbacksMap; 80 IDMapOwnPointer> NotificationCallbacksMap;
91 81
92 void RespondToNotificationCallback(int request_id, 82 void RespondToNotificationCallback(int request_id,
93 NotificationCallbacksMap* map); 83 NotificationCallbacksMap* map);
94 84
95 // Nulls out the raw pointer to |render_thread_| after ensuring that any
96 // message routing is removed.
97 void DisconnectFromRenderThread();
98
99 int routing_id_;
100 content::RenderThread* render_thread_;
101
102 // Track the various blink::WebCredentialManagerClient::*Callbacks objects 85 // Track the various blink::WebCredentialManagerClient::*Callbacks objects
103 // generated from Blink. This class takes ownership of these objects. 86 // generated from Blink. This class takes ownership of these objects.
104 NotificationCallbacksMap failed_sign_in_callbacks_; 87 NotificationCallbacksMap failed_sign_in_callbacks_;
105 NotificationCallbacksMap signed_in_callbacks_; 88 NotificationCallbacksMap signed_in_callbacks_;
106 NotificationCallbacksMap signed_out_callbacks_; 89 NotificationCallbacksMap signed_out_callbacks_;
107 RequestCallbacksMap request_callbacks_; 90 RequestCallbacksMap request_callbacks_;
108 91
109 DISALLOW_COPY_AND_ASSIGN(CredentialManagerClient); 92 DISALLOW_COPY_AND_ASSIGN(CredentialManagerClient);
110 }; 93 };
111 94
112 } // namespace password_manager 95 } // namespace password_manager
113 96
114 #endif // COMPONENTS_PASSWORD_MANAGER_CONTENT_RENDERER_CREDENTIAL_MANAGER_CLIEN T_H_ 97 #endif // COMPONENTS_PASSWORD_MANAGER_CONTENT_RENDERER_CREDENTIAL_MANAGER_CLIEN T_H_
OLDNEW

Powered by Google App Engine
This is Rietveld 408576698