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

Side by Side Diff: components/autofill/content/browser/content_autofill_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/autofill/content/browser/content_autofill_driver_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/core/browser/autofill_client.h"
11 #include "components/autofill/core/browser/autofill_manager.h"
12 #include "components/autofill/core/browser/form_structure.h"
13 #include "components/autofill/core/common/autofill_switches.h"
14 #include "content/public/browser/render_frame_host.h"
15 #include "content/public/browser/web_contents.h"
16 #include "ipc/ipc_message_macros.h"
17
18 namespace autofill {
19
20 const char ContentAutofillDriverFactory::
21 kContentAutofillDriverFactoryWebContentsUserDataKey[] =
22 "web_contents_autofill_driver_factory";
23
24 // static
25 void ContentAutofillDriverFactory::CreateForWebContentsAndDelegate(
26 content::WebContents* contents,
27 AutofillClient* client,
28 const std::string& app_locale,
29 AutofillManager::AutofillDownloadManagerState enable_download_manager) {
30 if (FromWebContents(contents))
31 return;
32
33 contents->SetUserData(
34 kContentAutofillDriverFactoryWebContentsUserDataKey,
35 new ContentAutofillDriverFactory(contents, client, app_locale,
36 enable_download_manager));
37 }
38
39 // static
40 ContentAutofillDriverFactory* ContentAutofillDriverFactory::FromWebContents(
41 content::WebContents* contents) {
42 return static_cast<ContentAutofillDriverFactory*>(contents->GetUserData(
43 kContentAutofillDriverFactoryWebContentsUserDataKey));
44 }
45
46 ContentAutofillDriverFactory::ContentAutofillDriverFactory(
47 content::WebContents* web_contents,
48 AutofillClient* client,
49 const std::string& app_locale,
50 AutofillManager::AutofillDownloadManagerState enable_download_manager)
51 : content::WebContentsObserver(web_contents),
52 client_(client),
53 app_locale_(app_locale),
54 enable_download_manager_(enable_download_manager) {
55 web_contents->ForEachFrame(
56 base::Bind(&ContentAutofillDriverFactory::CreateDriverForFrame,
57 base::Unretained(this)));
58 }
59
60 ContentAutofillDriverFactory::~ContentAutofillDriverFactory() {
61 STLDeleteContainerPairSecondPointers(frame_driver_map_.begin(),
62 frame_driver_map_.end());
63 frame_driver_map_.clear();
64 }
65
66 ContentAutofillDriver* ContentAutofillDriverFactory::DriverForFrame(
67 content::RenderFrameHost* render_frame_host) {
68 return frame_driver_map_[render_frame_host];
69 }
70
71 bool ContentAutofillDriverFactory::OnMessageReceived(
72 const IPC::Message& message,
73 content::RenderFrameHost* render_frame_host) {
74 return frame_driver_map_[render_frame_host]->HandleMessage(message);
75 }
76
77 void ContentAutofillDriverFactory::RenderFrameCreated(
78 content::RenderFrameHost* render_frame_host) {
79 // The driver for the main frame has already been created.
80 if (!frame_driver_map_[render_frame_host])
81 CreateDriverForFrame(render_frame_host);
82 }
83
84 void ContentAutofillDriverFactory::RenderFrameDeleted(
85 content::RenderFrameHost* render_frame_host) {
86 delete frame_driver_map_[render_frame_host];
87 frame_driver_map_.erase(render_frame_host);
88 }
89
90 void ContentAutofillDriverFactory::DidNavigateAnyFrame(
91 content::RenderFrameHost* render_frame_host,
92 const content::LoadCommittedDetails& details,
93 const content::FrameNavigateParams& params) {
94 frame_driver_map_[render_frame_host]->DidNavigateFrame(details, params);
95 }
96
97 void ContentAutofillDriverFactory::NavigationEntryCommitted(
98 const content::LoadCommittedDetails& load_details) {
99 client_->HideAutofillPopup();
100 }
101
102 void ContentAutofillDriverFactory::WasHidden() {
103 client_->HideAutofillPopup();
104 }
105
106 void ContentAutofillDriverFactory::CreateDriverForFrame(
107 content::RenderFrameHost* render_frame_host) {
108 DCHECK(!frame_driver_map_[render_frame_host]);
109 frame_driver_map_[render_frame_host] = new ContentAutofillDriver(
110 render_frame_host, client_, app_locale_, enable_download_manager_);
111 }
112
113 } // namespace autofill
OLDNEW

Powered by Google App Engine
This is Rietveld 408576698