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

Side by Side Diff: chrome/browser/automation/automation_provider_observers.cc

Issue 7810002: Move infobar handling to a tab helper. (Closed) Base URL: svn://svn.chromium.org/chrome/trunk/src
Patch Set: fixes Created 9 years, 3 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 | Annotate | Revision Log
OLDNEW
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
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
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 895 matching lines...) Expand 10 before | Expand all | Expand 10 after
2281 tab_contents_(NULL) { 2282 tab_contents_(NULL) {
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_) {
2292 InfoBarTabHelper* infobar_helper = tab_contents_->infobar_tab_helper();
2291 InfoBarDelegate* infobar = NULL; 2293 InfoBarDelegate* infobar = NULL;
2292 if (tab_contents_->infobar_count() > 0 && 2294 if (infobar_helper->infobar_count() > 0 &&
2293 (infobar = tab_contents_->GetInfoBarDelegateAt(0))) { 2295 (infobar = infobar_helper->GetInfoBarDelegateAt(0))) {
2294 tab_contents_->RemoveInfoBar(infobar); 2296 infobar_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);
2322
2320 // Accept in the infobar. 2323 // Accept in the infobar.
2321 tab_contents_ = Source<TabContentsWrapper>(source).ptr(); 2324 tab_contents_ = Source<TabContentsWrapper>(source).ptr();
2322 InfoBarDelegate* infobar = NULL; 2325 InfoBarDelegate* infobar = NULL;
2323 if (!(infobar = tab_contents_->GetInfoBarDelegateAt(0))) { 2326 infobar = tab_contents_->infobar_tab_helper()->GetInfoBarDelegateAt(0);
2327
2328 ConfirmInfoBarDelegate* confirm_infobar = infobar->AsConfirmInfoBarDelegate();
2329 if (!confirm_infobar) {
2324 if (automation_) { 2330 if (automation_) {
2325 AutomationJSONReply( 2331 AutomationJSONReply(
2326 automation_, reply_message_.release()).SendError( 2332 automation_, reply_message_.release()).SendError(
2327 "Could not identify the infobar delegate.");
2328 }
2329 delete this;
2330 return;
2331 }
2332 ConfirmInfoBarDelegate* confirm_infobar;
2333 if (!(confirm_infobar = infobar->AsConfirmInfoBarDelegate())) {
2334 if (automation_) {
2335 AutomationJSONReply(
2336 automation_, reply_message_.release()).SendError(
2337 "Infobar is not a confirm infobar."); 2333 "Infobar is not a confirm infobar.");
2338 } 2334 }
2339 delete this; 2335 delete this;
2340 return; 2336 return;
2341 } 2337 }
2342 if (!(confirm_infobar->Accept())) { 2338
2339 if (!confirm_infobar->Accept()) {
2343 if (automation_) { 2340 if (automation_) {
2344 AutomationJSONReply( 2341 AutomationJSONReply(
2345 automation_, reply_message_.release()).SendError( 2342 automation_, reply_message_.release()).SendError(
2346 "Could not accept in the infobar."); 2343 "Could not accept in the infobar.");
2347 } 2344 }
2348 delete this; 2345 delete this;
2349 return; 2346 return;
2350 } 2347 }
2351 } 2348 }
2352 2349
(...skipping 350 matching lines...) Expand 10 before | Expand all | Expand 10 after
2703 void DragTargetDropAckNotificationObserver::Observe( 2700 void DragTargetDropAckNotificationObserver::Observe(
2704 int type, 2701 int type,
2705 const NotificationSource& source, 2702 const NotificationSource& source,
2706 const NotificationDetails& details) { 2703 const NotificationDetails& details) {
2707 if (automation_) { 2704 if (automation_) {
2708 AutomationJSONReply(automation_, 2705 AutomationJSONReply(automation_,
2709 reply_message_.release()).SendSuccess(NULL); 2706 reply_message_.release()).SendSuccess(NULL);
2710 } 2707 }
2711 delete this; 2708 delete this;
2712 } 2709 }
OLDNEW
« no previous file with comments | « chrome/browser/autofill/autofill_manager.cc ('k') | chrome/browser/automation/testing_automation_provider.cc » ('j') | no next file with comments »

Powered by Google App Engine
This is Rietveld 408576698