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

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

Issue 7327007: Moving notification types which are chrome specific to a new header file chrome_notification_type... (Closed) Base URL: svn://svn.chromium.org/chrome/trunk/src/
Patch Set: '' Created 9 years, 5 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 42 matching lines...) Expand 10 before | Expand all | Expand 10 after
53 #include "chrome/browser/translate/translate_tab_helper.h" 53 #include "chrome/browser/translate/translate_tab_helper.h"
54 #include "chrome/browser/ui/browser.h" 54 #include "chrome/browser/ui/browser.h"
55 #include "chrome/browser/ui/browser_list.h" 55 #include "chrome/browser/ui/browser_list.h"
56 #include "chrome/browser/ui/find_bar/find_notification_details.h" 56 #include "chrome/browser/ui/find_bar/find_notification_details.h"
57 #include "chrome/browser/ui/login/login_prompt.h" 57 #include "chrome/browser/ui/login/login_prompt.h"
58 #include "chrome/browser/ui/tab_contents/tab_contents_wrapper.h" 58 #include "chrome/browser/ui/tab_contents/tab_contents_wrapper.h"
59 #include "chrome/browser/ui/webui/ntp/app_launcher_handler.h" 59 #include "chrome/browser/ui/webui/ntp/app_launcher_handler.h"
60 #include "chrome/browser/ui/webui/ntp/most_visited_handler.h" 60 #include "chrome/browser/ui/webui/ntp/most_visited_handler.h"
61 #include "chrome/browser/ui/webui/ntp/new_tab_ui.h" 61 #include "chrome/browser/ui/webui/ntp/new_tab_ui.h"
62 #include "chrome/common/automation_messages.h" 62 #include "chrome/common/automation_messages.h"
63 #include "chrome/common/chrome_notification_types.h"
63 #include "chrome/common/extensions/extension.h" 64 #include "chrome/common/extensions/extension.h"
64 #include "content/browser/renderer_host/render_process_host.h" 65 #include "content/browser/renderer_host/render_process_host.h"
65 #include "content/browser/renderer_host/render_view_host.h" 66 #include "content/browser/renderer_host/render_view_host.h"
66 #include "content/browser/tab_contents/navigation_controller.h" 67 #include "content/browser/tab_contents/navigation_controller.h"
67 #include "content/browser/tab_contents/tab_contents.h" 68 #include "content/browser/tab_contents/tab_contents.h"
68 #include "content/common/notification_service.h" 69 #include "content/common/notification_service.h"
69 #include "googleurl/src/gurl.h" 70 #include "googleurl/src/gurl.h"
70 #include "ui/gfx/codec/png_codec.h" 71 #include "ui/gfx/codec/png_codec.h"
71 #include "ui/gfx/rect.h" 72 #include "ui/gfx/rect.h"
72 73
(...skipping 79 matching lines...) Expand 10 before | Expand all | Expand 10 after
152 } 153 }
153 154
154 void InitialLoadObserver::ConditionMet() { 155 void InitialLoadObserver::ConditionMet() {
155 registrar_.RemoveAll(); 156 registrar_.RemoveAll();
156 if (automation_) 157 if (automation_)
157 automation_->OnInitialTabLoadsComplete(); 158 automation_->OnInitialTabLoadsComplete();
158 } 159 }
159 160
160 NewTabUILoadObserver::NewTabUILoadObserver(AutomationProvider* automation) 161 NewTabUILoadObserver::NewTabUILoadObserver(AutomationProvider* automation)
161 : automation_(automation->AsWeakPtr()) { 162 : automation_(automation->AsWeakPtr()) {
162 registrar_.Add(this, NotificationType::INITIAL_NEW_TAB_UI_LOAD, 163 registrar_.Add(this, chrome::INITIAL_NEW_TAB_UI_LOAD,
163 NotificationService::AllSources()); 164 NotificationService::AllSources());
164 } 165 }
165 166
166 NewTabUILoadObserver::~NewTabUILoadObserver() { 167 NewTabUILoadObserver::~NewTabUILoadObserver() {
167 } 168 }
168 169
169 void NewTabUILoadObserver::Observe(NotificationType type, 170 void NewTabUILoadObserver::Observe(NotificationType type,
170 const NotificationSource& source, 171 const NotificationSource& source,
171 const NotificationDetails& details) { 172 const NotificationDetails& details) {
172 if (type == NotificationType::INITIAL_NEW_TAB_UI_LOAD) { 173 if (type == chrome::INITIAL_NEW_TAB_UI_LOAD) {
173 Details<int> load_time(details); 174 Details<int> load_time(details);
174 if (automation_) { 175 if (automation_) {
175 automation_->Send( 176 automation_->Send(
176 new AutomationMsg_InitialNewTabUILoadComplete(*load_time.ptr())); 177 new AutomationMsg_InitialNewTabUILoadComplete(*load_time.ptr()));
177 } 178 }
178 } else { 179 } else {
179 NOTREACHED(); 180 NOTREACHED();
180 } 181 }
181 } 182 }
182 183
(...skipping 49 matching lines...) Expand 10 before | Expand all | Expand 10 after
232 reply_message_(reply_message), 233 reply_message_(reply_message),
233 controller_(controller), 234 controller_(controller),
234 navigations_remaining_(number_of_navigations), 235 navigations_remaining_(number_of_navigations),
235 navigation_started_(false), 236 navigation_started_(false),
236 use_json_interface_(use_json_interface) { 237 use_json_interface_(use_json_interface) {
237 DCHECK_LT(0, navigations_remaining_); 238 DCHECK_LT(0, navigations_remaining_);
238 Source<NavigationController> source(controller_); 239 Source<NavigationController> source(controller_);
239 registrar_.Add(this, NotificationType::NAV_ENTRY_COMMITTED, source); 240 registrar_.Add(this, NotificationType::NAV_ENTRY_COMMITTED, source);
240 registrar_.Add(this, NotificationType::LOAD_START, source); 241 registrar_.Add(this, NotificationType::LOAD_START, source);
241 registrar_.Add(this, NotificationType::LOAD_STOP, source); 242 registrar_.Add(this, NotificationType::LOAD_STOP, source);
242 registrar_.Add(this, NotificationType::AUTH_NEEDED, source); 243 registrar_.Add(this, chrome::AUTH_NEEDED, source);
243 registrar_.Add(this, NotificationType::AUTH_SUPPLIED, source); 244 registrar_.Add(this, chrome::AUTH_SUPPLIED, source);
244 registrar_.Add(this, NotificationType::AUTH_CANCELLED, source); 245 registrar_.Add(this, chrome::AUTH_CANCELLED, source);
245 246
246 if (include_current_navigation && controller->tab_contents()->is_loading()) 247 if (include_current_navigation && controller->tab_contents()->is_loading())
247 navigation_started_ = true; 248 navigation_started_ = true;
248 } 249 }
249 250
250 NavigationNotificationObserver::~NavigationNotificationObserver() { 251 NavigationNotificationObserver::~NavigationNotificationObserver() {
251 } 252 }
252 253
253 void NavigationNotificationObserver::Observe( 254 void NavigationNotificationObserver::Observe(
254 NotificationType type, const NotificationSource& source, 255 NotificationType type, const NotificationSource& source,
255 const NotificationDetails& details) { 256 const NotificationDetails& details) {
256 if (!automation_) { 257 if (!automation_) {
257 delete this; 258 delete this;
258 return; 259 return;
259 } 260 }
260 261
261 // We listen for 2 events to determine when the navigation started because: 262 // We listen for 2 events to determine when the navigation started because:
262 // - when this is used by the WaitForNavigation method, we might be invoked 263 // - when this is used by the WaitForNavigation method, we might be invoked
263 // afer the load has started (but not after the entry was committed, as 264 // afer the load has started (but not after the entry was committed, as
264 // WaitForNavigation compares times of the last navigation). 265 // WaitForNavigation compares times of the last navigation).
265 // - when this is used with a page requiring authentication, we will not get 266 // - when this is used with a page requiring authentication, we will not get
266 // a NotificationType::NAV_ENTRY_COMMITTED until after we authenticate, so 267 // a chrome::NAV_ENTRY_COMMITTED until after we authenticate, so
267 // we need the NotificationType::LOAD_START. 268 // we need the chrome::LOAD_START.
268 if (type == NotificationType::NAV_ENTRY_COMMITTED || 269 if (type == NotificationType::NAV_ENTRY_COMMITTED ||
269 type == NotificationType::LOAD_START) { 270 type == NotificationType::LOAD_START) {
270 navigation_started_ = true; 271 navigation_started_ = true;
271 } else if (type == NotificationType::LOAD_STOP) { 272 } else if (type == NotificationType::LOAD_STOP) {
272 if (navigation_started_) { 273 if (navigation_started_) {
273 navigation_started_ = false; 274 navigation_started_ = false;
274 if (--navigations_remaining_ == 0) 275 if (--navigations_remaining_ == 0)
275 ConditionMet(AUTOMATION_MSG_NAVIGATION_SUCCESS); 276 ConditionMet(AUTOMATION_MSG_NAVIGATION_SUCCESS);
276 } 277 }
277 } else if (type == NotificationType::AUTH_SUPPLIED || 278 } else if (type == chrome::AUTH_SUPPLIED ||
278 type == NotificationType::AUTH_CANCELLED) { 279 type == chrome::AUTH_CANCELLED) {
279 // The LoginHandler for this tab is no longer valid. 280 // The LoginHandler for this tab is no longer valid.
280 automation_->RemoveLoginHandler(controller_); 281 automation_->RemoveLoginHandler(controller_);
281 282
282 // Treat this as if navigation started again, since load start/stop don't 283 // Treat this as if navigation started again, since load start/stop don't
283 // occur while authentication is ongoing. 284 // occur while authentication is ongoing.
284 navigation_started_ = true; 285 navigation_started_ = true;
285 } else if (type == NotificationType::AUTH_NEEDED) { 286 } else if (type == chrome::AUTH_NEEDED) {
286 // Remember the login handler that wants authentication. 287 // Remember the login handler that wants authentication.
287 // We do this in all cases (not just when navigation_started_ == true) so 288 // We do this in all cases (not just when navigation_started_ == true) so
288 // tests can still wait for auth dialogs outside of navigation. 289 // tests can still wait for auth dialogs outside of navigation.
289 LoginHandler* handler = 290 LoginHandler* handler =
290 Details<LoginNotificationDetails>(details)->handler(); 291 Details<LoginNotificationDetails>(details)->handler();
291 automation_->AddLoginHandler(controller_, handler); 292 automation_->AddLoginHandler(controller_, handler);
292 293
293 // Respond that authentication is needed. 294 // Respond that authentication is needed.
294 navigation_started_ = false; 295 navigation_started_ = false;
295 ConditionMet(AUTOMATION_MSG_NAVIGATION_AUTH_NEEDED); 296 ConditionMet(AUTOMATION_MSG_NAVIGATION_AUTH_NEEDED);
(...skipping 158 matching lines...) Expand 10 before | Expand all | Expand 10 after
454 return false; 455 return false;
455 } 456 }
456 return true; 457 return true;
457 } 458 }
458 459
459 ExtensionInstallNotificationObserver::ExtensionInstallNotificationObserver( 460 ExtensionInstallNotificationObserver::ExtensionInstallNotificationObserver(
460 AutomationProvider* automation, int id, IPC::Message* reply_message) 461 AutomationProvider* automation, int id, IPC::Message* reply_message)
461 : automation_(automation->AsWeakPtr()), 462 : automation_(automation->AsWeakPtr()),
462 id_(id), 463 id_(id),
463 reply_message_(reply_message) { 464 reply_message_(reply_message) {
464 registrar_.Add(this, NotificationType::EXTENSION_LOADED, 465 registrar_.Add(this, chrome::EXTENSION_LOADED,
465 NotificationService::AllSources()); 466 NotificationService::AllSources());
466 registrar_.Add(this, NotificationType::EXTENSION_INSTALL_ERROR, 467 registrar_.Add(this, chrome::EXTENSION_INSTALL_ERROR,
467 NotificationService::AllSources()); 468 NotificationService::AllSources());
468 registrar_.Add(this, NotificationType::EXTENSION_UPDATE_DISABLED, 469 registrar_.Add(this, chrome::EXTENSION_UPDATE_DISABLED,
469 NotificationService::AllSources()); 470 NotificationService::AllSources());
470 } 471 }
471 472
472 ExtensionInstallNotificationObserver::~ExtensionInstallNotificationObserver() { 473 ExtensionInstallNotificationObserver::~ExtensionInstallNotificationObserver() {
473 } 474 }
474 475
475 void ExtensionInstallNotificationObserver::Observe( 476 void ExtensionInstallNotificationObserver::Observe(
476 NotificationType type, const NotificationSource& source, 477 NotificationType type, const NotificationSource& source,
477 const NotificationDetails& details) { 478 const NotificationDetails& details) {
478 switch (type.value) { 479 switch (type.value) {
479 case NotificationType::EXTENSION_LOADED: 480 case chrome::EXTENSION_LOADED:
480 SendResponse(AUTOMATION_MSG_EXTENSION_INSTALL_SUCCEEDED); 481 SendResponse(AUTOMATION_MSG_EXTENSION_INSTALL_SUCCEEDED);
481 break; 482 break;
482 case NotificationType::EXTENSION_INSTALL_ERROR: 483 case chrome::EXTENSION_INSTALL_ERROR:
483 case NotificationType::EXTENSION_UPDATE_DISABLED: 484 case chrome::EXTENSION_UPDATE_DISABLED:
484 SendResponse(AUTOMATION_MSG_EXTENSION_INSTALL_FAILED); 485 SendResponse(AUTOMATION_MSG_EXTENSION_INSTALL_FAILED);
485 break; 486 break;
486 default: 487 default:
487 NOTREACHED(); 488 NOTREACHED();
488 break; 489 break;
489 } 490 }
490 491
491 delete this; 492 delete this;
492 } 493 }
493 494
(...skipping 17 matching lines...) Expand all
511 automation_->Send(reply_message_.release()); 512 automation_->Send(reply_message_.release());
512 } 513 }
513 514
514 ExtensionUninstallObserver::ExtensionUninstallObserver( 515 ExtensionUninstallObserver::ExtensionUninstallObserver(
515 AutomationProvider* automation, 516 AutomationProvider* automation,
516 IPC::Message* reply_message, 517 IPC::Message* reply_message,
517 const std::string& id) 518 const std::string& id)
518 : automation_(automation->AsWeakPtr()), 519 : automation_(automation->AsWeakPtr()),
519 reply_message_(reply_message), 520 reply_message_(reply_message),
520 id_(id) { 521 id_(id) {
521 registrar_.Add(this, NotificationType::EXTENSION_UNINSTALLED, 522 registrar_.Add(this, chrome::EXTENSION_UNINSTALLED,
522 NotificationService::AllSources()); 523 NotificationService::AllSources());
523 registrar_.Add(this, NotificationType::EXTENSION_UNINSTALL_NOT_ALLOWED, 524 registrar_.Add(this, chrome::EXTENSION_UNINSTALL_NOT_ALLOWED,
524 NotificationService::AllSources()); 525 NotificationService::AllSources());
525 } 526 }
526 527
527 ExtensionUninstallObserver::~ExtensionUninstallObserver() { 528 ExtensionUninstallObserver::~ExtensionUninstallObserver() {
528 } 529 }
529 530
530 void ExtensionUninstallObserver::Observe( 531 void ExtensionUninstallObserver::Observe(
531 NotificationType type, 532 NotificationType type,
532 const NotificationSource& source, 533 const NotificationSource& source,
533 const NotificationDetails& details) { 534 const NotificationDetails& details) {
534 if (!automation_) { 535 if (!automation_) {
535 delete this; 536 delete this;
536 return; 537 return;
537 } 538 }
538 539
539 switch (type.value) { 540 switch (type.value) {
540 case NotificationType::EXTENSION_UNINSTALLED: { 541 case chrome::EXTENSION_UNINSTALLED: {
541 UninstalledExtensionInfo* info = 542 UninstalledExtensionInfo* info =
542 Details<UninstalledExtensionInfo>(details).ptr(); 543 Details<UninstalledExtensionInfo>(details).ptr();
543 if (id_ == info->extension_id) { 544 if (id_ == info->extension_id) {
544 scoped_ptr<DictionaryValue> return_value(new DictionaryValue); 545 scoped_ptr<DictionaryValue> return_value(new DictionaryValue);
545 return_value->SetBoolean("success", true); 546 return_value->SetBoolean("success", true);
546 AutomationJSONReply(automation_, reply_message_.release()) 547 AutomationJSONReply(automation_, reply_message_.release())
547 .SendSuccess(return_value.get()); 548 .SendSuccess(return_value.get());
548 delete this; 549 delete this;
549 return; 550 return;
550 } 551 }
551 break; 552 break;
552 } 553 }
553 554
554 case NotificationType::EXTENSION_UNINSTALL_NOT_ALLOWED: { 555 case chrome::EXTENSION_UNINSTALL_NOT_ALLOWED: {
555 const Extension* extension = Details<Extension>(details).ptr(); 556 const Extension* extension = Details<Extension>(details).ptr();
556 if (id_ == extension->id()) { 557 if (id_ == extension->id()) {
557 scoped_ptr<DictionaryValue> return_value(new DictionaryValue); 558 scoped_ptr<DictionaryValue> return_value(new DictionaryValue);
558 return_value->SetBoolean("success", false); 559 return_value->SetBoolean("success", false);
559 AutomationJSONReply(automation_, reply_message_.release()) 560 AutomationJSONReply(automation_, reply_message_.release())
560 .SendSuccess(return_value.get()); 561 .SendSuccess(return_value.get());
561 delete this; 562 delete this;
562 return; 563 return;
563 } 564 }
564 break; 565 break;
565 } 566 }
566 567
567 default: 568 default:
568 NOTREACHED(); 569 NOTREACHED();
569 } 570 }
570 } 571 }
571 572
572 ExtensionReadyNotificationObserver::ExtensionReadyNotificationObserver( 573 ExtensionReadyNotificationObserver::ExtensionReadyNotificationObserver(
573 ExtensionProcessManager* manager, AutomationProvider* automation, int id, 574 ExtensionProcessManager* manager, AutomationProvider* automation, int id,
574 IPC::Message* reply_message) 575 IPC::Message* reply_message)
575 : manager_(manager), 576 : manager_(manager),
576 automation_(automation->AsWeakPtr()), 577 automation_(automation->AsWeakPtr()),
577 id_(id), 578 id_(id),
578 reply_message_(reply_message), 579 reply_message_(reply_message),
579 extension_(NULL) { 580 extension_(NULL) {
580 registrar_.Add(this, NotificationType::EXTENSION_HOST_DID_STOP_LOADING, 581 registrar_.Add(this, chrome::EXTENSION_HOST_DID_STOP_LOADING,
581 NotificationService::AllSources()); 582 NotificationService::AllSources());
582 registrar_.Add(this, NotificationType::EXTENSION_LOADED, 583 registrar_.Add(this, chrome::EXTENSION_LOADED,
583 NotificationService::AllSources()); 584 NotificationService::AllSources());
584 registrar_.Add(this, NotificationType::EXTENSION_INSTALL_ERROR, 585 registrar_.Add(this, chrome::EXTENSION_INSTALL_ERROR,
585 NotificationService::AllSources()); 586 NotificationService::AllSources());
586 registrar_.Add(this, NotificationType::EXTENSION_UPDATE_DISABLED, 587 registrar_.Add(this, chrome::EXTENSION_UPDATE_DISABLED,
587 NotificationService::AllSources()); 588 NotificationService::AllSources());
588 } 589 }
589 590
590 ExtensionReadyNotificationObserver::~ExtensionReadyNotificationObserver() { 591 ExtensionReadyNotificationObserver::~ExtensionReadyNotificationObserver() {
591 } 592 }
592 593
593 void ExtensionReadyNotificationObserver::Observe( 594 void ExtensionReadyNotificationObserver::Observe(
594 NotificationType type, const NotificationSource& source, 595 NotificationType type, const NotificationSource& source,
595 const NotificationDetails& details) { 596 const NotificationDetails& details) {
596 if (!automation_) { 597 if (!automation_) {
597 delete this; 598 delete this;
598 return; 599 return;
599 } 600 }
600 601
601 switch (type.value) { 602 switch (type.value) {
602 case NotificationType::EXTENSION_HOST_DID_STOP_LOADING: 603 case chrome::EXTENSION_HOST_DID_STOP_LOADING:
603 // Only continue on with this method if our extension has been loaded 604 // Only continue on with this method if our extension has been loaded
604 // and all the extension hosts have stopped loading. 605 // and all the extension hosts have stopped loading.
605 if (!extension_ || !DidExtensionHostsStopLoading(manager_)) 606 if (!extension_ || !DidExtensionHostsStopLoading(manager_))
606 return; 607 return;
607 break; 608 break;
608 case NotificationType::EXTENSION_LOADED: 609 case chrome::EXTENSION_LOADED:
609 extension_ = Details<const Extension>(details).ptr(); 610 extension_ = Details<const Extension>(details).ptr();
610 if (!DidExtensionHostsStopLoading(manager_)) 611 if (!DidExtensionHostsStopLoading(manager_))
611 return; 612 return;
612 break; 613 break;
613 case NotificationType::EXTENSION_INSTALL_ERROR: 614 case chrome::EXTENSION_INSTALL_ERROR:
614 case NotificationType::EXTENSION_UPDATE_DISABLED: 615 case chrome::EXTENSION_UPDATE_DISABLED:
615 break; 616 break;
616 default: 617 default:
617 NOTREACHED(); 618 NOTREACHED();
618 break; 619 break;
619 } 620 }
620 621
621 if (id_ == AutomationMsg_InstallExtensionAndGetHandle::ID) { 622 if (id_ == AutomationMsg_InstallExtensionAndGetHandle::ID) {
622 // A handle of zero indicates an error. 623 // A handle of zero indicates an error.
623 int extension_handle = 0; 624 int extension_handle = 0;
624 if (extension_) 625 if (extension_)
625 extension_handle = automation_->AddExtension(extension_); 626 extension_handle = automation_->AddExtension(extension_);
626 AutomationMsg_InstallExtensionAndGetHandle::WriteReplyParams( 627 AutomationMsg_InstallExtensionAndGetHandle::WriteReplyParams(
627 reply_message_.get(), extension_handle); 628 reply_message_.get(), extension_handle);
628 } else if (id_ == AutomationMsg_EnableExtension::ID) { 629 } else if (id_ == AutomationMsg_EnableExtension::ID) {
629 AutomationMsg_EnableExtension::WriteReplyParams(reply_message_.get(), true); 630 AutomationMsg_EnableExtension::WriteReplyParams(reply_message_.get(), true);
630 } else { 631 } else {
631 NOTREACHED(); 632 NOTREACHED();
632 LOG(ERROR) << "Cannot write reply params for unknown message id."; 633 LOG(ERROR) << "Cannot write reply params for unknown message id.";
633 } 634 }
634 635
635 automation_->Send(reply_message_.release()); 636 automation_->Send(reply_message_.release());
636 delete this; 637 delete this;
637 } 638 }
638 639
639 ExtensionUnloadNotificationObserver::ExtensionUnloadNotificationObserver() 640 ExtensionUnloadNotificationObserver::ExtensionUnloadNotificationObserver()
640 : did_receive_unload_notification_(false) { 641 : did_receive_unload_notification_(false) {
641 registrar_.Add(this, NotificationType::EXTENSION_UNLOADED, 642 registrar_.Add(this, chrome::EXTENSION_UNLOADED,
642 NotificationService::AllSources()); 643 NotificationService::AllSources());
643 } 644 }
644 645
645 ExtensionUnloadNotificationObserver::~ExtensionUnloadNotificationObserver() { 646 ExtensionUnloadNotificationObserver::~ExtensionUnloadNotificationObserver() {
646 } 647 }
647 648
648 void ExtensionUnloadNotificationObserver::Observe( 649 void ExtensionUnloadNotificationObserver::Observe(
649 NotificationType type, const NotificationSource& source, 650 NotificationType type, const NotificationSource& source,
650 const NotificationDetails& details) { 651 const NotificationDetails& details) {
651 if (type.value == NotificationType::EXTENSION_UNLOADED) { 652 if (type.value == chrome::EXTENSION_UNLOADED) {
652 did_receive_unload_notification_ = true; 653 did_receive_unload_notification_ = true;
653 } else { 654 } else {
654 NOTREACHED(); 655 NOTREACHED();
655 } 656 }
656 } 657 }
657 658
658 ExtensionsUpdatedObserver::ExtensionsUpdatedObserver( 659 ExtensionsUpdatedObserver::ExtensionsUpdatedObserver(
659 ExtensionProcessManager* manager, AutomationProvider* automation, 660 ExtensionProcessManager* manager, AutomationProvider* automation,
660 IPC::Message* reply_message) 661 IPC::Message* reply_message)
661 : manager_(manager), automation_(automation->AsWeakPtr()), 662 : manager_(manager), automation_(automation->AsWeakPtr()),
662 reply_message_(reply_message), updater_finished_(false) { 663 reply_message_(reply_message), updater_finished_(false) {
663 registrar_.Add(this, NotificationType::EXTENSION_HOST_DID_STOP_LOADING, 664 registrar_.Add(this, chrome::EXTENSION_HOST_DID_STOP_LOADING,
664 NotificationService::AllSources()); 665 NotificationService::AllSources());
665 registrar_.Add(this, NotificationType::EXTENSION_INSTALL_ERROR, 666 registrar_.Add(this, chrome::EXTENSION_INSTALL_ERROR,
666 NotificationService::AllSources()); 667 NotificationService::AllSources());
667 registrar_.Add(this, NotificationType::EXTENSION_INSTALL_NOT_ALLOWED, 668 registrar_.Add(this, chrome::EXTENSION_INSTALL_NOT_ALLOWED,
668 NotificationService::AllSources()); 669 NotificationService::AllSources());
669 registrar_.Add(this, NotificationType::EXTENSION_LOADED, 670 registrar_.Add(this, chrome::EXTENSION_LOADED,
670 NotificationService::AllSources()); 671 NotificationService::AllSources());
671 registrar_.Add(this, NotificationType::EXTENSION_UPDATE_DISABLED, 672 registrar_.Add(this, chrome::EXTENSION_UPDATE_DISABLED,
672 NotificationService::AllSources()); 673 NotificationService::AllSources());
673 registrar_.Add(this, NotificationType::EXTENSION_UPDATE_FOUND, 674 registrar_.Add(this, chrome::EXTENSION_UPDATE_FOUND,
674 NotificationService::AllSources()); 675 NotificationService::AllSources());
675 registrar_.Add(this, NotificationType::EXTENSION_UPDATING_FINISHED, 676 registrar_.Add(this, chrome::EXTENSION_UPDATING_FINISHED,
676 NotificationService::AllSources()); 677 NotificationService::AllSources());
677 } 678 }
678 679
679 ExtensionsUpdatedObserver::~ExtensionsUpdatedObserver() { 680 ExtensionsUpdatedObserver::~ExtensionsUpdatedObserver() {
680 } 681 }
681 682
682 void ExtensionsUpdatedObserver::Observe( 683 void ExtensionsUpdatedObserver::Observe(
683 NotificationType type, const NotificationSource& source, 684 NotificationType type, const NotificationSource& source,
684 const NotificationDetails& details) { 685 const NotificationDetails& details) {
685 if (!automation_) { 686 if (!automation_) {
686 delete this; 687 delete this;
687 return; 688 return;
688 } 689 }
689 690
690 // We expect the following sequence of events. First, the ExtensionUpdater 691 // We expect the following sequence of events. First, the ExtensionUpdater
691 // service notifies of each extension that needs to be updated. Once the 692 // service notifies of each extension that needs to be updated. Once the
692 // ExtensionUpdater has finished searching for extensions to update, it 693 // ExtensionUpdater has finished searching for extensions to update, it
693 // notifies that it is finished. Meanwhile, the extensions are updated 694 // notifies that it is finished. Meanwhile, the extensions are updated
694 // asynchronously: either they will be updated and loaded, or else they will 695 // asynchronously: either they will be updated and loaded, or else they will
695 // not load due to (1) not being allowed; (2) having updating disabled; or 696 // not load due to (1) not being allowed; (2) having updating disabled; or
696 // (3) encountering an error. Finally, notifications are also sent whenever 697 // (3) encountering an error. Finally, notifications are also sent whenever
697 // an extension host stops loading. Updating is not considered complete if 698 // an extension host stops loading. Updating is not considered complete if
698 // any extension hosts are still loading. 699 // any extension hosts are still loading.
699 switch (type.value) { 700 switch (type.value) {
700 case NotificationType::EXTENSION_UPDATE_FOUND: 701 case chrome::EXTENSION_UPDATE_FOUND:
701 // Extension updater has identified an extension that needs to be updated. 702 // Extension updater has identified an extension that needs to be updated.
702 in_progress_updates_.insert(*(Details<const std::string>(details).ptr())); 703 in_progress_updates_.insert(*(Details<const std::string>(details).ptr()));
703 break; 704 break;
704 705
705 case NotificationType::EXTENSION_UPDATING_FINISHED: 706 case chrome::EXTENSION_UPDATING_FINISHED:
706 // Extension updater has completed notifying all extensions to update 707 // Extension updater has completed notifying all extensions to update
707 // themselves. 708 // themselves.
708 updater_finished_ = true; 709 updater_finished_ = true;
709 break; 710 break;
710 711
711 case NotificationType::EXTENSION_LOADED: 712 case chrome::EXTENSION_LOADED:
712 case NotificationType::EXTENSION_INSTALL_NOT_ALLOWED: 713 case chrome::EXTENSION_INSTALL_NOT_ALLOWED:
713 case NotificationType::EXTENSION_UPDATE_DISABLED: { 714 case chrome::EXTENSION_UPDATE_DISABLED: {
714 // An extension has either completed update installation and is now 715 // An extension has either completed update installation and is now
715 // loaded, or else the install has been skipped because it is 716 // loaded, or else the install has been skipped because it is
716 // either not allowed or else has been disabled. 717 // either not allowed or else has been disabled.
717 const Extension* extension = Details<Extension>(details).ptr(); 718 const Extension* extension = Details<Extension>(details).ptr();
718 in_progress_updates_.erase(extension->id()); 719 in_progress_updates_.erase(extension->id());
719 break; 720 break;
720 } 721 }
721 722
722 case NotificationType::EXTENSION_INSTALL_ERROR: { 723 case chrome::EXTENSION_INSTALL_ERROR: {
723 // An extension had an error on update installation. 724 // An extension had an error on update installation.
724 CrxInstaller* installer = Source<CrxInstaller>(source).ptr(); 725 CrxInstaller* installer = Source<CrxInstaller>(source).ptr();
725 in_progress_updates_.erase(installer->expected_id()); 726 in_progress_updates_.erase(installer->expected_id());
726 break; 727 break;
727 } 728 }
728 729
729 case NotificationType::EXTENSION_HOST_DID_STOP_LOADING: 730 case chrome::EXTENSION_HOST_DID_STOP_LOADING:
730 // Break out to the conditional check below to see if all extension hosts 731 // Break out to the conditional check below to see if all extension hosts
731 // have stopped loading. 732 // have stopped loading.
732 break; 733 break;
733 734
734 default: 735 default:
735 NOTREACHED(); 736 NOTREACHED();
736 break; 737 break;
737 } 738 }
738 739
739 // Send the reply if (1) the extension updater has finished notifying all 740 // Send the reply if (1) the extension updater has finished notifying all
740 // extensions to update themselves; (2) all extensions that need to be updated 741 // extensions to update themselves; (2) all extensions that need to be updated
741 // have completed installation and are now loaded; and (3) all extension hosts 742 // have completed installation and are now loaded; and (3) all extension hosts
742 // have stopped loading. 743 // have stopped loading.
743 if (updater_finished_ && in_progress_updates_.empty() && 744 if (updater_finished_ && in_progress_updates_.empty() &&
744 DidExtensionHostsStopLoading(manager_)) { 745 DidExtensionHostsStopLoading(manager_)) {
745 AutomationJSONReply reply(automation_, reply_message_.release()); 746 AutomationJSONReply reply(automation_, reply_message_.release());
746 reply.SendSuccess(NULL); 747 reply.SendSuccess(NULL);
747 delete this; 748 delete this;
748 } 749 }
749 } 750 }
750 751
751 ExtensionTestResultNotificationObserver:: 752 ExtensionTestResultNotificationObserver::
752 ExtensionTestResultNotificationObserver(AutomationProvider* automation) 753 ExtensionTestResultNotificationObserver(AutomationProvider* automation)
753 : automation_(automation->AsWeakPtr()) { 754 : automation_(automation->AsWeakPtr()) {
754 registrar_.Add(this, NotificationType::EXTENSION_TEST_PASSED, 755 registrar_.Add(this, chrome::EXTENSION_TEST_PASSED,
755 NotificationService::AllSources()); 756 NotificationService::AllSources());
756 registrar_.Add(this, NotificationType::EXTENSION_TEST_FAILED, 757 registrar_.Add(this, chrome::EXTENSION_TEST_FAILED,
757 NotificationService::AllSources()); 758 NotificationService::AllSources());
758 } 759 }
759 760
760 ExtensionTestResultNotificationObserver:: 761 ExtensionTestResultNotificationObserver::
761 ~ExtensionTestResultNotificationObserver() { 762 ~ExtensionTestResultNotificationObserver() {
762 } 763 }
763 764
764 void ExtensionTestResultNotificationObserver::Observe( 765 void ExtensionTestResultNotificationObserver::Observe(
765 NotificationType type, const NotificationSource& source, 766 NotificationType type, const NotificationSource& source,
766 const NotificationDetails& details) { 767 const NotificationDetails& details) {
767 switch (type.value) { 768 switch (type.value) {
768 case NotificationType::EXTENSION_TEST_PASSED: 769 case chrome::EXTENSION_TEST_PASSED:
769 results_.push_back(true); 770 results_.push_back(true);
770 messages_.push_back(""); 771 messages_.push_back("");
771 break; 772 break;
772 773
773 case NotificationType::EXTENSION_TEST_FAILED: 774 case chrome::EXTENSION_TEST_FAILED:
774 results_.push_back(false); 775 results_.push_back(false);
775 messages_.push_back(*(Details<std::string>(details).ptr())); 776 messages_.push_back(*(Details<std::string>(details).ptr()));
776 break; 777 break;
777 778
778 default: 779 default:
779 NOTREACHED(); 780 NOTREACHED();
780 } 781 }
781 // There may be a reply message waiting for this event, so check. 782 // There may be a reply message waiting for this event, so check.
782 MaybeSendResult(); 783 MaybeSendResult();
783 } 784 }
(...skipping 18 matching lines...) Expand all
802 } 803 }
803 } 804 }
804 805
805 BrowserOpenedNotificationObserver::BrowserOpenedNotificationObserver( 806 BrowserOpenedNotificationObserver::BrowserOpenedNotificationObserver(
806 AutomationProvider* automation, 807 AutomationProvider* automation,
807 IPC::Message* reply_message) 808 IPC::Message* reply_message)
808 : automation_(automation->AsWeakPtr()), 809 : automation_(automation->AsWeakPtr()),
809 reply_message_(reply_message), 810 reply_message_(reply_message),
810 new_window_id_(extension_misc::kUnknownWindowId), 811 new_window_id_(extension_misc::kUnknownWindowId),
811 for_browser_command_(false) { 812 for_browser_command_(false) {
812 registrar_.Add(this, NotificationType::BROWSER_OPENED, 813 registrar_.Add(this, chrome::BROWSER_OPENED,
813 NotificationService::AllSources()); 814 NotificationService::AllSources());
814 registrar_.Add(this, NotificationType::LOAD_STOP, 815 registrar_.Add(this, NotificationType::LOAD_STOP,
815 NotificationService::AllSources()); 816 NotificationService::AllSources());
816 } 817 }
817 818
818 BrowserOpenedNotificationObserver::~BrowserOpenedNotificationObserver() { 819 BrowserOpenedNotificationObserver::~BrowserOpenedNotificationObserver() {
819 } 820 }
820 821
821 void BrowserOpenedNotificationObserver::Observe( 822 void BrowserOpenedNotificationObserver::Observe(
822 NotificationType type, const NotificationSource& source, 823 NotificationType type, const NotificationSource& source,
823 const NotificationDetails& details) { 824 const NotificationDetails& details) {
824 if (!automation_) { 825 if (!automation_) {
825 delete this; 826 delete this;
826 return; 827 return;
827 } 828 }
828 829
829 if (type.value == NotificationType::BROWSER_OPENED) { 830 if (type.value == chrome::BROWSER_OPENED) {
830 // Store the new browser ID and continue waiting for a new tab within it 831 // Store the new browser ID and continue waiting for a new tab within it
831 // to stop loading. 832 // to stop loading.
832 new_window_id_ = ExtensionTabUtil::GetWindowId( 833 new_window_id_ = ExtensionTabUtil::GetWindowId(
833 Source<Browser>(source).ptr()); 834 Source<Browser>(source).ptr());
834 } else if (type.value == NotificationType::LOAD_STOP) { 835 } else if (type.value == NotificationType::LOAD_STOP) {
835 // Only send the result if the loaded tab is in the new window. 836 // Only send the result if the loaded tab is in the new window.
836 NavigationController* controller = 837 NavigationController* controller =
837 Source<NavigationController>(source).ptr(); 838 Source<NavigationController>(source).ptr();
838 TabContentsWrapper* tab = TabContentsWrapper::GetCurrentWrapperForContents( 839 TabContentsWrapper* tab = TabContentsWrapper::GetCurrentWrapperForContents(
839 controller->tab_contents()); 840 controller->tab_contents());
(...skipping 17 matching lines...) Expand all
857 for_browser_command_ = for_browser_command; 858 for_browser_command_ = for_browser_command;
858 } 859 }
859 860
860 BrowserClosedNotificationObserver::BrowserClosedNotificationObserver( 861 BrowserClosedNotificationObserver::BrowserClosedNotificationObserver(
861 Browser* browser, 862 Browser* browser,
862 AutomationProvider* automation, 863 AutomationProvider* automation,
863 IPC::Message* reply_message) 864 IPC::Message* reply_message)
864 : automation_(automation->AsWeakPtr()), 865 : automation_(automation->AsWeakPtr()),
865 reply_message_(reply_message), 866 reply_message_(reply_message),
866 for_browser_command_(false) { 867 for_browser_command_(false) {
867 registrar_.Add(this, NotificationType::BROWSER_CLOSED, 868 registrar_.Add(this, chrome::BROWSER_CLOSED,
868 Source<Browser>(browser)); 869 Source<Browser>(browser));
869 } 870 }
870 871
871 BrowserClosedNotificationObserver::~BrowserClosedNotificationObserver() {} 872 BrowserClosedNotificationObserver::~BrowserClosedNotificationObserver() {}
872 873
873 void BrowserClosedNotificationObserver::Observe( 874 void BrowserClosedNotificationObserver::Observe(
874 NotificationType type, const NotificationSource& source, 875 NotificationType type, const NotificationSource& source,
875 const NotificationDetails& details) { 876 const NotificationDetails& details) {
876 DCHECK(type == NotificationType::BROWSER_CLOSED); 877 DCHECK(type == chrome::BROWSER_CLOSED);
877 878
878 if (!automation_) { 879 if (!automation_) {
879 delete this; 880 delete this;
880 return; 881 return;
881 } 882 }
882 883
883 Details<bool> close_app(details); 884 Details<bool> close_app(details);
884 885
885 if (for_browser_command_) { 886 if (for_browser_command_) {
886 AutomationMsg_WindowExecuteCommand::WriteReplyParams(reply_message_.get(), 887 AutomationMsg_WindowExecuteCommand::WriteReplyParams(reply_message_.get(),
(...skipping 11 matching lines...) Expand all
898 for_browser_command_ = for_browser_command; 899 for_browser_command_ = for_browser_command;
899 } 900 }
900 901
901 BrowserCountChangeNotificationObserver::BrowserCountChangeNotificationObserver( 902 BrowserCountChangeNotificationObserver::BrowserCountChangeNotificationObserver(
902 int target_count, 903 int target_count,
903 AutomationProvider* automation, 904 AutomationProvider* automation,
904 IPC::Message* reply_message) 905 IPC::Message* reply_message)
905 : target_count_(target_count), 906 : target_count_(target_count),
906 automation_(automation->AsWeakPtr()), 907 automation_(automation->AsWeakPtr()),
907 reply_message_(reply_message) { 908 reply_message_(reply_message) {
908 registrar_.Add(this, NotificationType::BROWSER_OPENED, 909 registrar_.Add(this, chrome::BROWSER_OPENED,
909 NotificationService::AllSources()); 910 NotificationService::AllSources());
910 registrar_.Add(this, NotificationType::BROWSER_CLOSED, 911 registrar_.Add(this, chrome::BROWSER_CLOSED,
911 NotificationService::AllSources()); 912 NotificationService::AllSources());
912 } 913 }
913 914
914 BrowserCountChangeNotificationObserver:: 915 BrowserCountChangeNotificationObserver::
915 ~BrowserCountChangeNotificationObserver() {} 916 ~BrowserCountChangeNotificationObserver() {}
916 917
917 void BrowserCountChangeNotificationObserver::Observe( 918 void BrowserCountChangeNotificationObserver::Observe(
918 NotificationType type, 919 NotificationType type,
919 const NotificationSource& source, 920 const NotificationSource& source,
920 const NotificationDetails& details) { 921 const NotificationDetails& details) {
921 DCHECK(type == NotificationType::BROWSER_OPENED || 922 DCHECK(type == chrome::BROWSER_OPENED ||
922 type == NotificationType::BROWSER_CLOSED); 923 type == chrome::BROWSER_CLOSED);
923 int current_count = static_cast<int>(BrowserList::size()); 924 int current_count = static_cast<int>(BrowserList::size());
924 if (type == NotificationType::BROWSER_CLOSED) { 925 if (type == chrome::BROWSER_CLOSED) {
925 // At the time of the notification the browser being closed is not removed 926 // At the time of the notification the browser being closed is not removed
926 // from the list. The real count is one less than the reported count. 927 // from the list. The real count is one less than the reported count.
927 DCHECK_LT(0, current_count); 928 DCHECK_LT(0, current_count);
928 current_count--; 929 current_count--;
929 } 930 }
930 931
931 if (!automation_) { 932 if (!automation_) {
932 delete this; 933 delete this;
933 return; 934 return;
934 } 935 }
935 936
936 if (current_count == target_count_) { 937 if (current_count == target_count_) {
937 AutomationMsg_WaitForBrowserWindowCountToBecome::WriteReplyParams( 938 AutomationMsg_WaitForBrowserWindowCountToBecome::WriteReplyParams(
938 reply_message_.get(), true); 939 reply_message_.get(), true);
939 automation_->Send(reply_message_.release()); 940 automation_->Send(reply_message_.release());
940 delete this; 941 delete this;
941 } 942 }
942 } 943 }
943 944
944 AppModalDialogShownObserver::AppModalDialogShownObserver( 945 AppModalDialogShownObserver::AppModalDialogShownObserver(
945 AutomationProvider* automation, IPC::Message* reply_message) 946 AutomationProvider* automation, IPC::Message* reply_message)
946 : automation_(automation->AsWeakPtr()), 947 : automation_(automation->AsWeakPtr()),
947 reply_message_(reply_message) { 948 reply_message_(reply_message) {
948 registrar_.Add(this, NotificationType::APP_MODAL_DIALOG_SHOWN, 949 registrar_.Add(this, chrome::APP_MODAL_DIALOG_SHOWN,
949 NotificationService::AllSources()); 950 NotificationService::AllSources());
950 } 951 }
951 952
952 AppModalDialogShownObserver::~AppModalDialogShownObserver() { 953 AppModalDialogShownObserver::~AppModalDialogShownObserver() {
953 } 954 }
954 955
955 void AppModalDialogShownObserver::Observe( 956 void AppModalDialogShownObserver::Observe(
956 NotificationType type, const NotificationSource& source, 957 NotificationType type, const NotificationSource& source,
957 const NotificationDetails& details) { 958 const NotificationDetails& details) {
958 DCHECK(type == NotificationType::APP_MODAL_DIALOG_SHOWN); 959 DCHECK(type == chrome::APP_MODAL_DIALOG_SHOWN);
959 960
960 if (automation_) { 961 if (automation_) {
961 AutomationMsg_WaitForAppModalDialogToBeShown::WriteReplyParams( 962 AutomationMsg_WaitForAppModalDialogToBeShown::WriteReplyParams(
962 reply_message_.get(), true); 963 reply_message_.get(), true);
963 automation_->Send(reply_message_.release()); 964 automation_->Send(reply_message_.release());
964 } 965 }
965 delete this; 966 delete this;
966 } 967 }
967 968
968 namespace { 969 namespace {
969 970
970 // Define mapping from command to notification 971 // Define mapping from command to notification
971 struct CommandNotification { 972 struct CommandNotification {
972 int command; 973 int command;
973 NotificationType::Type notification_type; 974 int notification_type;
974 }; 975 };
975 976
976 const struct CommandNotification command_notifications[] = { 977 const struct CommandNotification command_notifications[] = {
977 {IDC_DUPLICATE_TAB, NotificationType::TAB_PARENTED}, 978 {IDC_DUPLICATE_TAB, NotificationType::TAB_PARENTED},
978 979
979 // Returns as soon as the restored tab is created. To further wait until 980 // Returns as soon as the restored tab is created. To further wait until
980 // the content page is loaded, use WaitForTabToBeRestored. 981 // the content page is loaded, use WaitForTabToBeRestored.
981 {IDC_RESTORE_TAB, NotificationType::TAB_PARENTED}, 982 {IDC_RESTORE_TAB, NotificationType::TAB_PARENTED},
982 983
983 // For the following commands, we need to wait for a new tab to be created, 984 // For the following commands, we need to wait for a new tab to be created,
(...skipping 84 matching lines...) Expand 10 before | Expand all | Expand 10 after
1068 } 1069 }
1069 1070
1070 bool ExecuteBrowserCommandObserver::Register(int command) { 1071 bool ExecuteBrowserCommandObserver::Register(int command) {
1071 if (!GetNotificationType(command, &notification_type_)) 1072 if (!GetNotificationType(command, &notification_type_))
1072 return false; 1073 return false;
1073 registrar_.Add(this, notification_type_, NotificationService::AllSources()); 1074 registrar_.Add(this, notification_type_, NotificationService::AllSources());
1074 return true; 1075 return true;
1075 } 1076 }
1076 1077
1077 bool ExecuteBrowserCommandObserver::GetNotificationType( 1078 bool ExecuteBrowserCommandObserver::GetNotificationType(
1078 int command, NotificationType::Type* type) { 1079 int command, int* type) {
1079 if (!type) 1080 if (!type)
1080 return false; 1081 return false;
1081 bool found = false; 1082 bool found = false;
1082 for (unsigned int i = 0; i < arraysize(command_notifications); i++) { 1083 for (unsigned int i = 0; i < arraysize(command_notifications); i++) {
1083 if (command_notifications[i].command == command) { 1084 if (command_notifications[i].command == command) {
1084 *type = command_notifications[i].notification_type; 1085 *type = command_notifications[i].notification_type;
1085 found = true; 1086 found = true;
1086 break; 1087 break;
1087 } 1088 }
1088 } 1089 }
1089 return found; 1090 return found;
1090 } 1091 }
1091 1092
1092 FindInPageNotificationObserver::FindInPageNotificationObserver( 1093 FindInPageNotificationObserver::FindInPageNotificationObserver(
1093 AutomationProvider* automation, TabContents* parent_tab, 1094 AutomationProvider* automation, TabContents* parent_tab,
1094 bool reply_with_json, IPC::Message* reply_message) 1095 bool reply_with_json, IPC::Message* reply_message)
1095 : automation_(automation->AsWeakPtr()), 1096 : automation_(automation->AsWeakPtr()),
1096 active_match_ordinal_(-1), 1097 active_match_ordinal_(-1),
1097 reply_with_json_(reply_with_json), 1098 reply_with_json_(reply_with_json),
1098 reply_message_(reply_message) { 1099 reply_message_(reply_message) {
1099 registrar_.Add(this, NotificationType::FIND_RESULT_AVAILABLE, 1100 registrar_.Add(this, chrome::FIND_RESULT_AVAILABLE,
1100 Source<TabContents>(parent_tab)); 1101 Source<TabContents>(parent_tab));
1101 } 1102 }
1102 1103
1103 FindInPageNotificationObserver::~FindInPageNotificationObserver() { 1104 FindInPageNotificationObserver::~FindInPageNotificationObserver() {
1104 } 1105 }
1105 1106
1106 void FindInPageNotificationObserver::Observe( 1107 void FindInPageNotificationObserver::Observe(
1107 NotificationType type, const NotificationSource& source, 1108 NotificationType type, const NotificationSource& source,
1108 const NotificationDetails& details) { 1109 const NotificationDetails& details) {
1109 Details<FindNotificationDetails> find_details(details); 1110 Details<FindNotificationDetails> find_details(details);
(...skipping 35 matching lines...) Expand 10 before | Expand all | Expand 10 after
1145 automation_->Send(reply_message_.release()); 1146 automation_->Send(reply_message_.release());
1146 } 1147 }
1147 } 1148 }
1148 } 1149 }
1149 } 1150 }
1150 1151
1151 // static 1152 // static
1152 const int FindInPageNotificationObserver::kFindInPageRequestId = -1; 1153 const int FindInPageNotificationObserver::kFindInPageRequestId = -1;
1153 1154
1154 DomOperationObserver::DomOperationObserver() { 1155 DomOperationObserver::DomOperationObserver() {
1155 registrar_.Add(this, NotificationType::DOM_OPERATION_RESPONSE, 1156 registrar_.Add(this, chrome::DOM_OPERATION_RESPONSE,
1156 NotificationService::AllSources()); 1157 NotificationService::AllSources());
1157 } 1158 }
1158 1159
1159 DomOperationObserver::~DomOperationObserver() {} 1160 DomOperationObserver::~DomOperationObserver() {}
1160 1161
1161 void DomOperationObserver::Observe( 1162 void DomOperationObserver::Observe(
1162 NotificationType type, const NotificationSource& source, 1163 NotificationType type, const NotificationSource& source,
1163 const NotificationDetails& details) { 1164 const NotificationDetails& details) {
1164 if (NotificationType::DOM_OPERATION_RESPONSE == type) { 1165 if (chrome::DOM_OPERATION_RESPONSE == type) {
1165 Details<DomOperationNotificationDetails> dom_op_details(details); 1166 Details<DomOperationNotificationDetails> dom_op_details(details);
1166 OnDomOperationCompleted(dom_op_details->json()); 1167 OnDomOperationCompleted(dom_op_details->json());
1167 } 1168 }
1168 } 1169 }
1169 1170
1170 DomOperationMessageSender::DomOperationMessageSender( 1171 DomOperationMessageSender::DomOperationMessageSender(
1171 AutomationProvider* automation, 1172 AutomationProvider* automation,
1172 IPC::Message* reply_message, 1173 IPC::Message* reply_message,
1173 bool use_json_interface) 1174 bool use_json_interface)
1174 : automation_(automation->AsWeakPtr()), 1175 : automation_(automation->AsWeakPtr()),
(...skipping 17 matching lines...) Expand all
1192 } 1193 }
1193 } 1194 }
1194 delete this; 1195 delete this;
1195 } 1196 }
1196 1197
1197 DocumentPrintedNotificationObserver::DocumentPrintedNotificationObserver( 1198 DocumentPrintedNotificationObserver::DocumentPrintedNotificationObserver(
1198 AutomationProvider* automation, IPC::Message* reply_message) 1199 AutomationProvider* automation, IPC::Message* reply_message)
1199 : automation_(automation->AsWeakPtr()), 1200 : automation_(automation->AsWeakPtr()),
1200 success_(false), 1201 success_(false),
1201 reply_message_(reply_message) { 1202 reply_message_(reply_message) {
1202 registrar_.Add(this, NotificationType::PRINT_JOB_EVENT, 1203 registrar_.Add(this, chrome::PRINT_JOB_EVENT,
1203 NotificationService::AllSources()); 1204 NotificationService::AllSources());
1204 } 1205 }
1205 1206
1206 DocumentPrintedNotificationObserver::~DocumentPrintedNotificationObserver() { 1207 DocumentPrintedNotificationObserver::~DocumentPrintedNotificationObserver() {
1207 if (automation_) { 1208 if (automation_) {
1208 AutomationMsg_PrintNow::WriteReplyParams(reply_message_.get(), success_); 1209 AutomationMsg_PrintNow::WriteReplyParams(reply_message_.get(), success_);
1209 automation_->Send(reply_message_.release()); 1210 automation_->Send(reply_message_.release());
1210 } 1211 }
1211 } 1212 }
1212 1213
1213 void DocumentPrintedNotificationObserver::Observe( 1214 void DocumentPrintedNotificationObserver::Observe(
1214 NotificationType type, 1215 NotificationType type,
1215 const NotificationSource& source, 1216 const NotificationSource& source,
1216 const NotificationDetails& details) { 1217 const NotificationDetails& details) {
1217 DCHECK(type == NotificationType::PRINT_JOB_EVENT); 1218 DCHECK(type == chrome::PRINT_JOB_EVENT);
1218 switch (Details<printing::JobEventDetails>(details)->type()) { 1219 switch (Details<printing::JobEventDetails>(details)->type()) {
1219 case printing::JobEventDetails::JOB_DONE: { 1220 case printing::JobEventDetails::JOB_DONE: {
1220 // Succeeded. 1221 // Succeeded.
1221 success_ = true; 1222 success_ = true;
1222 delete this; 1223 delete this;
1223 break; 1224 break;
1224 } 1225 }
1225 case printing::JobEventDetails::USER_INIT_CANCELED: 1226 case printing::JobEventDetails::USER_INIT_CANCELED:
1226 case printing::JobEventDetails::FAILED: { 1227 case printing::JobEventDetails::FAILED: {
1227 // Failed. 1228 // Failed.
(...skipping 11 matching lines...) Expand all
1239 break; 1240 break;
1240 } 1241 }
1241 default: { 1242 default: {
1242 NOTREACHED(); 1243 NOTREACHED();
1243 break; 1244 break;
1244 } 1245 }
1245 } 1246 }
1246 } 1247 }
1247 1248
1248 MetricEventDurationObserver::MetricEventDurationObserver() { 1249 MetricEventDurationObserver::MetricEventDurationObserver() {
1249 registrar_.Add(this, NotificationType::METRIC_EVENT_DURATION, 1250 registrar_.Add(this, chrome::METRIC_EVENT_DURATION,
1250 NotificationService::AllSources()); 1251 NotificationService::AllSources());
1251 } 1252 }
1252 1253
1253 MetricEventDurationObserver::~MetricEventDurationObserver() {} 1254 MetricEventDurationObserver::~MetricEventDurationObserver() {}
1254 1255
1255 int MetricEventDurationObserver::GetEventDurationMs( 1256 int MetricEventDurationObserver::GetEventDurationMs(
1256 const std::string& event_name) { 1257 const std::string& event_name) {
1257 EventDurationMap::const_iterator it = durations_.find(event_name); 1258 EventDurationMap::const_iterator it = durations_.find(event_name);
1258 if (it == durations_.end()) 1259 if (it == durations_.end())
1259 return -1; 1260 return -1;
1260 return it->second; 1261 return it->second;
1261 } 1262 }
1262 1263
1263 void MetricEventDurationObserver::Observe(NotificationType type, 1264 void MetricEventDurationObserver::Observe(NotificationType type,
1264 const NotificationSource& source, const NotificationDetails& details) { 1265 const NotificationSource& source, const NotificationDetails& details) {
1265 if (type != NotificationType::METRIC_EVENT_DURATION) { 1266 if (type != chrome::METRIC_EVENT_DURATION) {
1266 NOTREACHED(); 1267 NOTREACHED();
1267 return; 1268 return;
1268 } 1269 }
1269 MetricEventDurationDetails* metric_event_duration = 1270 MetricEventDurationDetails* metric_event_duration =
1270 Details<MetricEventDurationDetails>(details).ptr(); 1271 Details<MetricEventDurationDetails>(details).ptr();
1271 durations_[metric_event_duration->event_name] = 1272 durations_[metric_event_duration->event_name] =
1272 metric_event_duration->duration_ms; 1273 metric_event_duration->duration_ms;
1273 } 1274 }
1274 1275
1275 PageTranslatedObserver::PageTranslatedObserver(AutomationProvider* automation, 1276 PageTranslatedObserver::PageTranslatedObserver(AutomationProvider* automation,
1276 IPC::Message* reply_message, 1277 IPC::Message* reply_message,
1277 TabContents* tab_contents) 1278 TabContents* tab_contents)
1278 : automation_(automation->AsWeakPtr()), 1279 : automation_(automation->AsWeakPtr()),
1279 reply_message_(reply_message) { 1280 reply_message_(reply_message) {
1280 registrar_.Add(this, NotificationType::PAGE_TRANSLATED, 1281 registrar_.Add(this, chrome::PAGE_TRANSLATED,
1281 Source<TabContents>(tab_contents)); 1282 Source<TabContents>(tab_contents));
1282 } 1283 }
1283 1284
1284 PageTranslatedObserver::~PageTranslatedObserver() {} 1285 PageTranslatedObserver::~PageTranslatedObserver() {}
1285 1286
1286 void PageTranslatedObserver::Observe(NotificationType type, 1287 void PageTranslatedObserver::Observe(NotificationType type,
1287 const NotificationSource& source, 1288 const NotificationSource& source,
1288 const NotificationDetails& details) { 1289 const NotificationDetails& details) {
1289 if (!automation_) { 1290 if (!automation_) {
1290 delete this; 1291 delete this;
1291 return; 1292 return;
1292 } 1293 }
1293 1294
1294 DCHECK(type == NotificationType::PAGE_TRANSLATED); 1295 DCHECK(type == chrome::PAGE_TRANSLATED);
1295 AutomationJSONReply reply(automation_, reply_message_.release()); 1296 AutomationJSONReply reply(automation_, reply_message_.release());
1296 1297
1297 PageTranslatedDetails* translated_details = 1298 PageTranslatedDetails* translated_details =
1298 Details<PageTranslatedDetails>(details).ptr(); 1299 Details<PageTranslatedDetails>(details).ptr();
1299 scoped_ptr<DictionaryValue> return_value(new DictionaryValue); 1300 scoped_ptr<DictionaryValue> return_value(new DictionaryValue);
1300 return_value->SetBoolean( 1301 return_value->SetBoolean(
1301 "translation_success", 1302 "translation_success",
1302 translated_details->error_type == TranslateErrors::NONE); 1303 translated_details->error_type == TranslateErrors::NONE);
1303 reply.SendSuccess(return_value.get()); 1304 reply.SendSuccess(return_value.get());
1304 delete this; 1305 delete this;
1305 } 1306 }
1306 1307
1307 TabLanguageDeterminedObserver::TabLanguageDeterminedObserver( 1308 TabLanguageDeterminedObserver::TabLanguageDeterminedObserver(
1308 AutomationProvider* automation, IPC::Message* reply_message, 1309 AutomationProvider* automation, IPC::Message* reply_message,
1309 TabContents* tab_contents, TranslateInfoBarDelegate* translate_bar) 1310 TabContents* tab_contents, TranslateInfoBarDelegate* translate_bar)
1310 : automation_(automation->AsWeakPtr()), 1311 : automation_(automation->AsWeakPtr()),
1311 reply_message_(reply_message), 1312 reply_message_(reply_message),
1312 tab_contents_(tab_contents), 1313 tab_contents_(tab_contents),
1313 translate_bar_(translate_bar) { 1314 translate_bar_(translate_bar) {
1314 registrar_.Add(this, NotificationType::TAB_LANGUAGE_DETERMINED, 1315 registrar_.Add(this, chrome::TAB_LANGUAGE_DETERMINED,
1315 Source<TabContents>(tab_contents)); 1316 Source<TabContents>(tab_contents));
1316 } 1317 }
1317 1318
1318 TabLanguageDeterminedObserver::~TabLanguageDeterminedObserver() {} 1319 TabLanguageDeterminedObserver::~TabLanguageDeterminedObserver() {}
1319 1320
1320 void TabLanguageDeterminedObserver::Observe( 1321 void TabLanguageDeterminedObserver::Observe(
1321 NotificationType type, const NotificationSource& source, 1322 NotificationType type, const NotificationSource& source,
1322 const NotificationDetails& details) { 1323 const NotificationDetails& details) {
1323 DCHECK(type == NotificationType::TAB_LANGUAGE_DETERMINED); 1324 DCHECK(type == chrome::TAB_LANGUAGE_DETERMINED);
1324 1325
1325 if (!automation_) { 1326 if (!automation_) {
1326 delete this; 1327 delete this;
1327 return; 1328 return;
1328 } 1329 }
1329 1330
1330 TranslateTabHelper* helper = TabContentsWrapper::GetCurrentWrapperForContents( 1331 TranslateTabHelper* helper = TabContentsWrapper::GetCurrentWrapperForContents(
1331 tab_contents_)->translate_tab_helper(); 1332 tab_contents_)->translate_tab_helper();
1332 scoped_ptr<DictionaryValue> return_value(new DictionaryValue); 1333 scoped_ptr<DictionaryValue> return_value(new DictionaryValue);
1333 return_value->SetBoolean("page_translated", 1334 return_value->SetBoolean("page_translated",
(...skipping 35 matching lines...) Expand 10 before | Expand all | Expand 10 after
1369 1370
1370 InfoBarCountObserver::InfoBarCountObserver(AutomationProvider* automation, 1371 InfoBarCountObserver::InfoBarCountObserver(AutomationProvider* automation,
1371 IPC::Message* reply_message, 1372 IPC::Message* reply_message,
1372 TabContentsWrapper* tab_contents, 1373 TabContentsWrapper* tab_contents,
1373 size_t target_count) 1374 size_t target_count)
1374 : automation_(automation->AsWeakPtr()), 1375 : automation_(automation->AsWeakPtr()),
1375 reply_message_(reply_message), 1376 reply_message_(reply_message),
1376 tab_contents_(tab_contents), 1377 tab_contents_(tab_contents),
1377 target_count_(target_count) { 1378 target_count_(target_count) {
1378 Source<TabContentsWrapper> source(tab_contents); 1379 Source<TabContentsWrapper> source(tab_contents);
1379 registrar_.Add(this, NotificationType::TAB_CONTENTS_INFOBAR_ADDED, source); 1380 registrar_.Add(this, chrome::TAB_CONTENTS_INFOBAR_ADDED, source);
1380 registrar_.Add(this, NotificationType::TAB_CONTENTS_INFOBAR_REMOVED, source); 1381 registrar_.Add(this, chrome::TAB_CONTENTS_INFOBAR_REMOVED, source);
1381 CheckCount(); 1382 CheckCount();
1382 } 1383 }
1383 1384
1384 InfoBarCountObserver::~InfoBarCountObserver() {} 1385 InfoBarCountObserver::~InfoBarCountObserver() {}
1385 1386
1386 void InfoBarCountObserver::Observe(NotificationType type, 1387 void InfoBarCountObserver::Observe(NotificationType type,
1387 const NotificationSource& source, 1388 const NotificationSource& source,
1388 const NotificationDetails& details) { 1389 const NotificationDetails& details) {
1389 DCHECK(type == NotificationType::TAB_CONTENTS_INFOBAR_ADDED || 1390 DCHECK(type == chrome::TAB_CONTENTS_INFOBAR_ADDED ||
1390 type == NotificationType::TAB_CONTENTS_INFOBAR_REMOVED); 1391 type == chrome::TAB_CONTENTS_INFOBAR_REMOVED);
1391 CheckCount(); 1392 CheckCount();
1392 } 1393 }
1393 1394
1394 void InfoBarCountObserver::CheckCount() { 1395 void InfoBarCountObserver::CheckCount() {
1395 if (tab_contents_->infobar_count() != target_count_) 1396 if (tab_contents_->infobar_count() != target_count_)
1396 return; 1397 return;
1397 1398
1398 if (automation_) { 1399 if (automation_) {
1399 AutomationMsg_WaitForInfoBarCount::WriteReplyParams(reply_message_.get(), 1400 AutomationMsg_WaitForInfoBarCount::WriteReplyParams(reply_message_.get(),
1400 true); 1401 true);
(...skipping 312 matching lines...) Expand 10 before | Expand all | Expand 10 after
1713 BrowserThread::PostTask( 1714 BrowserThread::PostTask(
1714 BrowserThread::DB, 1715 BrowserThread::DB,
1715 FROM_HERE, 1716 FROM_HERE,
1716 NewRunnableMethod( 1717 NewRunnableMethod(
1717 this, &PasswordStoreLoginsChangedObserver::RegisterObserversTask)); 1718 this, &PasswordStoreLoginsChangedObserver::RegisterObserversTask));
1718 done_event_.Wait(); 1719 done_event_.Wait();
1719 } 1720 }
1720 1721
1721 void PasswordStoreLoginsChangedObserver::RegisterObserversTask() { 1722 void PasswordStoreLoginsChangedObserver::RegisterObserversTask() {
1722 DCHECK(BrowserThread::CurrentlyOn(BrowserThread::DB)); 1723 DCHECK(BrowserThread::CurrentlyOn(BrowserThread::DB));
1723 registrar_.Add(this, NotificationType::LOGINS_CHANGED, 1724 registrar_.Add(this, chrome::LOGINS_CHANGED,
1724 NotificationService::AllSources()); 1725 NotificationService::AllSources());
1725 done_event_.Signal(); 1726 done_event_.Signal();
1726 } 1727 }
1727 1728
1728 void PasswordStoreLoginsChangedObserver::Observe( 1729 void PasswordStoreLoginsChangedObserver::Observe(
1729 NotificationType type, 1730 NotificationType type,
1730 const NotificationSource& source, 1731 const NotificationSource& source,
1731 const NotificationDetails& details) { 1732 const NotificationDetails& details) {
1732 DCHECK(BrowserThread::CurrentlyOn(BrowserThread::DB)); 1733 DCHECK(BrowserThread::CurrentlyOn(BrowserThread::DB));
1733 DCHECK(type.value == NotificationType::LOGINS_CHANGED); 1734 DCHECK(type.value == chrome::LOGINS_CHANGED);
1734 PasswordStoreChangeList* change_details = 1735 PasswordStoreChangeList* change_details =
1735 Details<PasswordStoreChangeList>(details).ptr(); 1736 Details<PasswordStoreChangeList>(details).ptr();
1736 if (change_details->size() != 1 || 1737 if (change_details->size() != 1 ||
1737 change_details->front().type() != expected_type_) { 1738 change_details->front().type() != expected_type_) {
1738 // Notify the UI thread that there's an error. 1739 // Notify the UI thread that there's an error.
1739 std::string error = "Unexpected password store login change details."; 1740 std::string error = "Unexpected password store login change details.";
1740 BrowserThread::PostTask( 1741 BrowserThread::PostTask(
1741 BrowserThread::UI, 1742 BrowserThread::UI,
1742 FROM_HERE, 1743 FROM_HERE,
1743 NewRunnableMethod( 1744 NewRunnableMethod(
(...skipping 54 matching lines...) Expand 10 before | Expand all | Expand 10 after
1798 OmniboxAcceptNotificationObserver::OmniboxAcceptNotificationObserver( 1799 OmniboxAcceptNotificationObserver::OmniboxAcceptNotificationObserver(
1799 NavigationController* controller, 1800 NavigationController* controller,
1800 AutomationProvider* automation, 1801 AutomationProvider* automation,
1801 IPC::Message* reply_message) 1802 IPC::Message* reply_message)
1802 : automation_(automation->AsWeakPtr()), 1803 : automation_(automation->AsWeakPtr()),
1803 reply_message_(reply_message), 1804 reply_message_(reply_message),
1804 controller_(controller) { 1805 controller_(controller) {
1805 Source<NavigationController> source(controller_); 1806 Source<NavigationController> source(controller_);
1806 registrar_.Add(this, NotificationType::LOAD_STOP, source); 1807 registrar_.Add(this, NotificationType::LOAD_STOP, source);
1807 // Pages requiring auth don't send LOAD_STOP. 1808 // Pages requiring auth don't send LOAD_STOP.
1808 registrar_.Add(this, NotificationType::AUTH_NEEDED, source); 1809 registrar_.Add(this, chrome::AUTH_NEEDED, source);
1809 } 1810 }
1810 1811
1811 OmniboxAcceptNotificationObserver::~OmniboxAcceptNotificationObserver() { 1812 OmniboxAcceptNotificationObserver::~OmniboxAcceptNotificationObserver() {
1812 } 1813 }
1813 1814
1814 void OmniboxAcceptNotificationObserver::Observe( 1815 void OmniboxAcceptNotificationObserver::Observe(
1815 NotificationType type, 1816 NotificationType type,
1816 const NotificationSource& source, 1817 const NotificationSource& source,
1817 const NotificationDetails& details) { 1818 const NotificationDetails& details) {
1818 if (type == NotificationType::LOAD_STOP || 1819 if (type == NotificationType::LOAD_STOP ||
1819 type == NotificationType::AUTH_NEEDED) { 1820 type == chrome::AUTH_NEEDED) {
1820 if (automation_) { 1821 if (automation_) {
1821 AutomationJSONReply(automation_, 1822 AutomationJSONReply(automation_,
1822 reply_message_.release()).SendSuccess(NULL); 1823 reply_message_.release()).SendSuccess(NULL);
1823 } 1824 }
1824 delete this; 1825 delete this;
1825 } else { 1826 } else {
1826 NOTREACHED(); 1827 NOTREACHED();
1827 } 1828 }
1828 } 1829 }
1829 1830
1830 SavePackageNotificationObserver::SavePackageNotificationObserver( 1831 SavePackageNotificationObserver::SavePackageNotificationObserver(
1831 SavePackage* save_package, 1832 SavePackage* save_package,
1832 AutomationProvider* automation, 1833 AutomationProvider* automation,
1833 IPC::Message* reply_message) 1834 IPC::Message* reply_message)
1834 : automation_(automation->AsWeakPtr()), 1835 : automation_(automation->AsWeakPtr()),
1835 reply_message_(reply_message) { 1836 reply_message_(reply_message) {
1836 Source<SavePackage> source(save_package); 1837 Source<SavePackage> source(save_package);
1837 registrar_.Add(this, NotificationType::SAVE_PACKAGE_SUCCESSFULLY_FINISHED, 1838 registrar_.Add(this, chrome::SAVE_PACKAGE_SUCCESSFULLY_FINISHED,
1838 source); 1839 source);
1839 } 1840 }
1840 1841
1841 SavePackageNotificationObserver::~SavePackageNotificationObserver() {} 1842 SavePackageNotificationObserver::~SavePackageNotificationObserver() {}
1842 1843
1843 void SavePackageNotificationObserver::Observe( 1844 void SavePackageNotificationObserver::Observe(
1844 NotificationType type, 1845 NotificationType type,
1845 const NotificationSource& source, 1846 const NotificationSource& source,
1846 const NotificationDetails& details) { 1847 const NotificationDetails& details) {
1847 if (type == NotificationType::SAVE_PACKAGE_SUCCESSFULLY_FINISHED) { 1848 if (type == chrome::SAVE_PACKAGE_SUCCESSFULLY_FINISHED) {
1848 if (automation_) { 1849 if (automation_) {
1849 AutomationJSONReply(automation_, 1850 AutomationJSONReply(automation_,
1850 reply_message_.release()).SendSuccess(NULL); 1851 reply_message_.release()).SendSuccess(NULL);
1851 } 1852 }
1852 delete this; 1853 delete this;
1853 } else { 1854 } else {
1854 NOTREACHED(); 1855 NOTREACHED();
1855 } 1856 }
1856 } 1857 }
1857 1858
(...skipping 183 matching lines...) Expand 10 before | Expand all | Expand 10 after
2041 2042
2042 // Add default site URLs. 2043 // Add default site URLs.
2043 ListValue* default_sites_list = new ListValue; 2044 ListValue* default_sites_list = new ListValue;
2044 std::vector<GURL> urls = MostVisitedHandler::GetPrePopulatedUrls(); 2045 std::vector<GURL> urls = MostVisitedHandler::GetPrePopulatedUrls();
2045 for (size_t i = 0; i < urls.size(); ++i) { 2046 for (size_t i = 0; i < urls.size(); ++i) {
2046 default_sites_list->Append(Value::CreateStringValue( 2047 default_sites_list->Append(Value::CreateStringValue(
2047 urls[i].possibly_invalid_spec())); 2048 urls[i].possibly_invalid_spec()));
2048 } 2049 }
2049 ntp_info_->Set("default_sites", default_sites_list); 2050 ntp_info_->Set("default_sites", default_sites_list);
2050 2051
2051 registrar_.Add(this, NotificationType::TOP_SITES_UPDATED, 2052 registrar_.Add(this, chrome::TOP_SITES_UPDATED,
2052 Source<history::TopSites>(top_sites_)); 2053 Source<history::TopSites>(top_sites_));
2053 if (top_sites_->loaded()) { 2054 if (top_sites_->loaded()) {
2054 OnTopSitesLoaded(); 2055 OnTopSitesLoaded();
2055 } else { 2056 } else {
2056 registrar_.Add(this, NotificationType::TOP_SITES_LOADED, 2057 registrar_.Add(this, chrome::TOP_SITES_LOADED,
2057 Source<Profile>(automation_->profile())); 2058 Source<Profile>(automation_->profile()));
2058 } 2059 }
2059 } 2060 }
2060 2061
2061 NTPInfoObserver::~NTPInfoObserver() {} 2062 NTPInfoObserver::~NTPInfoObserver() {}
2062 2063
2063 void NTPInfoObserver::Observe(NotificationType type, 2064 void NTPInfoObserver::Observe(NotificationType type,
2064 const NotificationSource& source, 2065 const NotificationSource& source,
2065 const NotificationDetails& details) { 2066 const NotificationDetails& details) {
2066 if (type == NotificationType::TOP_SITES_LOADED) { 2067 if (type == chrome::TOP_SITES_LOADED) {
2067 OnTopSitesLoaded(); 2068 OnTopSitesLoaded();
2068 } else if (type == NotificationType::TOP_SITES_UPDATED) { 2069 } else if (type == chrome::TOP_SITES_UPDATED) {
2069 Details<CancelableRequestProvider::Handle> request_details(details); 2070 Details<CancelableRequestProvider::Handle> request_details(details);
2070 if (request_ == *request_details.ptr()) { 2071 if (request_ == *request_details.ptr()) {
2071 top_sites_->GetMostVisitedURLs( 2072 top_sites_->GetMostVisitedURLs(
2072 consumer_, 2073 consumer_,
2073 NewCallback(this, &NTPInfoObserver::OnTopSitesReceived)); 2074 NewCallback(this, &NTPInfoObserver::OnTopSitesReceived));
2074 } 2075 }
2075 } 2076 }
2076 } 2077 }
2077 2078
2078 void NTPInfoObserver::OnTopSitesLoaded() { 2079 void NTPInfoObserver::OnTopSitesLoaded() {
(...skipping 35 matching lines...) Expand 10 before | Expand all | Expand 10 after
2114 launch_container_(launch_container), 2115 launch_container_(launch_container),
2115 new_window_id_(extension_misc::kUnknownWindowId) { 2116 new_window_id_(extension_misc::kUnknownWindowId) {
2116 if (launch_container_ == extension_misc::LAUNCH_TAB) { 2117 if (launch_container_ == extension_misc::LAUNCH_TAB) {
2117 // Need to wait for the currently-active tab to reload. 2118 // Need to wait for the currently-active tab to reload.
2118 Source<NavigationController> source(controller_); 2119 Source<NavigationController> source(controller_);
2119 registrar_.Add(this, NotificationType::LOAD_STOP, source); 2120 registrar_.Add(this, NotificationType::LOAD_STOP, source);
2120 } else { 2121 } else {
2121 // Need to wait for a new tab in a new window to load. 2122 // Need to wait for a new tab in a new window to load.
2122 registrar_.Add(this, NotificationType::LOAD_STOP, 2123 registrar_.Add(this, NotificationType::LOAD_STOP,
2123 NotificationService::AllSources()); 2124 NotificationService::AllSources());
2124 registrar_.Add(this, NotificationType::BROWSER_WINDOW_READY, 2125 registrar_.Add(this, chrome::BROWSER_WINDOW_READY,
2125 NotificationService::AllSources()); 2126 NotificationService::AllSources());
2126 } 2127 }
2127 } 2128 }
2128 2129
2129 AppLaunchObserver::~AppLaunchObserver() {} 2130 AppLaunchObserver::~AppLaunchObserver() {}
2130 2131
2131 void AppLaunchObserver::Observe(NotificationType type, 2132 void AppLaunchObserver::Observe(NotificationType type,
2132 const NotificationSource& source, 2133 const NotificationSource& source,
2133 const NotificationDetails& details) { 2134 const NotificationDetails& details) {
2134 if (type.value == NotificationType::LOAD_STOP) { 2135 if (type.value == NotificationType::LOAD_STOP) {
(...skipping 15 matching lines...) Expand all
2150 int window_id = tab ? tab->restore_tab_helper()->window_id().id() : -1; 2151 int window_id = tab ? tab->restore_tab_helper()->window_id().id() : -1;
2151 if (window_id == new_window_id_) { 2152 if (window_id == new_window_id_) {
2152 if (automation_) { 2153 if (automation_) {
2153 AutomationJSONReply(automation_, 2154 AutomationJSONReply(automation_,
2154 reply_message_.release()).SendSuccess(NULL); 2155 reply_message_.release()).SendSuccess(NULL);
2155 } 2156 }
2156 delete this; 2157 delete this;
2157 return; 2158 return;
2158 } 2159 }
2159 } 2160 }
2160 } else if (type.value == NotificationType::BROWSER_WINDOW_READY) { 2161 } else if (type.value == chrome::BROWSER_WINDOW_READY) {
2161 new_window_id_ = ExtensionTabUtil::GetWindowId( 2162 new_window_id_ = ExtensionTabUtil::GetWindowId(
2162 Source<Browser>(source).ptr()); 2163 Source<Browser>(source).ptr());
2163 } else { 2164 } else {
2164 NOTREACHED(); 2165 NOTREACHED();
2165 } 2166 }
2166 } 2167 }
2167 2168
2168 AutofillDisplayedObserver::AutofillDisplayedObserver( 2169 AutofillDisplayedObserver::AutofillDisplayedObserver(
2169 NotificationType notification, 2170 NotificationType notification,
2170 RenderViewHost* render_view_host, 2171 RenderViewHost* render_view_host,
(...skipping 44 matching lines...) Expand 10 before | Expand all | Expand 10 after
2215 DCHECK(BrowserThread::CurrentlyOn(BrowserThread::UI)); 2216 DCHECK(BrowserThread::CurrentlyOn(BrowserThread::UI));
2216 BrowserThread::PostTask( 2217 BrowserThread::PostTask(
2217 BrowserThread::DB, 2218 BrowserThread::DB,
2218 FROM_HERE, 2219 FROM_HERE,
2219 NewRunnableMethod(this, &AutofillChangedObserver::RegisterObserversTask)); 2220 NewRunnableMethod(this, &AutofillChangedObserver::RegisterObserversTask));
2220 done_event_.Wait(); 2221 done_event_.Wait();
2221 } 2222 }
2222 2223
2223 void AutofillChangedObserver::RegisterObserversTask() { 2224 void AutofillChangedObserver::RegisterObserversTask() {
2224 DCHECK(BrowserThread::CurrentlyOn(BrowserThread::DB)); 2225 DCHECK(BrowserThread::CurrentlyOn(BrowserThread::DB));
2225 registrar_.Add(this, NotificationType::AUTOFILL_CREDIT_CARD_CHANGED, 2226 registrar_.Add(this, chrome::AUTOFILL_CREDIT_CARD_CHANGED,
2226 NotificationService::AllSources()); 2227 NotificationService::AllSources());
2227 registrar_.Add(this, NotificationType::AUTOFILL_PROFILE_CHANGED, 2228 registrar_.Add(this, chrome::AUTOFILL_PROFILE_CHANGED,
2228 NotificationService::AllSources()); 2229 NotificationService::AllSources());
2229 done_event_.Signal(); 2230 done_event_.Signal();
2230 } 2231 }
2231 2232
2232 void AutofillChangedObserver::Observe( 2233 void AutofillChangedObserver::Observe(
2233 NotificationType type, 2234 NotificationType type,
2234 const NotificationSource& source, 2235 const NotificationSource& source,
2235 const NotificationDetails& details) { 2236 const NotificationDetails& details) {
2236 DCHECK(BrowserThread::CurrentlyOn(BrowserThread::DB)); 2237 DCHECK(BrowserThread::CurrentlyOn(BrowserThread::DB));
2237 2238
2238 if (type.value == NotificationType::AUTOFILL_CREDIT_CARD_CHANGED) { 2239 if (type.value == chrome::AUTOFILL_CREDIT_CARD_CHANGED) {
2239 num_credit_cards_--; 2240 num_credit_cards_--;
2240 } else if (type.value == NotificationType::AUTOFILL_PROFILE_CHANGED) { 2241 } else if (type.value == chrome::AUTOFILL_PROFILE_CHANGED) {
2241 num_profiles_--; 2242 num_profiles_--;
2242 } else { 2243 } else {
2243 NOTREACHED(); 2244 NOTREACHED();
2244 } 2245 }
2245 2246
2246 if (num_profiles_ == 0 && num_credit_cards_ == 0) { 2247 if (num_profiles_ == 0 && num_credit_cards_ == 0) {
2247 registrar_.RemoveAll(); // Must be done from the DB thread. 2248 registrar_.RemoveAll(); // Must be done from the DB thread.
2248 2249
2249 // Notify the UI thread that we're done listening for all relevant 2250 // Notify the UI thread that we're done listening for all relevant
2250 // autofill notifications. 2251 // autofill notifications.
(...skipping 31 matching lines...) Expand 10 before | Expand all | Expand 10 after
2282 } // namespace 2283 } // namespace
2283 2284
2284 GetActiveNotificationsObserver::GetActiveNotificationsObserver( 2285 GetActiveNotificationsObserver::GetActiveNotificationsObserver(
2285 AutomationProvider* automation, 2286 AutomationProvider* automation,
2286 IPC::Message* reply_message) 2287 IPC::Message* reply_message)
2287 : automation_(automation->AsWeakPtr()), 2288 : automation_(automation->AsWeakPtr()),
2288 reply_message_(reply_message) { 2289 reply_message_(reply_message) {
2289 if (AreActiveNotificationProcessesReady()) { 2290 if (AreActiveNotificationProcessesReady()) {
2290 SendMessage(); 2291 SendMessage();
2291 } else { 2292 } else {
2292 registrar_.Add(this, NotificationType::NOTIFY_BALLOON_CONNECTED, 2293 registrar_.Add(this, chrome::NOTIFY_BALLOON_CONNECTED,
2293 NotificationService::AllSources()); 2294 NotificationService::AllSources());
2294 } 2295 }
2295 } 2296 }
2296 2297
2297 GetActiveNotificationsObserver::~GetActiveNotificationsObserver() {} 2298 GetActiveNotificationsObserver::~GetActiveNotificationsObserver() {}
2298 2299
2299 void GetActiveNotificationsObserver::Observe( 2300 void GetActiveNotificationsObserver::Observe(
2300 NotificationType type, 2301 NotificationType type,
2301 const NotificationSource& source, 2302 const NotificationSource& source,
2302 const NotificationDetails& details) { 2303 const NotificationDetails& details) {
(...skipping 32 matching lines...) Expand 10 before | Expand all | Expand 10 after
2335 2336
2336 OnNotificationBalloonCountObserver::OnNotificationBalloonCountObserver( 2337 OnNotificationBalloonCountObserver::OnNotificationBalloonCountObserver(
2337 AutomationProvider* provider, 2338 AutomationProvider* provider,
2338 IPC::Message* reply_message, 2339 IPC::Message* reply_message,
2339 int count) 2340 int count)
2340 : automation_(provider->AsWeakPtr()), 2341 : automation_(provider->AsWeakPtr()),
2341 reply_message_(reply_message), 2342 reply_message_(reply_message),
2342 collection_( 2343 collection_(
2343 g_browser_process->notification_ui_manager()->balloon_collection()), 2344 g_browser_process->notification_ui_manager()->balloon_collection()),
2344 count_(count) { 2345 count_(count) {
2345 registrar_.Add(this, NotificationType::NOTIFY_BALLOON_CONNECTED, 2346 registrar_.Add(this, chrome::NOTIFY_BALLOON_CONNECTED,
2346 NotificationService::AllSources()); 2347 NotificationService::AllSources());
2347 collection_->set_on_collection_changed_callback(NewCallback( 2348 collection_->set_on_collection_changed_callback(NewCallback(
2348 this, &OnNotificationBalloonCountObserver::CheckBalloonCount)); 2349 this, &OnNotificationBalloonCountObserver::CheckBalloonCount));
2349 CheckBalloonCount(); 2350 CheckBalloonCount();
2350 } 2351 }
2351 2352
2352 OnNotificationBalloonCountObserver::~OnNotificationBalloonCountObserver() { 2353 OnNotificationBalloonCountObserver::~OnNotificationBalloonCountObserver() {
2353 } 2354 }
2354 2355
2355 void OnNotificationBalloonCountObserver::Observe( 2356 void OnNotificationBalloonCountObserver::Observe(
(...skipping 231 matching lines...) Expand 10 before | Expand all | Expand 10 after
2587 void DragTargetDropAckNotificationObserver::Observe( 2588 void DragTargetDropAckNotificationObserver::Observe(
2588 NotificationType type, 2589 NotificationType type,
2589 const NotificationSource& source, 2590 const NotificationSource& source,
2590 const NotificationDetails& details) { 2591 const NotificationDetails& details) {
2591 if (automation_) { 2592 if (automation_) {
2592 AutomationJSONReply(automation_, 2593 AutomationJSONReply(automation_,
2593 reply_message_.release()).SendSuccess(NULL); 2594 reply_message_.release()).SendSuccess(NULL);
2594 } 2595 }
2595 delete this; 2596 delete this;
2596 } 2597 }
OLDNEW

Powered by Google App Engine
This is Rietveld 408576698