OLD | NEW |
1 // Copyright 2013 The Chromium Authors. All rights reserved. | 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 | 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 #include "components/autofill/content/browser/autofill_driver_impl.h" | 5 #include "components/autofill/content/browser/autofill_driver_impl.h" |
6 | 6 |
7 #include "components/autofill/core/browser/autofill_external_delegate.h" | 7 #include "components/autofill/core/browser/autofill_external_delegate.h" |
8 #include "components/autofill/core/browser/autofill_manager.h" | 8 #include "components/autofill/core/browser/autofill_manager.h" |
9 #include "components/autofill/core/browser/autofill_manager_delegate.h" | 9 #include "components/autofill/core/browser/autofill_manager_delegate.h" |
10 #include "components/autofill/core/common/autofill_messages.h" | 10 #include "components/autofill/core/common/autofill_messages.h" |
| 11 #include "content/public/browser/navigation_controller.h" |
11 #include "content/public/browser/navigation_details.h" | 12 #include "content/public/browser/navigation_details.h" |
| 13 #include "content/public/browser/notification_service.h" |
| 14 #include "content/public/browser/notification_source.h" |
| 15 #include "content/public/browser/notification_types.h" |
12 #include "content/public/browser/web_contents.h" | 16 #include "content/public/browser/web_contents.h" |
13 #include "content/public/common/frame_navigate_params.h" | 17 #include "content/public/common/frame_navigate_params.h" |
14 #include "ipc/ipc_message_macros.h" | 18 #include "ipc/ipc_message_macros.h" |
15 | 19 |
16 namespace autofill { | 20 namespace autofill { |
17 | 21 |
18 namespace { | 22 namespace { |
19 | 23 |
20 const char kAutofillDriverImplWebContentsUserDataKey[] = | 24 const char kAutofillDriverImplWebContentsUserDataKey[] = |
21 "web_contents_autofill_driver_impl"; | 25 "web_contents_autofill_driver_impl"; |
(...skipping 31 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
53 AutofillDriverImpl::AutofillDriverImpl( | 57 AutofillDriverImpl::AutofillDriverImpl( |
54 content::WebContents* web_contents, | 58 content::WebContents* web_contents, |
55 autofill::AutofillManagerDelegate* delegate, | 59 autofill::AutofillManagerDelegate* delegate, |
56 const std::string& app_locale, | 60 const std::string& app_locale, |
57 AutofillManager::AutofillDownloadManagerState enable_download_manager) | 61 AutofillManager::AutofillDownloadManagerState enable_download_manager) |
58 : content::WebContentsObserver(web_contents), | 62 : content::WebContentsObserver(web_contents), |
59 autofill_manager_(new AutofillManager( | 63 autofill_manager_(new AutofillManager( |
60 this, delegate, app_locale, enable_download_manager)) { | 64 this, delegate, app_locale, enable_download_manager)) { |
61 SetAutofillExternalDelegate(scoped_ptr<AutofillExternalDelegate>( | 65 SetAutofillExternalDelegate(scoped_ptr<AutofillExternalDelegate>( |
62 new AutofillExternalDelegate(web_contents, autofill_manager_.get()))); | 66 new AutofillExternalDelegate(web_contents, autofill_manager_.get()))); |
| 67 |
| 68 registrar_.Add(this, |
| 69 content::NOTIFICATION_WEB_CONTENTS_VISIBILITY_CHANGED, |
| 70 content::Source<content::WebContents>(web_contents)); |
| 71 registrar_.Add( |
| 72 this, |
| 73 content::NOTIFICATION_NAV_ENTRY_COMMITTED, |
| 74 content::Source<content::NavigationController>( |
| 75 &(web_contents->GetController()))); |
63 } | 76 } |
64 | 77 |
65 AutofillDriverImpl::~AutofillDriverImpl() {} | 78 AutofillDriverImpl::~AutofillDriverImpl() {} |
66 | 79 |
67 content::WebContents* AutofillDriverImpl::GetWebContents() { | 80 content::WebContents* AutofillDriverImpl::GetWebContents() { |
68 return web_contents(); | 81 return web_contents(); |
69 } | 82 } |
70 | 83 |
71 bool AutofillDriverImpl::OnMessageReceived(const IPC::Message& message) { | 84 bool AutofillDriverImpl::OnMessageReceived(const IPC::Message& message) { |
72 bool handled = true; | 85 bool handled = true; |
(...skipping 64 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
137 autofill_external_delegate_ = delegate.Pass(); | 150 autofill_external_delegate_ = delegate.Pass(); |
138 autofill_manager_->SetExternalDelegate(autofill_external_delegate_.get()); | 151 autofill_manager_->SetExternalDelegate(autofill_external_delegate_.get()); |
139 } | 152 } |
140 | 153 |
141 void AutofillDriverImpl::SetAutofillManager( | 154 void AutofillDriverImpl::SetAutofillManager( |
142 scoped_ptr<AutofillManager> manager) { | 155 scoped_ptr<AutofillManager> manager) { |
143 autofill_manager_ = manager.Pass(); | 156 autofill_manager_ = manager.Pass(); |
144 autofill_manager_->SetExternalDelegate(autofill_external_delegate_.get()); | 157 autofill_manager_->SetExternalDelegate(autofill_external_delegate_.get()); |
145 } | 158 } |
146 | 159 |
| 160 void AutofillDriverImpl::Observe( |
| 161 int type, |
| 162 const content::NotificationSource& source, |
| 163 const content::NotificationDetails& details) { |
| 164 if (type == content::NOTIFICATION_WEB_CONTENTS_VISIBILITY_CHANGED) { |
| 165 if (!*content::Details<bool>(details).ptr()) |
| 166 autofill_manager_->delegate()->HideAutofillPopup(); |
| 167 } else if (type == content::NOTIFICATION_NAV_ENTRY_COMMITTED) { |
| 168 autofill_manager_->delegate()->HideAutofillPopup(); |
| 169 } else { |
| 170 NOTREACHED(); |
| 171 } |
| 172 } |
| 173 |
147 } // namespace autofill | 174 } // namespace autofill |
OLD | NEW |