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

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: . 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/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
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 MouseEventProcessedObserver::MouseEventProcessedObserver(
1888 AutomationProvider* automation,
1889 IPC::Message* reply_message,
1890 TabContentsWrapper* tab_contents)
1891 : automation_(automation->AsWeakPtr()),
1892 reply_message_(reply_message),
1893 has_point_(false) {
1894 registrar_.Add(this, chrome::NOTIFICATION_APP_MODAL_DIALOG_SHOWN,
1895 content::NotificationService::AllSources());
1896 StartObserving(tab_contents->automation_tab_helper());
1897 }
1898
1899 MouseEventProcessedObserver::~MouseEventProcessedObserver() {}
1900
1901 void MouseEventProcessedObserver::OnWillProcessMouseEventAt(
1902 const gfx::Point& point) {
1903 has_point_ = true;
1904 point_ = point;
1905 }
1906
1907 void MouseEventProcessedObserver::OnProcessMouseEventACK(
1908 bool success,
1909 const std::string& error_msg) {
1910 if (success && !has_point_) {
1911 SendMessage(false,
1912 automation::Error("Received mouse event ACK without a point"));
1913 } else {
1914 SendMessage(success, automation::Error(error_msg));
1915 }
1916 }
1917
1918 void MouseEventProcessedObserver::Observe(
1919 int type,
1920 const content::NotificationSource& source,
1921 const content::NotificationDetails& details) {
1922 if (has_point_)
1923 SendMessage(true, automation::Error());
dennis_jeffrey 2012/05/08 19:18:49 To make sure I understand correctly: if OnWillProc
kkania 2012/05/09 18:19:59 Yes
1924 else
1925 SendMessage(false, automation::Error(automation::kBlockedByModalDialog));
1926 }
1927
1928 void MouseEventProcessedObserver::SendMessage(
1929 bool success,
1930 const automation::Error& error) {
1931 if (automation_) {
1932 if (success) {
1933 DictionaryValue dict;
1934 dict.SetInteger("x", point_.x());
1935 dict.SetInteger("y", point_.y());
1936 AutomationJSONReply(automation_, reply_message_.release())
1937 .SendSuccess(&dict);
1938 } else {
1939 AutomationJSONReply(automation_, reply_message_.release())
1940 .SendError(error);
1941 }
1942 }
1943 delete this;
1944 }
1945
1886 namespace { 1946 namespace {
1887 1947
1888 // Returns a vector of dictionaries containing information about installed apps, 1948 // Returns a vector of dictionaries containing information about installed apps,
1889 // as identified from a given list of extensions. The caller takes ownership 1949 // as identified from a given list of extensions. The caller takes ownership
1890 // of the created vector. 1950 // of the created vector.
1891 std::vector<DictionaryValue*>* GetAppInfoFromExtensions( 1951 std::vector<DictionaryValue*>* GetAppInfoFromExtensions(
1892 const ExtensionSet* extensions, 1952 const ExtensionSet* extensions,
1893 ExtensionService* ext_service) { 1953 ExtensionService* ext_service) {
1894 std::vector<DictionaryValue*>* apps_list = 1954 std::vector<DictionaryValue*>* apps_list =
1895 new std::vector<DictionaryValue*>(); 1955 new std::vector<DictionaryValue*>();
(...skipping 1074 matching lines...) Expand 10 before | Expand all | Expand 10 after
2970 } 3030 }
2971 3031
2972 ExtensionHost* host = content::Details<ExtensionHost>(details).ptr(); 3032 ExtensionHost* host = content::Details<ExtensionHost>(details).ptr();
2973 if (host->extension_id() == extension_id_ && 3033 if (host->extension_id() == extension_id_ &&
2974 host->extension_host_type() == chrome::VIEW_TYPE_EXTENSION_POPUP) { 3034 host->extension_host_type() == chrome::VIEW_TYPE_EXTENSION_POPUP) {
2975 AutomationJSONReply(automation_, reply_message_.release()) 3035 AutomationJSONReply(automation_, reply_message_.release())
2976 .SendSuccess(NULL); 3036 .SendSuccess(NULL);
2977 delete this; 3037 delete this;
2978 } 3038 }
2979 } 3039 }
OLDNEW

Powered by Google App Engine
This is Rietveld 408576698