| OLD | NEW |
| 1 // Copyright (c) 2012 The Chromium Authors. All rights reserved. | 1 // Copyright (c) 2012 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 #ifndef CHROME_BROWSER_AUTOMATION_AUTOMATION_PROVIDER_OBSERVERS_H_ | 5 #ifndef CHROME_BROWSER_AUTOMATION_AUTOMATION_PROVIDER_OBSERVERS_H_ |
| 6 #define CHROME_BROWSER_AUTOMATION_AUTOMATION_PROVIDER_OBSERVERS_H_ | 6 #define CHROME_BROWSER_AUTOMATION_AUTOMATION_PROVIDER_OBSERVERS_H_ |
| 7 | 7 |
| 8 #include <deque> | 8 #include <deque> |
| 9 #include <map> | 9 #include <map> |
| 10 #include <set> | 10 #include <set> |
| 11 #include <string> | 11 #include <string> |
| 12 #include <vector> | 12 #include <vector> |
| 13 | 13 |
| 14 #include "base/callback.h" | 14 #include "base/callback.h" |
| 15 #include "base/compiler_specific.h" | 15 #include "base/compiler_specific.h" |
| 16 #include "base/memory/scoped_ptr.h" | 16 #include "base/memory/scoped_ptr.h" |
| 17 #include "base/memory/weak_ptr.h" | 17 #include "base/memory/weak_ptr.h" |
| 18 #include "base/sequenced_task_runner_helpers.h" | 18 #include "base/sequenced_task_runner_helpers.h" |
| 19 #include "base/synchronization/waitable_event.h" | 19 #include "base/synchronization/waitable_event.h" |
| 20 #include "base/values.h" | 20 #include "base/values.h" |
| 21 #include "chrome/browser/automation/automation_provider_json.h" | 21 #include "chrome/browser/automation/automation_provider_json.h" |
| 22 #include "chrome/browser/bookmarks/bookmark_model_observer.h" | 22 #include "chrome/browser/bookmarks/bookmark_model_observer.h" |
| 23 #include "components/autofill/core/browser/personal_data_manager.h" | 23 #include "components/autofill/core/browser/personal_data_manager.h" |
| 24 #include "components/autofill/core/browser/personal_data_manager_observer.h" | 24 #include "components/autofill/core/browser/personal_data_manager_observer.h" |
| 25 #if defined(OS_CHROMEOS) | 25 #if defined(OS_CHROMEOS) |
| 26 #include "chrome/browser/chromeos/cros/network_library.h" | |
| 27 #include "chrome/browser/chromeos/login/enrollment/enrollment_screen.h" | 26 #include "chrome/browser/chromeos/login/enrollment/enrollment_screen.h" |
| 28 #include "chrome/browser/chromeos/login/login_status_consumer.h" | 27 #include "chrome/browser/chromeos/login/login_status_consumer.h" |
| 29 #include "chrome/browser/chromeos/login/user_manager.h" | 28 #include "chrome/browser/chromeos/login/user_manager.h" |
| 30 #include "chrome/browser/chromeos/login/wizard_controller.h" | 29 #include "chrome/browser/chromeos/login/wizard_controller.h" |
| 31 #endif // defined(OS_CHROMEOS) | 30 #endif // defined(OS_CHROMEOS) |
| 32 #include "chrome/browser/common/cancelable_request.h" | 31 #include "chrome/browser/common/cancelable_request.h" |
| 33 #include "chrome/browser/download/all_download_item_notifier.h" | 32 #include "chrome/browser/download/all_download_item_notifier.h" |
| 34 #include "chrome/browser/history/history_service.h" | 33 #include "chrome/browser/history/history_service.h" |
| 35 #include "chrome/browser/history/history_types.h" | 34 #include "chrome/browser/history/history_types.h" |
| 36 #include "chrome/browser/importer/importer_progress_observer.h" | 35 #include "chrome/browser/importer/importer_progress_observer.h" |
| (...skipping 89 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 126 size_t crashed_tab_count_; | 125 size_t crashed_tab_count_; |
| 127 size_t outstanding_tab_count_; | 126 size_t outstanding_tab_count_; |
| 128 base::TimeTicks init_time_; | 127 base::TimeTicks init_time_; |
| 129 TabTimeMap loading_tabs_; | 128 TabTimeMap loading_tabs_; |
| 130 TabSet finished_tabs_; | 129 TabSet finished_tabs_; |
| 131 | 130 |
| 132 DISALLOW_COPY_AND_ASSIGN(InitialLoadObserver); | 131 DISALLOW_COPY_AND_ASSIGN(InitialLoadObserver); |
| 133 }; | 132 }; |
| 134 | 133 |
| 135 #if defined(OS_CHROMEOS) | 134 #if defined(OS_CHROMEOS) |
| 136 // Watches for NetworkManager events. Because NetworkLibrary loads | |
| 137 // asynchronously, this is used to make sure it is done before tests are run. | |
| 138 class NetworkManagerInitObserver | |
| 139 : public chromeos::NetworkLibrary::NetworkManagerObserver { | |
| 140 public: | |
| 141 explicit NetworkManagerInitObserver(AutomationProvider* automation); | |
| 142 virtual ~NetworkManagerInitObserver(); | |
| 143 virtual bool Init(); | |
| 144 virtual void OnNetworkManagerChanged(chromeos::NetworkLibrary* obj); | |
| 145 | |
| 146 private: | |
| 147 base::WeakPtr<AutomationProvider> automation_; | |
| 148 | |
| 149 DISALLOW_COPY_AND_ASSIGN(NetworkManagerInitObserver); | |
| 150 }; | |
| 151 | |
| 152 // Observes when the ChromeOS login WebUI becomes ready (by showing the login | 135 // Observes when the ChromeOS login WebUI becomes ready (by showing the login |
| 153 // form, account picker, a network error or the OOBE wizard, depending on Chrome | 136 // form, account picker, a network error or the OOBE wizard, depending on Chrome |
| 154 // flags and state). | 137 // flags and state). |
| 155 class OOBEWebuiReadyObserver : public content::NotificationObserver { | 138 class OOBEWebuiReadyObserver : public content::NotificationObserver { |
| 156 public: | 139 public: |
| 157 explicit OOBEWebuiReadyObserver(AutomationProvider* automation); | 140 explicit OOBEWebuiReadyObserver(AutomationProvider* automation); |
| 158 | 141 |
| 159 // Overridden from content::NotificationObserver: | 142 // Overridden from content::NotificationObserver: |
| 160 virtual void Observe(int type, | 143 virtual void Observe(int type, |
| 161 const content::NotificationSource& source, | 144 const content::NotificationSource& source, |
| (...skipping 619 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 781 | 764 |
| 782 virtual void OnLoginSuccess( | 765 virtual void OnLoginSuccess( |
| 783 const chromeos::UserContext& user_context, | 766 const chromeos::UserContext& user_context, |
| 784 bool pending_requests, | 767 bool pending_requests, |
| 785 bool using_oauth) {} | 768 bool using_oauth) {} |
| 786 | 769 |
| 787 private: | 770 private: |
| 788 DISALLOW_COPY_AND_ASSIGN(ScreenUnlockObserver); | 771 DISALLOW_COPY_AND_ASSIGN(ScreenUnlockObserver); |
| 789 }; | 772 }; |
| 790 | 773 |
| 791 class NetworkScanObserver | |
| 792 : public chromeos::NetworkLibrary::NetworkManagerObserver { | |
| 793 public: | |
| 794 NetworkScanObserver(AutomationProvider* automation, | |
| 795 IPC::Message* reply_message); | |
| 796 | |
| 797 virtual ~NetworkScanObserver(); | |
| 798 | |
| 799 // NetworkLibrary::NetworkManagerObserver implementation. | |
| 800 virtual void OnNetworkManagerChanged(chromeos::NetworkLibrary* obj); | |
| 801 | |
| 802 private: | |
| 803 base::WeakPtr<AutomationProvider> automation_; | |
| 804 scoped_ptr<IPC::Message> reply_message_; | |
| 805 | |
| 806 DISALLOW_COPY_AND_ASSIGN(NetworkScanObserver); | |
| 807 }; | |
| 808 | |
| 809 class ToggleNetworkDeviceObserver | |
| 810 : public chromeos::NetworkLibrary::NetworkManagerObserver { | |
| 811 public: | |
| 812 ToggleNetworkDeviceObserver(AutomationProvider* automation, | |
| 813 IPC::Message* reply_message, | |
| 814 const std::string& device, | |
| 815 bool enable); | |
| 816 | |
| 817 virtual ~ToggleNetworkDeviceObserver(); | |
| 818 | |
| 819 // NetworkLibrary::NetworkManagerObserver implementation. | |
| 820 virtual void OnNetworkManagerChanged(chromeos::NetworkLibrary* obj); | |
| 821 | |
| 822 private: | |
| 823 base::WeakPtr<AutomationProvider> automation_; | |
| 824 scoped_ptr<IPC::Message> reply_message_; | |
| 825 std::string device_; | |
| 826 bool enable_; | |
| 827 | |
| 828 DISALLOW_COPY_AND_ASSIGN(ToggleNetworkDeviceObserver); | |
| 829 }; | |
| 830 | |
| 831 class NetworkStatusObserver | |
| 832 : public chromeos::NetworkLibrary::NetworkManagerObserver { | |
| 833 public: | |
| 834 NetworkStatusObserver(AutomationProvider* automation, | |
| 835 IPC::Message* reply_message); | |
| 836 virtual ~NetworkStatusObserver(); | |
| 837 | |
| 838 virtual const chromeos::Network* GetNetwork( | |
| 839 chromeos::NetworkLibrary* network_library) = 0; | |
| 840 // NetworkLibrary::NetworkManagerObserver implementation. | |
| 841 virtual void OnNetworkManagerChanged(chromeos::NetworkLibrary* obj); | |
| 842 virtual void NetworkStatusCheck(const chromeos::Network* network) = 0; | |
| 843 | |
| 844 protected: | |
| 845 base::WeakPtr<AutomationProvider> automation_; | |
| 846 scoped_ptr<IPC::Message> reply_message_; | |
| 847 | |
| 848 private: | |
| 849 DISALLOW_COPY_AND_ASSIGN(NetworkStatusObserver); | |
| 850 }; | |
| 851 | |
| 852 // Waits for a connection success or failure for the specified | |
| 853 // network and returns the status to the automation provider. | |
| 854 class NetworkConnectObserver : public NetworkStatusObserver { | |
| 855 public: | |
| 856 NetworkConnectObserver(AutomationProvider* automation, | |
| 857 IPC::Message* reply_message); | |
| 858 | |
| 859 virtual void NetworkStatusCheck(const chromeos::Network* network); | |
| 860 | |
| 861 private: | |
| 862 DISALLOW_COPY_AND_ASSIGN(NetworkConnectObserver); | |
| 863 }; | |
| 864 | |
| 865 // Waits until a network has disconnected. Then returns success | |
| 866 // or failure. | |
| 867 class NetworkDisconnectObserver : public NetworkStatusObserver { | |
| 868 public: | |
| 869 NetworkDisconnectObserver(AutomationProvider* automation, | |
| 870 IPC::Message* reply_message, | |
| 871 const std::string& service_path); | |
| 872 | |
| 873 virtual void NetworkStatusCheck(const chromeos::Network* network); | |
| 874 const chromeos::Network* GetNetwork( | |
| 875 chromeos::NetworkLibrary* network_library); | |
| 876 | |
| 877 private: | |
| 878 std::string service_path_; | |
| 879 DISALLOW_COPY_AND_ASSIGN(NetworkDisconnectObserver); | |
| 880 }; | |
| 881 | |
| 882 // Waits for a connection success or failure for the specified | |
| 883 // network and returns the status to the automation provider. | |
| 884 class ServicePathConnectObserver : public NetworkConnectObserver { | |
| 885 public: | |
| 886 ServicePathConnectObserver(AutomationProvider* automation, | |
| 887 IPC::Message* reply_message, | |
| 888 const std::string& service_path); | |
| 889 | |
| 890 const chromeos::Network* GetNetwork( | |
| 891 chromeos::NetworkLibrary* network_library); | |
| 892 | |
| 893 private: | |
| 894 std::string service_path_; | |
| 895 DISALLOW_COPY_AND_ASSIGN(ServicePathConnectObserver); | |
| 896 }; | |
| 897 | |
| 898 // Waits for a connection success or failure for the specified | |
| 899 // network and returns the status to the automation provider. | |
| 900 class SSIDConnectObserver : public NetworkConnectObserver { | |
| 901 public: | |
| 902 SSIDConnectObserver(AutomationProvider* automation, | |
| 903 IPC::Message* reply_message, | |
| 904 const std::string& ssid); | |
| 905 | |
| 906 const chromeos::Network* GetNetwork( | |
| 907 chromeos::NetworkLibrary* network_library); | |
| 908 | |
| 909 private: | |
| 910 std::string ssid_; | |
| 911 DISALLOW_COPY_AND_ASSIGN(SSIDConnectObserver); | |
| 912 }; | |
| 913 | |
| 914 // Waits for a connection success or failure for the specified | |
| 915 // virtual network and returns the status to the automation provider. | |
| 916 class VirtualConnectObserver | |
| 917 : public chromeos::NetworkLibrary::NetworkManagerObserver { | |
| 918 public: | |
| 919 VirtualConnectObserver(AutomationProvider* automation, | |
| 920 IPC::Message* reply_message, | |
| 921 const std::string& service_name); | |
| 922 | |
| 923 virtual ~VirtualConnectObserver(); | |
| 924 | |
| 925 // NetworkLibrary::NetworkManagerObserver implementation. | |
| 926 virtual void OnNetworkManagerChanged(chromeos::NetworkLibrary* cros); | |
| 927 | |
| 928 private: | |
| 929 virtual chromeos::VirtualNetwork* GetVirtualNetwork( | |
| 930 const chromeos::NetworkLibrary* cros); | |
| 931 | |
| 932 base::WeakPtr<AutomationProvider> automation_; | |
| 933 scoped_ptr<IPC::Message> reply_message_; | |
| 934 std::string service_name_; | |
| 935 | |
| 936 DISALLOW_COPY_AND_ASSIGN(VirtualConnectObserver); | |
| 937 }; | |
| 938 | |
| 939 #endif // defined(OS_CHROMEOS) | 774 #endif // defined(OS_CHROMEOS) |
| 940 | 775 |
| 941 // Waits for the bookmark model to load. | 776 // Waits for the bookmark model to load. |
| 942 class AutomationProviderBookmarkModelObserver : public BookmarkModelObserver { | 777 class AutomationProviderBookmarkModelObserver : public BookmarkModelObserver { |
| 943 public: | 778 public: |
| 944 AutomationProviderBookmarkModelObserver(AutomationProvider* provider, | 779 AutomationProviderBookmarkModelObserver(AutomationProvider* provider, |
| 945 IPC::Message* reply_message, | 780 IPC::Message* reply_message, |
| 946 BookmarkModel* model, | 781 BookmarkModel* model, |
| 947 bool use_json_interface); | 782 bool use_json_interface); |
| 948 virtual ~AutomationProviderBookmarkModelObserver(); | 783 virtual ~AutomationProviderBookmarkModelObserver(); |
| (...skipping 704 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 1653 base::WeakPtr<AutomationProvider> automation_; | 1488 base::WeakPtr<AutomationProvider> automation_; |
| 1654 scoped_ptr<IPC::Message> reply_message_; | 1489 scoped_ptr<IPC::Message> reply_message_; |
| 1655 int new_window_id_; | 1490 int new_window_id_; |
| 1656 int num_loads_; | 1491 int num_loads_; |
| 1657 | 1492 |
| 1658 DISALLOW_COPY_AND_ASSIGN( | 1493 DISALLOW_COPY_AND_ASSIGN( |
| 1659 BrowserOpenedWithExistingProfileNotificationObserver); | 1494 BrowserOpenedWithExistingProfileNotificationObserver); |
| 1660 }; | 1495 }; |
| 1661 | 1496 |
| 1662 #endif // CHROME_BROWSER_AUTOMATION_AUTOMATION_PROVIDER_OBSERVERS_H_ | 1497 #endif // CHROME_BROWSER_AUTOMATION_AUTOMATION_PROVIDER_OBSERVERS_H_ |
| OLD | NEW |