| 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 142 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 153 return_value->Set("tabs", items); | 153 return_value->Set("tabs", items); |
| 154 return return_value; | 154 return return_value; |
| 155 } | 155 } |
| 156 | 156 |
| 157 void InitialLoadObserver::ConditionMet() { | 157 void InitialLoadObserver::ConditionMet() { |
| 158 registrar_.RemoveAll(); | 158 registrar_.RemoveAll(); |
| 159 if (automation_) | 159 if (automation_) |
| 160 automation_->OnInitialTabLoadsComplete(); | 160 automation_->OnInitialTabLoadsComplete(); |
| 161 } | 161 } |
| 162 | 162 |
| 163 NewTabUILoadObserver::NewTabUILoadObserver(AutomationProvider* automation) | 163 NewTabUILoadObserver::NewTabUILoadObserver(AutomationProvider* automation, |
| 164 Profile* profile) |
| 164 : automation_(automation->AsWeakPtr()) { | 165 : automation_(automation->AsWeakPtr()) { |
| 165 registrar_.Add(this, chrome::NOTIFICATION_INITIAL_NEW_TAB_UI_LOAD, | 166 registrar_.Add(this, chrome::NOTIFICATION_INITIAL_NEW_TAB_UI_LOAD, |
| 166 NotificationService::AllSources()); | 167 Source<Profile>(profile)); |
| 167 } | 168 } |
| 168 | 169 |
| 169 NewTabUILoadObserver::~NewTabUILoadObserver() { | 170 NewTabUILoadObserver::~NewTabUILoadObserver() { |
| 170 } | 171 } |
| 171 | 172 |
| 172 void NewTabUILoadObserver::Observe(int type, | 173 void NewTabUILoadObserver::Observe(int type, |
| 173 const NotificationSource& source, | 174 const NotificationSource& source, |
| 174 const NotificationDetails& details) { | 175 const NotificationDetails& details) { |
| 175 if (type == chrome::NOTIFICATION_INITIAL_NEW_TAB_UI_LOAD) { | 176 if (type == chrome::NOTIFICATION_INITIAL_NEW_TAB_UI_LOAD) { |
| 176 Details<int> load_time(details); | 177 Details<int> load_time(details); |
| (...skipping 579 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 756 } | 757 } |
| 757 | 758 |
| 758 BrowserOpenedNotificationObserver::BrowserOpenedNotificationObserver( | 759 BrowserOpenedNotificationObserver::BrowserOpenedNotificationObserver( |
| 759 AutomationProvider* automation, | 760 AutomationProvider* automation, |
| 760 IPC::Message* reply_message) | 761 IPC::Message* reply_message) |
| 761 : automation_(automation->AsWeakPtr()), | 762 : automation_(automation->AsWeakPtr()), |
| 762 reply_message_(reply_message), | 763 reply_message_(reply_message), |
| 763 new_window_id_(extension_misc::kUnknownWindowId), | 764 new_window_id_(extension_misc::kUnknownWindowId), |
| 764 for_browser_command_(false) { | 765 for_browser_command_(false) { |
| 765 registrar_.Add(this, chrome::NOTIFICATION_BROWSER_OPENED, | 766 registrar_.Add(this, chrome::NOTIFICATION_BROWSER_OPENED, |
| 766 NotificationService::AllSources()); | 767 NotificationService::AllBrowserContextsAndSources()); |
| 767 registrar_.Add(this, content::NOTIFICATION_LOAD_STOP, | 768 registrar_.Add(this, content::NOTIFICATION_LOAD_STOP, |
| 768 NotificationService::AllSources()); | 769 NotificationService::AllBrowserContextsAndSources()); |
| 769 } | 770 } |
| 770 | 771 |
| 771 BrowserOpenedNotificationObserver::~BrowserOpenedNotificationObserver() { | 772 BrowserOpenedNotificationObserver::~BrowserOpenedNotificationObserver() { |
| 772 } | 773 } |
| 773 | 774 |
| 774 void BrowserOpenedNotificationObserver::Observe( | 775 void BrowserOpenedNotificationObserver::Observe( |
| 775 int type, const NotificationSource& source, | 776 int type, const NotificationSource& source, |
| 776 const NotificationDetails& details) { | 777 const NotificationDetails& details) { |
| 777 if (!automation_) { | 778 if (!automation_) { |
| 778 delete this; | 779 delete this; |
| (...skipping 73 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 852 } | 853 } |
| 853 | 854 |
| 854 BrowserCountChangeNotificationObserver::BrowserCountChangeNotificationObserver( | 855 BrowserCountChangeNotificationObserver::BrowserCountChangeNotificationObserver( |
| 855 int target_count, | 856 int target_count, |
| 856 AutomationProvider* automation, | 857 AutomationProvider* automation, |
| 857 IPC::Message* reply_message) | 858 IPC::Message* reply_message) |
| 858 : target_count_(target_count), | 859 : target_count_(target_count), |
| 859 automation_(automation->AsWeakPtr()), | 860 automation_(automation->AsWeakPtr()), |
| 860 reply_message_(reply_message) { | 861 reply_message_(reply_message) { |
| 861 registrar_.Add(this, chrome::NOTIFICATION_BROWSER_OPENED, | 862 registrar_.Add(this, chrome::NOTIFICATION_BROWSER_OPENED, |
| 862 NotificationService::AllSources()); | 863 NotificationService::AllBrowserContextsAndSources()); |
| 863 registrar_.Add(this, chrome::NOTIFICATION_BROWSER_CLOSED, | 864 registrar_.Add(this, chrome::NOTIFICATION_BROWSER_CLOSED, |
| 864 NotificationService::AllSources()); | 865 NotificationService::AllBrowserContextsAndSources()); |
| 865 } | 866 } |
| 866 | 867 |
| 867 BrowserCountChangeNotificationObserver:: | 868 BrowserCountChangeNotificationObserver:: |
| 868 ~BrowserCountChangeNotificationObserver() {} | 869 ~BrowserCountChangeNotificationObserver() {} |
| 869 | 870 |
| 870 void BrowserCountChangeNotificationObserver::Observe( | 871 void BrowserCountChangeNotificationObserver::Observe( |
| 871 int type, | 872 int type, |
| 872 const NotificationSource& source, | 873 const NotificationSource& source, |
| 873 const NotificationDetails& details) { | 874 const NotificationDetails& details) { |
| 874 DCHECK(type == chrome::NOTIFICATION_BROWSER_OPENED || | 875 DCHECK(type == chrome::NOTIFICATION_BROWSER_OPENED || |
| (...skipping 1731 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 2606 void DragTargetDropAckNotificationObserver::Observe( | 2607 void DragTargetDropAckNotificationObserver::Observe( |
| 2607 int type, | 2608 int type, |
| 2608 const NotificationSource& source, | 2609 const NotificationSource& source, |
| 2609 const NotificationDetails& details) { | 2610 const NotificationDetails& details) { |
| 2610 if (automation_) { | 2611 if (automation_) { |
| 2611 AutomationJSONReply(automation_, | 2612 AutomationJSONReply(automation_, |
| 2612 reply_message_.release()).SendSuccess(NULL); | 2613 reply_message_.release()).SendSuccess(NULL); |
| 2613 } | 2614 } |
| 2614 delete this; | 2615 delete this; |
| 2615 } | 2616 } |
| OLD | NEW |