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 #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 47 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... | |
58 #include "chrome/browser/ui/browser.h" | 58 #include "chrome/browser/ui/browser.h" |
59 #include "chrome/browser/ui/browser_list.h" | 59 #include "chrome/browser/ui/browser_list.h" |
60 #include "chrome/browser/ui/browser_window.h" | 60 #include "chrome/browser/ui/browser_window.h" |
61 #include "chrome/browser/ui/find_bar/find_notification_details.h" | 61 #include "chrome/browser/ui/find_bar/find_notification_details.h" |
62 #include "chrome/browser/ui/login/login_prompt.h" | 62 #include "chrome/browser/ui/login/login_prompt.h" |
63 #include "chrome/browser/ui/tab_contents/tab_contents_wrapper.h" | 63 #include "chrome/browser/ui/tab_contents/tab_contents_wrapper.h" |
64 #include "chrome/browser/ui/webui/ntp/app_launcher_handler.h" | 64 #include "chrome/browser/ui/webui/ntp/app_launcher_handler.h" |
65 #include "chrome/browser/ui/webui/ntp/most_visited_handler.h" | 65 #include "chrome/browser/ui/webui/ntp/most_visited_handler.h" |
66 #include "chrome/browser/ui/webui/ntp/new_tab_ui.h" | 66 #include "chrome/browser/ui/webui/ntp/new_tab_ui.h" |
67 #include "chrome/browser/ui/webui/ntp/recently_closed_tabs_handler.h" | 67 #include "chrome/browser/ui/webui/ntp/recently_closed_tabs_handler.h" |
68 #include "chrome/common/automation_constants.h" | |
68 #include "chrome/common/automation_messages.h" | 69 #include "chrome/common/automation_messages.h" |
69 #include "chrome/common/chrome_notification_types.h" | 70 #include "chrome/common/chrome_notification_types.h" |
70 #include "chrome/common/chrome_view_type.h" | 71 #include "chrome/common/chrome_view_type.h" |
71 #include "chrome/common/content_settings_types.h" | 72 #include "chrome/common/content_settings_types.h" |
72 #include "chrome/common/extensions/extension.h" | 73 #include "chrome/common/extensions/extension.h" |
73 #include "content/public/browser/dom_operation_notification_details.h" | 74 #include "content/public/browser/dom_operation_notification_details.h" |
74 #include "content/public/browser/navigation_controller.h" | 75 #include "content/public/browser/navigation_controller.h" |
75 #include "content/public/browser/notification_service.h" | 76 #include "content/public/browser/notification_service.h" |
76 #include "content/public/browser/render_process_host.h" | 77 #include "content/public/browser/render_process_host.h" |
77 #include "content/public/browser/render_view_host.h" | 78 #include "content/public/browser/render_view_host.h" |
(...skipping 1798 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... | |
1876 AutomationJSONReply(automation_, reply_message_.release()) | 1877 AutomationJSONReply(automation_, reply_message_.release()) |
1877 .SendSuccess(NULL); | 1878 .SendSuccess(NULL); |
1878 } else { | 1879 } else { |
1879 AutomationJSONReply(automation_, reply_message_.release()) | 1880 AutomationJSONReply(automation_, reply_message_.release()) |
1880 .SendError("Failed to take snapshot of page: " + error_msg); | 1881 .SendError("Failed to take snapshot of page: " + error_msg); |
1881 } | 1882 } |
1882 } | 1883 } |
1883 delete this; | 1884 delete this; |
1884 } | 1885 } |
1885 | 1886 |
1887 AutomationMouseEventProcessor::AutomationMouseEventProcessor( | |
1888 RenderViewHost* render_view_host, | |
1889 const AutomationMouseEvent& event, | |
1890 const CompletionCallback& completion_callback, | |
1891 const ErrorCallback& error_callback) | |
1892 : RenderViewHostObserver(render_view_host), | |
1893 completion_callback_(completion_callback), | |
1894 error_callback_(error_callback), | |
1895 has_point_(false) { | |
1896 registrar_.Add(this, chrome::NOTIFICATION_APP_MODAL_DIALOG_SHOWN, | |
1897 content::NotificationService::AllSources()); | |
1898 Send(new AutomationMsg_ProcessMouseEvent(routing_id(), event)); | |
1899 } | |
1900 | |
1901 AutomationMouseEventProcessor::~AutomationMouseEventProcessor() {} | |
1902 | |
1903 void AutomationMouseEventProcessor::OnWillProcessMouseEventAt( | |
1904 const gfx::Point& point) { | |
1905 has_point_ = true; | |
1906 point_ = point; | |
1907 } | |
1908 | |
1909 void AutomationMouseEventProcessor::OnProcessMouseEventACK( | |
1910 bool success, | |
1911 const std::string& error_msg) { | |
1912 InvokeCallback(automation::Error(error_msg)); | |
1913 } | |
1914 | |
1915 void AutomationMouseEventProcessor::RenderViewHostDestroyed( | |
1916 RenderViewHost* host) { | |
1917 InvokeCallback(automation::Error("The render view host was destroyed")); | |
1918 } | |
1919 | |
1920 bool AutomationMouseEventProcessor::OnMessageReceived( | |
1921 const IPC::Message& message) { | |
1922 bool handled = true; | |
1923 bool msg_is_good = true; | |
1924 IPC_BEGIN_MESSAGE_MAP_EX(AutomationMouseEventProcessor, message, msg_is_good) | |
1925 IPC_MESSAGE_HANDLER(AutomationMsg_WillProcessMouseEventAt, | |
1926 OnWillProcessMouseEventAt) | |
1927 IPC_MESSAGE_HANDLER(AutomationMsg_ProcessMouseEventACK, | |
1928 OnProcessMouseEventACK) | |
1929 IPC_MESSAGE_UNHANDLED(handled = false) | |
1930 IPC_END_MESSAGE_MAP_EX() | |
1931 if (!msg_is_good) { | |
1932 LOG(ERROR) << "Failed to deserialize an IPC message"; | |
1933 } | |
dennis_jeffrey
2012/05/09 19:05:36
no need for curly braces
kkania
2012/05/09 19:11:50
You're supposed to be curly braces around macros,
dennis_jeffrey
2012/05/09 19:12:50
Ah, good point. Thanks for letting me know!
| |
1934 return handled; | |
1935 } | |
1936 | |
1937 void AutomationMouseEventProcessor::Observe( | |
1938 int type, | |
1939 const content::NotificationSource& source, | |
1940 const content::NotificationDetails& details) { | |
1941 InvokeCallback(automation::Error(automation::kBlockedByModalDialog)); | |
1942 } | |
1943 | |
1944 void AutomationMouseEventProcessor::InvokeCallback( | |
1945 const automation::Error& error) { | |
1946 if (has_point_) { | |
1947 completion_callback_.Run(point_); | |
1948 } else { | |
1949 error_callback_.Run(error); | |
1950 } | |
dennis_jeffrey
2012/05/09 19:05:36
no need for curly braces in the if/else
kkania
2012/05/09 19:11:50
Done.
| |
1951 delete this; | |
1952 } | |
1953 | |
1886 namespace { | 1954 namespace { |
1887 | 1955 |
1888 // Returns a vector of dictionaries containing information about installed apps, | 1956 // Returns a vector of dictionaries containing information about installed apps, |
1889 // as identified from a given list of extensions. The caller takes ownership | 1957 // as identified from a given list of extensions. The caller takes ownership |
1890 // of the created vector. | 1958 // of the created vector. |
1891 std::vector<DictionaryValue*>* GetAppInfoFromExtensions( | 1959 std::vector<DictionaryValue*>* GetAppInfoFromExtensions( |
1892 const ExtensionSet* extensions, | 1960 const ExtensionSet* extensions, |
1893 ExtensionService* ext_service) { | 1961 ExtensionService* ext_service) { |
1894 std::vector<DictionaryValue*>* apps_list = | 1962 std::vector<DictionaryValue*>* apps_list = |
1895 new std::vector<DictionaryValue*>(); | 1963 new std::vector<DictionaryValue*>(); |
(...skipping 1074 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... | |
2970 } | 3038 } |
2971 | 3039 |
2972 ExtensionHost* host = content::Details<ExtensionHost>(details).ptr(); | 3040 ExtensionHost* host = content::Details<ExtensionHost>(details).ptr(); |
2973 if (host->extension_id() == extension_id_ && | 3041 if (host->extension_id() == extension_id_ && |
2974 host->extension_host_type() == chrome::VIEW_TYPE_EXTENSION_POPUP) { | 3042 host->extension_host_type() == chrome::VIEW_TYPE_EXTENSION_POPUP) { |
2975 AutomationJSONReply(automation_, reply_message_.release()) | 3043 AutomationJSONReply(automation_, reply_message_.release()) |
2976 .SendSuccess(NULL); | 3044 .SendSuccess(NULL); |
2977 delete this; | 3045 delete this; |
2978 } | 3046 } |
2979 } | 3047 } |
OLD | NEW |