| OLD | NEW |
| 1 // Copyright (c) 2010 The Chromium Authors. All rights reserved. | 1 // Copyright (c) 2010 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.h" | 5 #include "chrome/browser/automation/automation_provider.h" |
| 6 | 6 |
| 7 #include <set> | 7 #include <set> |
| 8 | 8 |
| 9 #include "app/l10n_util.h" | 9 #include "app/l10n_util.h" |
| 10 #include "app/message_box_flags.h" | 10 #include "app/message_box_flags.h" |
| (...skipping 2059 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 2070 NavigationController& controller = | 2070 NavigationController& controller = |
| 2071 browser->GetSelectedTabContents()->controller(); | 2071 browser->GetSelectedTabContents()->controller(); |
| 2072 // Setup observer to wait until the selected item loads. | 2072 // Setup observer to wait until the selected item loads. |
| 2073 NotificationObserver* observer = | 2073 NotificationObserver* observer = |
| 2074 new OmniboxAcceptNotificationObserver(&controller, this, reply_message); | 2074 new OmniboxAcceptNotificationObserver(&controller, this, reply_message); |
| 2075 notification_observer_list_.AddObserver(observer); | 2075 notification_observer_list_.AddObserver(observer); |
| 2076 | 2076 |
| 2077 browser->window()->GetLocationBar()->AcceptInput(); | 2077 browser->window()->GetLocationBar()->AcceptInput(); |
| 2078 } | 2078 } |
| 2079 | 2079 |
| 2080 // Sample json input: { "command": "GetInitialLoadTimes" } | |
| 2081 // Refer to InitialLoadObserver::GetTimingInformation() for sample output. | |
| 2082 void AutomationProvider::GetInitialLoadTimes( | |
| 2083 Browser*, | |
| 2084 DictionaryValue*, | |
| 2085 IPC::Message* reply_message) { | |
| 2086 scoped_ptr<DictionaryValue> return_value( | |
| 2087 initial_load_observer_->GetTimingInformation()); | |
| 2088 | |
| 2089 std::string json_return; | |
| 2090 base::JSONWriter::Write(return_value.get(), false, &json_return); | |
| 2091 AutomationMsg_SendJSONRequest::WriteReplyParams( | |
| 2092 reply_message, json_return, true); | |
| 2093 Send(reply_message); | |
| 2094 } | |
| 2095 | |
| 2096 // Sample json input: { "command": "GetPluginsInfo" } | 2080 // Sample json input: { "command": "GetPluginsInfo" } |
| 2097 // Refer chrome/test/pyautolib/plugins_info.py for sample json output. | 2081 // Refer chrome/test/pyautolib/plugins_info.py for sample json output. |
| 2098 void AutomationProvider::GetPluginsInfo(Browser* browser, | 2082 void AutomationProvider::GetPluginsInfo(Browser* browser, |
| 2099 DictionaryValue* args, | 2083 DictionaryValue* args, |
| 2100 IPC::Message* reply_message) { | 2084 IPC::Message* reply_message) { |
| 2101 std::string json_return; | 2085 std::string json_return; |
| 2102 bool reply_return = true; | 2086 bool reply_return = true; |
| 2103 | 2087 |
| 2104 std::vector<WebPluginInfo> plugins; | 2088 std::vector<WebPluginInfo> plugins; |
| 2105 NPAPI::PluginList::Singleton()->GetPlugins(false, &plugins); | 2089 NPAPI::PluginList::Singleton()->GetPlugins(false, &plugins); |
| (...skipping 142 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 2248 | 2232 |
| 2249 handler_map["GetPrefsInfo"] = &AutomationProvider::GetPrefsInfo; | 2233 handler_map["GetPrefsInfo"] = &AutomationProvider::GetPrefsInfo; |
| 2250 handler_map["SetPrefs"] = &AutomationProvider::SetPrefs; | 2234 handler_map["SetPrefs"] = &AutomationProvider::SetPrefs; |
| 2251 | 2235 |
| 2252 handler_map["SetWindowDimensions"] = &AutomationProvider::SetWindowDimensions; | 2236 handler_map["SetWindowDimensions"] = &AutomationProvider::SetWindowDimensions; |
| 2253 | 2237 |
| 2254 handler_map["GetDownloadsInfo"] = &AutomationProvider::GetDownloadsInfo; | 2238 handler_map["GetDownloadsInfo"] = &AutomationProvider::GetDownloadsInfo; |
| 2255 handler_map["WaitForAllDownloadsToComplete"] = | 2239 handler_map["WaitForAllDownloadsToComplete"] = |
| 2256 &AutomationProvider::WaitForDownloadsToComplete; | 2240 &AutomationProvider::WaitForDownloadsToComplete; |
| 2257 | 2241 |
| 2258 handler_map["GetInitialLoadTimes"] = &AutomationProvider::GetInitialLoadTimes; | |
| 2259 | |
| 2260 if (error_string.empty()) { | 2242 if (error_string.empty()) { |
| 2261 if (handler_map.find(std::string(command)) != handler_map.end()) { | 2243 if (handler_map.find(std::string(command)) != handler_map.end()) { |
| 2262 (this->*handler_map[command])(browser, dict_value, reply_message); | 2244 (this->*handler_map[command])(browser, dict_value, reply_message); |
| 2263 return; | 2245 return; |
| 2264 } else { | 2246 } else { |
| 2265 error_string = "Unknown command. Options: "; | 2247 error_string = "Unknown command. Options: "; |
| 2266 for (std::map<std::string, JsonHandler>::const_iterator it = | 2248 for (std::map<std::string, JsonHandler>::const_iterator it = |
| 2267 handler_map.begin(); it != handler_map.end(); ++it) { | 2249 handler_map.begin(); it != handler_map.end(); ++it) { |
| 2268 error_string += it->first + ", "; | 2250 error_string += it->first + ", "; |
| 2269 } | 2251 } |
| (...skipping 1175 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 3445 } | 3427 } |
| 3446 | 3428 |
| 3447 void AutomationProvider::WaitForPopupMenuToOpen(IPC::Message* reply_message) { | 3429 void AutomationProvider::WaitForPopupMenuToOpen(IPC::Message* reply_message) { |
| 3448 NOTIMPLEMENTED(); | 3430 NOTIMPLEMENTED(); |
| 3449 } | 3431 } |
| 3450 #endif // !defined(TOOLKIT_VIEWS) | 3432 #endif // !defined(TOOLKIT_VIEWS) |
| 3451 | 3433 |
| 3452 void AutomationProvider::ResetToDefaultTheme() { | 3434 void AutomationProvider::ResetToDefaultTheme() { |
| 3453 profile_->ClearTheme(); | 3435 profile_->ClearTheme(); |
| 3454 } | 3436 } |
| OLD | NEW |