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

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

Issue 10384023: Determine the element location and click synchronously on the renderer. (Closed) Base URL: svn://svn.chromium.org/chrome/trunk/src
Patch Set: rebase Created 8 years, 7 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) 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
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/content_settings_types.h" 71 #include "chrome/common/content_settings_types.h"
71 #include "chrome/common/extensions/extension.h" 72 #include "chrome/common/extensions/extension.h"
72 #include "chrome/common/view_type.h" 73 #include "chrome/common/view_type.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 1777 matching lines...) Expand 10 before | Expand all | Expand 10 after
1855 AutomationJSONReply(automation_, reply_message_.release()) 1856 AutomationJSONReply(automation_, reply_message_.release())
1856 .SendSuccess(NULL); 1857 .SendSuccess(NULL);
1857 } else { 1858 } else {
1858 AutomationJSONReply(automation_, reply_message_.release()) 1859 AutomationJSONReply(automation_, reply_message_.release())
1859 .SendError("Failed to take snapshot of page: " + error_msg); 1860 .SendError("Failed to take snapshot of page: " + error_msg);
1860 } 1861 }
1861 } 1862 }
1862 delete this; 1863 delete this;
1863 } 1864 }
1864 1865
1866 AutomationMouseEventProcessor::AutomationMouseEventProcessor(
1867 RenderViewHost* render_view_host,
1868 const AutomationMouseEvent& event,
1869 const CompletionCallback& completion_callback,
1870 const ErrorCallback& error_callback)
1871 : RenderViewHostObserver(render_view_host),
1872 completion_callback_(completion_callback),
1873 error_callback_(error_callback),
1874 has_point_(false) {
1875 registrar_.Add(this, chrome::NOTIFICATION_APP_MODAL_DIALOG_SHOWN,
1876 content::NotificationService::AllSources());
1877 Send(new AutomationMsg_ProcessMouseEvent(routing_id(), event));
1878 }
1879
1880 AutomationMouseEventProcessor::~AutomationMouseEventProcessor() {}
1881
1882 void AutomationMouseEventProcessor::OnWillProcessMouseEventAt(
1883 const gfx::Point& point) {
1884 has_point_ = true;
1885 point_ = point;
1886 }
1887
1888 void AutomationMouseEventProcessor::OnProcessMouseEventACK(
1889 bool success,
1890 const std::string& error_msg) {
1891 InvokeCallback(automation::Error(error_msg));
1892 }
1893
1894 void AutomationMouseEventProcessor::RenderViewHostDestroyed(
1895 RenderViewHost* host) {
1896 InvokeCallback(automation::Error("The render view host was destroyed"));
1897 }
1898
1899 bool AutomationMouseEventProcessor::OnMessageReceived(
1900 const IPC::Message& message) {
1901 bool handled = true;
1902 bool msg_is_good = true;
1903 IPC_BEGIN_MESSAGE_MAP_EX(AutomationMouseEventProcessor, message, msg_is_good)
1904 IPC_MESSAGE_HANDLER(AutomationMsg_WillProcessMouseEventAt,
1905 OnWillProcessMouseEventAt)
1906 IPC_MESSAGE_HANDLER(AutomationMsg_ProcessMouseEventACK,
1907 OnProcessMouseEventACK)
1908 IPC_MESSAGE_UNHANDLED(handled = false)
1909 IPC_END_MESSAGE_MAP_EX()
1910 if (!msg_is_good) {
1911 LOG(ERROR) << "Failed to deserialize an IPC message";
1912 }
1913 return handled;
1914 }
1915
1916 void AutomationMouseEventProcessor::Observe(
1917 int type,
1918 const content::NotificationSource& source,
1919 const content::NotificationDetails& details) {
1920 InvokeCallback(automation::Error(automation::kBlockedByModalDialog));
1921 }
1922
1923 void AutomationMouseEventProcessor::InvokeCallback(
1924 const automation::Error& error) {
1925 if (has_point_)
1926 completion_callback_.Run(point_);
1927 else
1928 error_callback_.Run(error);
1929 delete this;
1930 }
1931
1865 namespace { 1932 namespace {
1866 1933
1867 // Returns a vector of dictionaries containing information about installed apps, 1934 // Returns a vector of dictionaries containing information about installed apps,
1868 // as identified from a given list of extensions. The caller takes ownership 1935 // as identified from a given list of extensions. The caller takes ownership
1869 // of the created vector. 1936 // of the created vector.
1870 std::vector<DictionaryValue*>* GetAppInfoFromExtensions( 1937 std::vector<DictionaryValue*>* GetAppInfoFromExtensions(
1871 const ExtensionSet* extensions, 1938 const ExtensionSet* extensions,
1872 ExtensionService* ext_service) { 1939 ExtensionService* ext_service) {
1873 std::vector<DictionaryValue*>* apps_list = 1940 std::vector<DictionaryValue*>* apps_list =
1874 new std::vector<DictionaryValue*>(); 1941 new std::vector<DictionaryValue*>();
(...skipping 1075 matching lines...) Expand 10 before | Expand all | Expand 10 after
2950 } 3017 }
2951 3018
2952 ExtensionHost* host = content::Details<ExtensionHost>(details).ptr(); 3019 ExtensionHost* host = content::Details<ExtensionHost>(details).ptr();
2953 if (host->extension_id() == extension_id_ && 3020 if (host->extension_id() == extension_id_ &&
2954 host->extension_host_type() == chrome::VIEW_TYPE_EXTENSION_POPUP) { 3021 host->extension_host_type() == chrome::VIEW_TYPE_EXTENSION_POPUP) {
2955 AutomationJSONReply(automation_, reply_message_.release()) 3022 AutomationJSONReply(automation_, reply_message_.release())
2956 .SendSuccess(NULL); 3023 .SendSuccess(NULL);
2957 delete this; 3024 delete this;
2958 } 3025 }
2959 } 3026 }
OLDNEW
« no previous file with comments | « chrome/browser/automation/automation_provider_observers.h ('k') | chrome/browser/automation/testing_automation_provider.cc » ('j') | no next file with comments »

Powered by Google App Engine
This is Rietveld 408576698