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

Side by Side Diff: components/autofill/content/browser/autofill_driver_impl.cc

Issue 16286020: Abstract WebContentsObserver from Autofill shared code (Closed) Base URL: http://git.chromium.org/chromium/src.git@master
Patch Set: Rebase to fix conflict Created 7 years, 6 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
« no previous file with comments | « components/autofill/content/browser/autofill_driver_impl.h ('k') | no next file » | no next file with comments »
Toggle Intra-line Diffs ('i') | Expand Comments ('e') | Collapse Comments ('c') | Show Comments Hide Comments ('s')
OLDNEW
(Empty)
1 // Copyright 2013 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/autofill_driver_impl.h"
6
7 #include "components/autofill/browser/autofill_external_delegate.h"
8 #include "components/autofill/browser/autofill_manager.h"
9 #include "components/autofill/browser/autofill_manager_delegate.h"
10 #include "content/public/browser/web_contents.h"
11
12 namespace autofill {
13
14 namespace {
15
16 const char kAutofillDriverImplWebContentsUserDataKey[] =
17 "web_contents_autofill_driver_impl";
18
19 } // namespace
20
21 // static
22 void AutofillDriverImpl::CreateForWebContentsAndDelegate(
23 content::WebContents* contents,
24 autofill::AutofillManagerDelegate* delegate,
25 const std::string& app_locale,
26 AutofillManager::AutofillDownloadManagerState enable_download_manager,
27 bool enable_native_ui) {
28 if (FromWebContents(contents))
29 return;
30
31 contents->SetUserData(kAutofillDriverImplWebContentsUserDataKey,
32 new AutofillDriverImpl(contents,
33 delegate,
34 app_locale,
35 enable_download_manager,
36 enable_native_ui));
37 // Trigger the lazy creation of AutocheckoutWhitelistManagerService, and
38 // schedule a fetch of the Autocheckout whitelist file if it's not already
39 // loaded. This helps ensure that the whitelist will be available by the time
40 // the user navigates to a form on which Autocheckout should be enabled.
41 delegate->GetAutocheckoutWhitelistManager();
42 }
43
44 // static
45 AutofillDriverImpl* AutofillDriverImpl::FromWebContents(
46 content::WebContents* contents) {
47 return static_cast<AutofillDriverImpl*>(
48 contents->GetUserData(kAutofillDriverImplWebContentsUserDataKey));
49 }
50
51 AutofillDriverImpl::AutofillDriverImpl(
52 content::WebContents* web_contents,
53 autofill::AutofillManagerDelegate* delegate,
54 const std::string& app_locale,
55 AutofillManager::AutofillDownloadManagerState enable_download_manager,
56 bool enable_native_ui)
57 : content::WebContentsObserver(web_contents),
58 autofill_manager_(this, delegate, app_locale, enable_download_manager) {
59 if (enable_native_ui) {
60 // TODO(blundell): Eliminate AutofillExternalDelegate being a WCUD and
61 // transfer ownership of it to this class.
62 AutofillExternalDelegate::CreateForWebContentsAndManager(
63 web_contents, &autofill_manager_);
64 autofill_manager_.SetExternalDelegate(
65 AutofillExternalDelegate::FromWebContents(web_contents));
66 }
67 }
68
69 AutofillDriverImpl::~AutofillDriverImpl() {}
70
71 content::WebContents* AutofillDriverImpl::GetWebContents() {
72 return web_contents();
73 }
74
75 bool AutofillDriverImpl::OnMessageReceived(const IPC::Message& message) {
76 // TODO(blundell): Move IPC handling into this class.
77 return autofill_manager_.OnMessageReceived(message);
78 }
79
80 void AutofillDriverImpl::DidNavigateMainFrame(
81 const content::LoadCommittedDetails& details,
82 const content::FrameNavigateParams& params) {
83 // TODO(blundell): Move the logic of this method into this class.
84 autofill_manager_.DidNavigateMainFrame(details, params);
85 }
86
87 } // namespace autofill
OLDNEW
« no previous file with comments | « components/autofill/content/browser/autofill_driver_impl.h ('k') | no next file » | no next file with comments »

Powered by Google App Engine
This is Rietveld 408576698