OLD | NEW |
---|---|
1 // Copyright (c) 2011 The Chromium Authors. All rights reserved. | 1 // Copyright (c) 2011 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 "chrome/browser/automation/automation_provider_observers.h" | 5 #include "chrome/browser/automation/automation_provider_observers.h" |
6 | 6 |
7 #include <deque> | 7 #include <deque> |
8 #include <string> | 8 #include <string> |
9 #include <vector> | 9 #include <vector> |
10 | 10 |
(...skipping 15 matching lines...) Expand all Loading... | |
26 #include "chrome/browser/browser_process.h" | 26 #include "chrome/browser/browser_process.h" |
27 #include "chrome/browser/dom_operation_notification_details.h" | 27 #include "chrome/browser/dom_operation_notification_details.h" |
28 #include "chrome/browser/extensions/crx_installer.h" | 28 #include "chrome/browser/extensions/crx_installer.h" |
29 #include "chrome/browser/extensions/extension_host.h" | 29 #include "chrome/browser/extensions/extension_host.h" |
30 #include "chrome/browser/extensions/extension_process_manager.h" | 30 #include "chrome/browser/extensions/extension_process_manager.h" |
31 #include "chrome/browser/extensions/extension_service.h" | 31 #include "chrome/browser/extensions/extension_service.h" |
32 #include "chrome/browser/extensions/extension_tabs_module.h" | 32 #include "chrome/browser/extensions/extension_tabs_module.h" |
33 #include "chrome/browser/extensions/extension_updater.h" | 33 #include "chrome/browser/extensions/extension_updater.h" |
34 #include "chrome/browser/history/history_types.h" | 34 #include "chrome/browser/history/history_types.h" |
35 #include "chrome/browser/history/top_sites.h" | 35 #include "chrome/browser/history/top_sites.h" |
36 #include "chrome/browser/infobars/infobar_tab_helper.h" | |
36 #include "chrome/browser/metrics/metric_event_duration_details.h" | 37 #include "chrome/browser/metrics/metric_event_duration_details.h" |
37 #include "chrome/browser/notifications/balloon.h" | 38 #include "chrome/browser/notifications/balloon.h" |
38 #include "chrome/browser/notifications/balloon_collection.h" | 39 #include "chrome/browser/notifications/balloon_collection.h" |
39 #include "chrome/browser/notifications/balloon_host.h" | 40 #include "chrome/browser/notifications/balloon_host.h" |
40 #include "chrome/browser/notifications/notification.h" | 41 #include "chrome/browser/notifications/notification.h" |
41 #include "chrome/browser/notifications/notification_ui_manager.h" | 42 #include "chrome/browser/notifications/notification_ui_manager.h" |
42 #include "chrome/browser/password_manager/password_store_change.h" | 43 #include "chrome/browser/password_manager/password_store_change.h" |
43 #include "chrome/browser/printing/print_job.h" | 44 #include "chrome/browser/printing/print_job.h" |
44 #include "chrome/browser/profiles/profile.h" | 45 #include "chrome/browser/profiles/profile.h" |
45 #include "chrome/browser/search_engines/template_url_service.h" | 46 #include "chrome/browser/search_engines/template_url_service.h" |
(...skipping 1319 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... | |
1365 | 1366 |
1366 void InfoBarCountObserver::Observe(int type, | 1367 void InfoBarCountObserver::Observe(int type, |
1367 const NotificationSource& source, | 1368 const NotificationSource& source, |
1368 const NotificationDetails& details) { | 1369 const NotificationDetails& details) { |
1369 DCHECK(type == chrome::NOTIFICATION_TAB_CONTENTS_INFOBAR_ADDED || | 1370 DCHECK(type == chrome::NOTIFICATION_TAB_CONTENTS_INFOBAR_ADDED || |
1370 type == chrome::NOTIFICATION_TAB_CONTENTS_INFOBAR_REMOVED); | 1371 type == chrome::NOTIFICATION_TAB_CONTENTS_INFOBAR_REMOVED); |
1371 CheckCount(); | 1372 CheckCount(); |
1372 } | 1373 } |
1373 | 1374 |
1374 void InfoBarCountObserver::CheckCount() { | 1375 void InfoBarCountObserver::CheckCount() { |
1375 if (tab_contents_->infobar_count() != target_count_) | 1376 if (tab_contents_->infobar_tab_helper()->infobar_count() != target_count_) |
1376 return; | 1377 return; |
1377 | 1378 |
1378 if (automation_) { | 1379 if (automation_) { |
1379 AutomationMsg_WaitForInfoBarCount::WriteReplyParams(reply_message_.get(), | 1380 AutomationMsg_WaitForInfoBarCount::WriteReplyParams(reply_message_.get(), |
1380 true); | 1381 true); |
1381 automation_->Send(reply_message_.release()); | 1382 automation_->Send(reply_message_.release()); |
1382 } | 1383 } |
1383 delete this; | 1384 delete this; |
1384 } | 1385 } |
1385 | 1386 |
(...skipping 896 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... | |
2282 pdm_->SetObserver(this); | 2283 pdm_->SetObserver(this); |
2283 registrar_.Add(this, chrome::NOTIFICATION_TAB_CONTENTS_INFOBAR_ADDED, | 2284 registrar_.Add(this, chrome::NOTIFICATION_TAB_CONTENTS_INFOBAR_ADDED, |
2284 NotificationService::AllSources()); | 2285 NotificationService::AllSources()); |
2285 } | 2286 } |
2286 | 2287 |
2287 AutofillFormSubmittedObserver::~AutofillFormSubmittedObserver() { | 2288 AutofillFormSubmittedObserver::~AutofillFormSubmittedObserver() { |
2288 pdm_->RemoveObserver(this); | 2289 pdm_->RemoveObserver(this); |
2289 | 2290 |
2290 if (tab_contents_) { | 2291 if (tab_contents_) { |
2291 InfoBarDelegate* infobar = NULL; | 2292 InfoBarDelegate* infobar = NULL; |
2292 if (tab_contents_->infobar_count() > 0 && | 2293 if (tab_contents_->infobar_tab_helper()->infobar_count() > 0 && |
Peter Kasting
2011/08/31 18:47:32
Nit: Can you pull the infobar_tab_helper() out to
| |
2293 (infobar = tab_contents_->GetInfoBarDelegateAt(0))) { | 2294 (infobar = |
2294 tab_contents_->RemoveInfoBar(infobar); | 2295 tab_contents_->infobar_tab_helper()->GetInfoBarDelegateAt(0))) { |
2296 tab_contents_->infobar_tab_helper()->RemoveInfoBar(infobar); | |
2295 } | 2297 } |
2296 } | 2298 } |
2297 } | 2299 } |
2298 | 2300 |
2299 void AutofillFormSubmittedObserver::OnPersonalDataChanged() { | 2301 void AutofillFormSubmittedObserver::OnPersonalDataChanged() { |
2300 if (automation_) { | 2302 if (automation_) { |
2301 AutomationJSONReply(automation_, | 2303 AutomationJSONReply(automation_, |
2302 reply_message_.release()).SendSuccess(NULL); | 2304 reply_message_.release()).SendSuccess(NULL); |
2303 } | 2305 } |
2304 delete this; | 2306 delete this; |
2305 } | 2307 } |
2306 | 2308 |
2307 void AutofillFormSubmittedObserver::OnInsufficientFormData() { | 2309 void AutofillFormSubmittedObserver::OnInsufficientFormData() { |
2308 if (automation_) { | 2310 if (automation_) { |
2309 AutomationJSONReply(automation_, | 2311 AutomationJSONReply(automation_, |
2310 reply_message_.release()).SendSuccess(NULL); | 2312 reply_message_.release()).SendSuccess(NULL); |
2311 } | 2313 } |
2312 delete this; | 2314 delete this; |
2313 } | 2315 } |
2314 | 2316 |
2315 void AutofillFormSubmittedObserver::Observe( | 2317 void AutofillFormSubmittedObserver::Observe( |
2316 int type, | 2318 int type, |
2317 const NotificationSource& source, | 2319 const NotificationSource& source, |
2318 const NotificationDetails& details) { | 2320 const NotificationDetails& details) { |
2319 DCHECK(type == chrome::NOTIFICATION_TAB_CONTENTS_INFOBAR_ADDED); | 2321 DCHECK(type == chrome::NOTIFICATION_TAB_CONTENTS_INFOBAR_ADDED); |
2320 // Accept in the infobar. | 2322 // Accept in the infobar. |
2321 tab_contents_ = Source<TabContentsWrapper>(source).ptr(); | 2323 tab_contents_ = Source<TabContentsWrapper>(source).ptr(); |
2322 InfoBarDelegate* infobar = NULL; | 2324 InfoBarDelegate* infobar = NULL; |
2323 if (!(infobar = tab_contents_->GetInfoBarDelegateAt(0))) { | 2325 if (!(infobar = |
Peter Kasting
2011/08/31 18:47:32
Nit: While here, remove this conditional entirely
| |
2326 tab_contents_->infobar_tab_helper()->GetInfoBarDelegateAt(0))) { | |
2324 if (automation_) { | 2327 if (automation_) { |
2325 AutomationJSONReply( | 2328 AutomationJSONReply( |
2326 automation_, reply_message_.release()).SendError( | 2329 automation_, reply_message_.release()).SendError( |
2327 "Could not identify the infobar delegate."); | 2330 "Could not identify the infobar delegate."); |
2328 } | 2331 } |
2329 delete this; | 2332 delete this; |
2330 return; | 2333 return; |
2331 } | 2334 } |
2332 ConfirmInfoBarDelegate* confirm_infobar; | 2335 ConfirmInfoBarDelegate* confirm_infobar; |
2333 if (!(confirm_infobar = infobar->AsConfirmInfoBarDelegate())) { | 2336 if (!(confirm_infobar = infobar->AsConfirmInfoBarDelegate())) { |
Peter Kasting
2011/08/31 18:47:32
Nit: While here, can you fix this conditional to a
| |
2334 if (automation_) { | 2337 if (automation_) { |
2335 AutomationJSONReply( | 2338 AutomationJSONReply( |
2336 automation_, reply_message_.release()).SendError( | 2339 automation_, reply_message_.release()).SendError( |
2337 "Infobar is not a confirm infobar."); | 2340 "Infobar is not a confirm infobar."); |
2338 } | 2341 } |
2339 delete this; | 2342 delete this; |
2340 return; | 2343 return; |
2341 } | 2344 } |
2342 if (!(confirm_infobar->Accept())) { | 2345 if (!(confirm_infobar->Accept())) { |
Peter Kasting
2011/08/31 18:47:32
Nit: Extra parens
| |
2343 if (automation_) { | 2346 if (automation_) { |
2344 AutomationJSONReply( | 2347 AutomationJSONReply( |
2345 automation_, reply_message_.release()).SendError( | 2348 automation_, reply_message_.release()).SendError( |
2346 "Could not accept in the infobar."); | 2349 "Could not accept in the infobar."); |
2347 } | 2350 } |
2348 delete this; | 2351 delete this; |
2349 return; | 2352 return; |
2350 } | 2353 } |
2351 } | 2354 } |
2352 | 2355 |
(...skipping 350 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... | |
2703 void DragTargetDropAckNotificationObserver::Observe( | 2706 void DragTargetDropAckNotificationObserver::Observe( |
2704 int type, | 2707 int type, |
2705 const NotificationSource& source, | 2708 const NotificationSource& source, |
2706 const NotificationDetails& details) { | 2709 const NotificationDetails& details) { |
2707 if (automation_) { | 2710 if (automation_) { |
2708 AutomationJSONReply(automation_, | 2711 AutomationJSONReply(automation_, |
2709 reply_message_.release()).SendSuccess(NULL); | 2712 reply_message_.release()).SendSuccess(NULL); |
2710 } | 2713 } |
2711 delete this; | 2714 delete this; |
2712 } | 2715 } |
OLD | NEW |