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

Side by Side Diff: components/password_manager/content/browser/content_password_manager_driver_factory.cc

Issue 707173004: Refactor Autofill for out of process iframes (OOPIF). (Closed) Base URL: https://chromium.googlesource.com/chromium/src.git@master
Patch Set: mem leak Created 6 years 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
(Empty)
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
3 // found in the LICENSE file.
4
5 #include "components/password_manager/content/browser/content_password_manager_d river_factory.h"
6
7 #include "base/bind.h"
8 #include "base/stl_util.h"
9 #include "components/autofill/content/browser/content_autofill_driver.h"
10 #include "components/autofill/content/browser/content_autofill_driver_factory.h"
11 #include "components/autofill/content/common/autofill_messages.h"
12 #include "components/autofill/core/common/form_data.h"
13 #include "components/autofill/core/common/password_form.h"
14 #include "components/password_manager/content/browser/content_password_manager_d river.h"
15 #include "components/password_manager/core/browser/password_manager_client.h"
16 #include "content/public/browser/browser_context.h"
17 #include "content/public/browser/navigation_details.h"
18 #include "content/public/browser/navigation_entry.h"
19 #include "content/public/browser/render_frame_host.h"
20 #include "content/public/browser/render_view_host.h"
21 #include "content/public/browser/web_contents.h"
22 #include "content/public/common/ssl_status.h"
23 #include "ipc/ipc_message_macros.h"
24 #include "net/cert/cert_status_flags.h"
25
26 namespace password_manager {
27
28 namespace {
29
30 const char kContentPasswordManagerDriverFactoryWebContentsUserDataKey[] =
31 "web_contents_password_manager_driver_factory";
32
33 } // namespace
34
35 void ContentPasswordManagerDriverFactory::CreateForWebContents(
36 content::WebContents* web_contents,
37 PasswordManagerClient* password_client,
38 autofill::AutofillClient* autofill_client) {
39 if (FromWebContents(web_contents))
40 return;
41
42 web_contents->SetUserData(
43 kContentPasswordManagerDriverFactoryWebContentsUserDataKey,
44 new ContentPasswordManagerDriverFactory(web_contents, password_client,
45 autofill_client));
46 }
47
48 ContentPasswordManagerDriverFactory::ContentPasswordManagerDriverFactory(
49 content::WebContents* web_contents,
50 PasswordManagerClient* password_client,
51 autofill::AutofillClient* autofill_client)
52 : content::WebContentsObserver(web_contents),
53 password_client_(password_client),
54 autofill_client_(autofill_client) {
55 web_contents->ForEachFrame(
56 base::Bind(&ContentPasswordManagerDriverFactory::CreateDriverForFrame,
57 base::Unretained(this)));
58 }
59
60 ContentPasswordManagerDriverFactory::~ContentPasswordManagerDriverFactory() {
61 STLDeleteContainerPairSecondPointers(frame_driver_map_.begin(),
62 frame_driver_map_.end());
63 frame_driver_map_.clear();
64 }
65
66 // static
67 ContentPasswordManagerDriverFactory*
68 ContentPasswordManagerDriverFactory::FromWebContents(
69 content::WebContents* contents) {
70 return static_cast<ContentPasswordManagerDriverFactory*>(
71 contents->GetUserData(
72 kContentPasswordManagerDriverFactoryWebContentsUserDataKey));
73 }
74
75 ContentPasswordManagerDriver*
76 ContentPasswordManagerDriverFactory::GetDriverForFrame(
77 content::RenderFrameHost* render_frame_host) {
78 return frame_driver_map_[render_frame_host];
79 }
80
81 void ContentPasswordManagerDriverFactory::RenderFrameCreated(
82 content::RenderFrameHost* render_frame_host) {
83 // The driver for the main frame will have already been created.
84 if (!frame_driver_map_[render_frame_host])
85 CreateDriverForFrame(render_frame_host);
86 }
87
88 void ContentPasswordManagerDriverFactory::RenderFrameDeleted(
89 content::RenderFrameHost* render_frame_host) {
90 delete frame_driver_map_[render_frame_host];
91 frame_driver_map_.erase(render_frame_host);
92 }
93
94 bool ContentPasswordManagerDriverFactory::OnMessageReceived(
95 const IPC::Message& message,
96 content::RenderFrameHost* render_frame_host) {
97 return frame_driver_map_[render_frame_host]->HandleMessage(message);
98 }
99
100 void ContentPasswordManagerDriverFactory::DidNavigateAnyFrame(
101 content::RenderFrameHost* render_frame_host,
102 const content::LoadCommittedDetails& details,
103 const content::FrameNavigateParams& params) {
104 frame_driver_map_[render_frame_host]->DidNavigateFrame(details, params);
105 }
106
107 void ContentPasswordManagerDriverFactory::CreateDriverForFrame(
108 content::RenderFrameHost* render_frame_host) {
109 DCHECK(!frame_driver_map_[render_frame_host]);
110 frame_driver_map_[render_frame_host] = new ContentPasswordManagerDriver(
111 render_frame_host, password_client_, autofill_client_);
112 }
113
114 } // namespace password_manager
OLDNEW

Powered by Google App Engine
This is Rietveld 408576698