Skip to content

Commit

Permalink
Credential Manager: Renderer-side implementation.
Browse files Browse the repository at this point in the history
This patch does three things:

1. Implements the Blink platform interface WebCredentialManagerClient by
   adding a CredentialManagerClient class to the password manager component.

2. Wires that implementation up to Blink's platform layer by creating an
   instance of the new client, held in ChromeContentRendererClient, and
   setting it as each new RenderView's client.

3. Stubs out IPCs for the renderer to pass messages up to the browser in
   order to do the heavy lifting of actually answering Blink's requests by
   generating and delivering Credential objects.                                                                                                             

BUG=400674
TBR=tkent@chromium.org

Review URL: https://codereview.chromium.org/464883002

Cr-Commit-Position: refs/heads/master@{#291390}
git-svn-id: svn://svn.chromium.org/chrome/trunk/src@291390 0039d316-1c4b-4281-b951-d872f2087c98
  • Loading branch information
mkwst@chromium.org committed Aug 22, 2014
1 parent 73902b6 commit e08e2f5
Show file tree
Hide file tree
Showing 25 changed files with 947 additions and 5 deletions.
1 change: 1 addition & 0 deletions chrome/chrome_common.gypi
Original file line number Diff line number Diff line change
Expand Up @@ -369,6 +369,7 @@
'<(DEPTH)/components/components.gyp:autofill_core_common',
'<(DEPTH)/components/components.gyp:autofill_content_common',
'<(DEPTH)/components/components.gyp:password_manager_core_common',
'<(DEPTH)/components/components.gyp:password_manager_content_common',
'<(DEPTH)/components/components.gyp:signin_core_common',
'<(DEPTH)/components/components.gyp:translate_content_common',
'<(DEPTH)/components/components.gyp:visitedlink_common',
Expand Down
1 change: 1 addition & 0 deletions chrome/chrome_renderer.gypi
Original file line number Diff line number Diff line change
Expand Up @@ -279,6 +279,7 @@
'../components/components.gyp:cdm_renderer',
'../components/components.gyp:data_reduction_proxy_common',
'../components/components.gyp:startup_metric_utils',
'../components/components.gyp:password_manager_content_renderer',
'../components/components.gyp:plugins_renderer',
'../components/components.gyp:translate_content_renderer',
'../components/components.gyp:translate_core_common',
Expand Down
1 change: 1 addition & 0 deletions chrome/common/BUILD.gn
Original file line number Diff line number Diff line change
Expand Up @@ -87,6 +87,7 @@ static_library("common") {
"//components/visitedlink/common",
"//components/autofill/content/common",
"//components/autofill/core/common",
"//components/password_manager/content/common",
"//components/password_manager/core/common",
"//components/signin/core/common",
"//components/translate/content/common",
Expand Down
1 change: 1 addition & 0 deletions chrome/renderer/BUILD.gn
Original file line number Diff line number Diff line change
Expand Up @@ -38,6 +38,7 @@ static_library("renderer") {
"//components/autofill/content/renderer",
"//components/cdm/renderer",
"//components/data_reduction_proxy/common",
"//components/password_manager/content/renderer",
"//components/plugins/renderer",
"//components/startup_metric_utils",
"//components/translate/core/common",
Expand Down
1 change: 1 addition & 0 deletions chrome/renderer/DEPS
Original file line number Diff line number Diff line change
Expand Up @@ -11,6 +11,7 @@ include_rules = [
"+components/dom_distiller/core",
"+components/nacl/common",
"+components/nacl/renderer",
"+components/password_manager/content/renderer",
"+components/plugins/renderer",
"+components/signin/core/common",
"+components/translate/content/common",
Expand Down
8 changes: 8 additions & 0 deletions chrome/renderer/chrome_content_renderer_client.cc
Original file line number Diff line number Diff line change
Expand Up @@ -74,6 +74,7 @@
#include "components/autofill/content/renderer/password_generation_agent.h"
#include "components/dom_distiller/core/url_constants.h"
#include "components/nacl/renderer/ppb_nacl_private_impl.h"
#include "components/password_manager/content/renderer/credential_manager_client.h"
#include "components/plugins/renderer/mobile_youtube_plugin.h"
#include "components/signin/core/common/profile_management_switches.h"
#include "components/visitedlink/renderer/visitedlink_slave.h"
Expand Down Expand Up @@ -314,6 +315,9 @@ void ChromeContentRendererClient::RenderThreadStarted() {
#endif
search_bouncer_.reset(new SearchBouncer());

credential_manager_client_.reset(
new password_manager::CredentialManagerClient());

thread->AddObserver(chrome_observer_.get());
thread->AddObserver(extension_dispatcher_.get());
#if defined(FULL_SAFE_BROWSING)
Expand All @@ -322,6 +326,7 @@ void ChromeContentRendererClient::RenderThreadStarted() {
thread->AddObserver(visited_link_slave_.get());
thread->AddObserver(prerender_dispatcher_.get());
thread->AddObserver(search_bouncer_.get());
thread->AddObserver(credential_manager_client_.get());

#if defined(ENABLE_WEBRTC)
thread->AddFilter(webrtc_logging_message_filter_.get());
Expand Down Expand Up @@ -493,6 +498,9 @@ void ChromeContentRendererClient::RenderViewCreated(
new SearchBox(render_view);

new ChromeRenderViewObserver(render_view, chrome_observer_.get());

if (credential_manager_client_)
credential_manager_client_->OnRenderViewCreated(render_view);
}

void ChromeContentRendererClient::SetNumberOfViews(int number_of_views) {
Expand Down
6 changes: 6 additions & 0 deletions chrome/renderer/chrome_content_renderer_client.h
Original file line number Diff line number Diff line change
Expand Up @@ -54,6 +54,10 @@ namespace blink {
class WebSecurityOrigin;
}

namespace password_manager {
class CredentialManagerClient;
}

#if defined(ENABLE_WEBRTC)
class WebRtcLoggingMessageFilter;
#endif
Expand Down Expand Up @@ -191,6 +195,8 @@ class ChromeContentRendererClient : public content::ContentRendererClient {
permissions_policy_delegate_;
scoped_ptr<PrescientNetworkingDispatcher> prescient_networking_dispatcher_;
scoped_ptr<RendererNetPredictor> net_predictor_;
scoped_ptr<password_manager::CredentialManagerClient>
credential_manager_client_;
#if defined(ENABLE_SPELLCHECK)
scoped_ptr<SpellCheck> spellcheck_;
#endif
Expand Down
5 changes: 5 additions & 0 deletions components/components_tests.gyp
Original file line number Diff line number Diff line change
Expand Up @@ -411,6 +411,7 @@
'sources': [
'autofill/content/renderer/renderer_save_password_progress_logger_unittest.cc',
'dom_distiller/content/dom_distiller_viewer_source_unittest.cc',
'password_manager/content/renderer/credential_manager_client_unittest.cc',
'power/origin_power_map_unittest.cc',
'usb_service/usb_context_unittest.cc',
'usb_service/usb_device_filter_unittest.cc',
Expand All @@ -435,6 +436,10 @@
# Dependencies of precache/content
'components.gyp:precache_content',

# Dependencies of password_manager
'components.gyp:password_manager_content_renderer',
'components.gyp:password_manager_content_renderer_test_support',

# Dependencies of power
'components.gyp:power',

Expand Down
73 changes: 68 additions & 5 deletions components/password_manager.gypi
Original file line number Diff line number Diff line change
Expand Up @@ -156,21 +156,84 @@
'conditions': [
['OS != "ios"', {
'targets': [
{
# GN version: //components/password_manager/content/common
'target_name': 'password_manager_content_common',
'type': 'static_library',
'dependencies': [
'../base/base.gyp:base',
'../content/content.gyp:content_common',
'../ipc/ipc.gyp:ipc',
'../third_party/WebKit/public/blink.gyp:blink_minimal',
'password_manager_core_common',
],
'include_dirs': [
'..',
],
'sources': [
'password_manager/content/common/credential_manager_message_generator.cc',
'password_manager/content/common/credential_manager_message_generator.h',
'password_manager/content/common/credential_manager_messages.h',
'password_manager/content/common/credential_manager_types.cc',
'password_manager/content/common/credential_manager_types.h',
],
},
{
# GN version: //components/password_manager/content/renderer
'target_name': 'password_manager_content_renderer',
'type': 'static_library',
'dependencies': [
'../base/base.gyp:base',
'../content/content.gyp:content_common',
'../ipc/ipc.gyp:ipc',
'../third_party/WebKit/public/blink.gyp:blink',
'password_manager_core_common',
'password_manager_content_common',
],
'include_dirs': [
'..',
],
'sources': [
'password_manager/content/renderer/credential_manager_client.cc',
'password_manager/content/renderer/credential_manager_client.h',
],
},
{
# GN version: //components/password_manager/core/browser:test_support
'target_name': 'password_manager_content_renderer_test_support',
'type': 'static_library',
'dependencies': [
'password_manager_content_common',
'../base/base.gyp:base',
'../testing/gmock.gyp:gmock',
'../testing/gtest.gyp:gtest',
'../third_party/WebKit/public/blink.gyp:blink',
],
'include_dirs': [
'..',
],
'sources': [
# Note: sources list duplicated in GN build.
'password_manager/content/renderer/test_credential_manager_client.cc',
'password_manager/content/renderer/test_credential_manager_client.h',
],
},
{
# GN version: //components/password_manager/content/browser
'target_name': 'password_manager_content_browser',
'type': 'static_library',
'dependencies': [
'autofill_content_browser',
'autofill_content_common',
'autofill_core_common',
'keyed_service_content',
'password_manager_core_browser',
'../base/base.gyp:base',
'../content/content.gyp:content_browser',
'../content/content.gyp:content_common',
'../ipc/ipc.gyp:ipc',
'../net/net.gyp:net',
'autofill_content_browser',
'autofill_content_common',
'autofill_core_common',
'keyed_service_content',
'password_manager_core_browser',
'password_manager_content_common',
],
'include_dirs': [
'..',
Expand Down
21 changes: 21 additions & 0 deletions components/password_manager/content/common/BUILD.gn
Original file line number Diff line number Diff line change
@@ -0,0 +1,21 @@
# Copyright 2014 The Chromium Authors. All rights reserved.
# Use of this source code is governed by a BSD-style license that can be
# found in the LICENSE file.

static_library("common") {
sources = [
"credential_manager_message_generator.cc",
"credential_manager_message_generator.h",
"credential_manager_messages.h",
"credential_manager_types.cc",
"credential_manager_types.h",
]

deps = [
"//base",
"//content/public/common",
"//ipc",
"//third_party/WebKit/public:blink",
"//url",
]
}
4 changes: 4 additions & 0 deletions components/password_manager/content/common/DEPS
Original file line number Diff line number Diff line change
@@ -0,0 +1,4 @@
include_rules = [
"+content/public/common",
"+ipc",
]
12 changes: 12 additions & 0 deletions components/password_manager/content/common/OWNERS
Original file line number Diff line number Diff line change
@@ -0,0 +1,12 @@
# Changes to IPC messages require a security review to avoid introducing
# new sandbox escapes.
per-file credential_manager_messages*.h=set noparent
per-file credential_manager_messages*.h=cevans@chromium.org
per-file credential_manager_messages*.h=dcheng@chromium.org
per-file credential_manager_messages*.h=inferno@chromium.org
per-file credential_manager_messages*.h=jln@chromium.org
per-file credential_manager_messages*.h=jschuh@chromium.org
per-file credential_manager_messages*.h=kenrb@chromium.org
per-file credential_manager_messages*.h=nasko@chromium.org
per-file credential_manager_messages*.h=palmer@chromium.org
per-file credential_manager_messages*.h=tsepez@chromium.org
Original file line number Diff line number Diff line change
@@ -0,0 +1,33 @@
// Copyright 2014 The Chromium Authors. All rights reserved.
// Use of this source code is governed by a BSD-style license that can be
// found in the LICENSE file.

// Get basic type definitions.
#define IPC_MESSAGE_IMPL
#include "components/password_manager/content/common/credential_manager_message_generator.h"

// Generate constructors.
#include "ipc/struct_constructor_macros.h"
#include "components/password_manager/content/common/credential_manager_message_generator.h"

// Generate destructors.
#include "ipc/struct_destructor_macros.h"
#include "components/password_manager/content/common/credential_manager_message_generator.h"

// Generate param traits write methods.
#include "ipc/param_traits_write_macros.h"
namespace IPC {
#include "components/password_manager/content/common/credential_manager_message_generator.h"
} // namespace IPC

// Generate param traits read methods.
#include "ipc/param_traits_read_macros.h"
namespace IPC {
#include "components/password_manager/content/common/credential_manager_message_generator.h"
} // namespace IPC

// Generate param traits log methods.
#include "ipc/param_traits_log_macros.h"
namespace IPC {
#include "components/password_manager/content/common/credential_manager_message_generator.h"
} // namespace IPC
Original file line number Diff line number Diff line change
@@ -0,0 +1,7 @@
// Copyright 2014 The Chromium Authors. All rights reserved.
// Use of this source code is governed by a BSD-style license that can be
// found in the LICENSE file.

// Multiply-included file, hence no include guard.

#include "components/password_manager/content/common/credential_manager_messages.h"
Original file line number Diff line number Diff line change
@@ -0,0 +1,93 @@
// Copyright 2014 The Chromium Authors. All rights reserved.
// Use of this source code is governed by a BSD-style license that can be
// found in the LICENSE file.

// Message definition file, included multiple times, hence no include guard.

#include <string>
#include <vector>

#include "base/strings/string16.h"
#include "components/password_manager/content/common/credential_manager_types.h"
#include "content/public/common/common_param_traits.h"
#include "content/public/common/common_param_traits_macros.h"
#include "ipc/ipc_message_macros.h"
#include "ipc/ipc_message_utils.h"
#include "third_party/WebKit/public/platform/WebCredentialManagerError.h"
#include "url/gurl.h"

#define IPC_MESSAGE_START CredentialManagerMsgStart

IPC_ENUM_TRAITS_MAX_VALUE(blink::WebCredentialManagerError::ErrorType,
blink::WebCredentialManagerError::ErrorTypeLast);

IPC_ENUM_TRAITS_MAX_VALUE(password_manager::CredentialType,
password_manager::CREDENTIAL_TYPE_LAST);

IPC_STRUCT_TRAITS_BEGIN(password_manager::CredentialInfo)
IPC_STRUCT_TRAITS_MEMBER(type)
IPC_STRUCT_TRAITS_MEMBER(id)
IPC_STRUCT_TRAITS_MEMBER(name)
IPC_STRUCT_TRAITS_MEMBER(avatar)
IPC_STRUCT_TRAITS_MEMBER(password)
IPC_STRUCT_TRAITS_MEMBER(federation)
IPC_STRUCT_TRAITS_END()

// ----------------------------------------------------------------------------
// Messages sent from the renderer to the browser

// Passes the notification from 'navigator.credentials.notifyFailedSignIn()' up
// to the browser process in order to suppress the automatic bubble which would
// pop up in order to prompt the user to save the credential she used for
// signin. The browser process will respond with a
// CredentialManagerMsg_AcknowledgeFailedSignedIn message.
IPC_MESSAGE_ROUTED2(CredentialManagerHostMsg_NotifyFailedSignIn,
int /* request_id */,
password_manager::CredentialInfo /* credential */)

// Passes the notification from 'navigator.credentials.notifySignedIn()' up to
// the browser process in order to (among other things) prompt the user to save
// the credential she used for signin. The browser process will respond with a
// CredentialManagerMsg_AcknowledgeSignedIn message.
IPC_MESSAGE_ROUTED2(CredentialManagerHostMsg_NotifySignedIn,
int /* request_id */,
password_manager::CredentialInfo /* credential */)

// Passes the notification from 'navigator.credentials.notifySignedOut()' up to
// the browser process in order to clear the "zeroclick" bit on that origin's
// stored credentials. The browser process will respond with a
// CredentialManagerMsg_AcknowledgeSignedOut message.
IPC_MESSAGE_ROUTED1(CredentialManagerHostMsg_NotifySignedOut,
int /* request_id */)

// Requests a credential from the browser process in response to a page calling
// 'navigator.credentials.request()'. The browser process will respond with a
// CredentialManagerMsg_SendCredential message.
IPC_MESSAGE_ROUTED3(CredentialManagerHostMsg_RequestCredential,
int /* request_id */,
bool /* zero_click_only */,
std::vector<GURL> /* federations */)

// ----------------------------------------------------------------------------
// Messages sent from the browser to the renderer

// Notify the renderer that the browser process has finished processing a
// CredentialManagerHostMsg_NotifyFailedSignedIn message.
IPC_MESSAGE_ROUTED1(CredentialManagerMsg_AcknowledgeFailedSignIn,
int /* request_id */);

// Notify the renderer that the browser process has finished processing a
// CredentialManagerHostMsg_NotifySignedIn message.
IPC_MESSAGE_ROUTED1(CredentialManagerMsg_AcknowledgeSignedIn,
int /* request_id */);

// Notify the renderer that the browser process has finished processing a
// CredentialManagerHostMsg_NotifySignedOut message.
IPC_MESSAGE_ROUTED1(CredentialManagerMsg_AcknowledgeSignedOut,
int /* request_id */);

// Send a credential to the renderer in response to a
// CredentialManagerHostMsg_RequestCredential message.
IPC_MESSAGE_ROUTED2(CredentialManagerMsg_SendCredential,
int /* request_id */,
password_manager::CredentialInfo /* credential */)
Loading

0 comments on commit e08e2f5

Please sign in to comment.