| OLD | NEW |
| 1 // Copyright (c) 2011 The Chromium Authors. All rights reserved. | 1 // Copyright (c) 2011 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/testing_automation_provider.h" | 5 #include "chrome/browser/automation/testing_automation_provider.h" |
| 6 | 6 |
| 7 #include <map> |
| 8 #include <string> |
| 9 #include <vector> |
| 10 |
| 7 #include "base/command_line.h" | 11 #include "base/command_line.h" |
| 8 #include "base/json/json_reader.h" | 12 #include "base/json/json_reader.h" |
| 9 #include "base/json/json_writer.h" | 13 #include "base/json/json_writer.h" |
| 10 #include "base/json/string_escape.h" | 14 #include "base/json/string_escape.h" |
| 11 #include "base/path_service.h" | 15 #include "base/path_service.h" |
| 12 #include "base/process.h" | 16 #include "base/process.h" |
| 13 #include "base/process_util.h" | 17 #include "base/process_util.h" |
| 14 #include "base/stringprintf.h" | 18 #include "base/stringprintf.h" |
| 15 #include "base/threading/thread_restrictions.h" | 19 #include "base/threading/thread_restrictions.h" |
| 16 #include "base/time.h" | 20 #include "base/time.h" |
| (...skipping 2566 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 2583 it++) { | 2587 it++) { |
| 2584 DownloadItem* curr_item = *it; | 2588 DownloadItem* curr_item = *it; |
| 2585 if (curr_item->id() == id) { | 2589 if (curr_item->id() == id) { |
| 2586 selected_item = curr_item; | 2590 selected_item = curr_item; |
| 2587 break; | 2591 break; |
| 2588 } | 2592 } |
| 2589 } | 2593 } |
| 2590 return selected_item; | 2594 return selected_item; |
| 2591 } | 2595 } |
| 2592 | 2596 |
| 2593 } // namespace | 2597 } // namespace |
| 2594 | 2598 |
| 2595 // See PerformActionOnDownload() in chrome/test/pyautolib/pyauto.py for sample | 2599 // See PerformActionOnDownload() in chrome/test/pyautolib/pyauto.py for sample |
| 2596 // json input and output. | 2600 // json input and output. |
| 2597 void TestingAutomationProvider::PerformActionOnDownload( | 2601 void TestingAutomationProvider::PerformActionOnDownload( |
| 2598 Browser* browser, | 2602 Browser* browser, |
| 2599 DictionaryValue* args, | 2603 DictionaryValue* args, |
| 2600 IPC::Message* reply_message) { | 2604 IPC::Message* reply_message) { |
| 2601 int id; | 2605 int id; |
| 2602 std::string action; | 2606 std::string action; |
| 2603 | 2607 |
| (...skipping 368 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 2972 ListValue* items = new ListValue; | 2976 ListValue* items = new ListValue; |
| 2973 for (std::vector<webkit::npapi::WebPluginInfo>::const_iterator it = | 2977 for (std::vector<webkit::npapi::WebPluginInfo>::const_iterator it = |
| 2974 plugins.begin(); | 2978 plugins.begin(); |
| 2975 it != plugins.end(); | 2979 it != plugins.end(); |
| 2976 ++it) { | 2980 ++it) { |
| 2977 DictionaryValue* item = new DictionaryValue; | 2981 DictionaryValue* item = new DictionaryValue; |
| 2978 item->SetString("name", it->name); | 2982 item->SetString("name", it->name); |
| 2979 item->SetString("path", it->path.value()); | 2983 item->SetString("path", it->path.value()); |
| 2980 item->SetString("version", it->version); | 2984 item->SetString("version", it->version); |
| 2981 item->SetString("desc", it->desc); | 2985 item->SetString("desc", it->desc); |
| 2982 item->SetBoolean("enabled", it->enabled); | 2986 item->SetBoolean("enabled", webkit::npapi::IsPluginEnabled(*it)); |
| 2983 // Add info about mime types. | 2987 // Add info about mime types. |
| 2984 ListValue* mime_types = new ListValue(); | 2988 ListValue* mime_types = new ListValue(); |
| 2985 for (std::vector<webkit::npapi::WebPluginMimeType>::const_iterator type_it = | 2989 for (std::vector<webkit::npapi::WebPluginMimeType>::const_iterator type_it = |
| 2986 it->mime_types.begin(); | 2990 it->mime_types.begin(); |
| 2987 type_it != it->mime_types.end(); | 2991 type_it != it->mime_types.end(); |
| 2988 ++type_it) { | 2992 ++type_it) { |
| 2989 DictionaryValue* mime_type = new DictionaryValue(); | 2993 DictionaryValue* mime_type = new DictionaryValue(); |
| 2990 mime_type->SetString("mimeType", type_it->mime_type); | 2994 mime_type->SetString("mimeType", type_it->mime_type); |
| 2991 mime_type->SetString("description", type_it->description); | 2995 mime_type->SetString("description", type_it->description); |
| 2992 | 2996 |
| (...skipping 197 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 3190 password_form.username_element = username_element; | 3194 password_form.username_element = username_element; |
| 3191 password_form.password_element = password_element; | 3195 password_form.password_element = password_element; |
| 3192 password_form.submit_element = submit_element; | 3196 password_form.submit_element = submit_element; |
| 3193 password_form.action = action_target; | 3197 password_form.action = action_target; |
| 3194 password_form.blacklisted_by_user = blacklist; | 3198 password_form.blacklisted_by_user = blacklist; |
| 3195 password_form.date_created = time; | 3199 password_form.date_created = time; |
| 3196 | 3200 |
| 3197 return password_form; | 3201 return password_form; |
| 3198 } | 3202 } |
| 3199 | 3203 |
| 3200 } // namespace | 3204 } // namespace |
| 3201 | 3205 |
| 3202 // See AddSavedPassword() in chrome/test/functional/pyauto.py for sample json | 3206 // See AddSavedPassword() in chrome/test/functional/pyauto.py for sample json |
| 3203 // input. | 3207 // input. |
| 3204 // Sample json output: { "password_added": true } | 3208 // Sample json output: { "password_added": true } |
| 3205 void TestingAutomationProvider::AddSavedPassword( | 3209 void TestingAutomationProvider::AddSavedPassword( |
| 3206 Browser* browser, | 3210 Browser* browser, |
| 3207 DictionaryValue* args, | 3211 DictionaryValue* args, |
| 3208 IPC::Message* reply_message) { | 3212 IPC::Message* reply_message) { |
| 3209 AutomationJSONReply reply(this, reply_message); | 3213 AutomationJSONReply reply(this, reply_message); |
| 3210 DictionaryValue* password_dict = NULL; | 3214 DictionaryValue* password_dict = NULL; |
| (...skipping 1299 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 4510 // If you change this, update Observer for NotificationType::SESSION_END | 4514 // If you change this, update Observer for NotificationType::SESSION_END |
| 4511 // below. | 4515 // below. |
| 4512 MessageLoop::current()->PostTask(FROM_HERE, | 4516 MessageLoop::current()->PostTask(FROM_HERE, |
| 4513 NewRunnableMethod(this, &TestingAutomationProvider::OnRemoveProvider)); | 4517 NewRunnableMethod(this, &TestingAutomationProvider::OnRemoveProvider)); |
| 4514 } | 4518 } |
| 4515 } | 4519 } |
| 4516 | 4520 |
| 4517 void TestingAutomationProvider::OnRemoveProvider() { | 4521 void TestingAutomationProvider::OnRemoveProvider() { |
| 4518 AutomationProviderList::GetInstance()->RemoveProvider(this); | 4522 AutomationProviderList::GetInstance()->RemoveProvider(this); |
| 4519 } | 4523 } |
| OLD | NEW |