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 2568 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
2585 it++) { | 2589 it++) { |
2586 DownloadItem* curr_item = *it; | 2590 DownloadItem* curr_item = *it; |
2587 if (curr_item->id() == id) { | 2591 if (curr_item->id() == id) { |
2588 selected_item = curr_item; | 2592 selected_item = curr_item; |
2589 break; | 2593 break; |
2590 } | 2594 } |
2591 } | 2595 } |
2592 return selected_item; | 2596 return selected_item; |
2593 } | 2597 } |
2594 | 2598 |
2595 } // namespace | 2599 } // namespace |
2596 | 2600 |
2597 // See PerformActionOnDownload() in chrome/test/pyautolib/pyauto.py for sample | 2601 // See PerformActionOnDownload() in chrome/test/pyautolib/pyauto.py for sample |
2598 // json input and output. | 2602 // json input and output. |
2599 void TestingAutomationProvider::PerformActionOnDownload( | 2603 void TestingAutomationProvider::PerformActionOnDownload( |
2600 Browser* browser, | 2604 Browser* browser, |
2601 DictionaryValue* args, | 2605 DictionaryValue* args, |
2602 IPC::Message* reply_message) { | 2606 IPC::Message* reply_message) { |
2603 int id; | 2607 int id; |
2604 std::string action; | 2608 std::string action; |
2605 | 2609 |
(...skipping 368 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
2974 ListValue* items = new ListValue; | 2978 ListValue* items = new ListValue; |
2975 for (std::vector<webkit::npapi::WebPluginInfo>::const_iterator it = | 2979 for (std::vector<webkit::npapi::WebPluginInfo>::const_iterator it = |
2976 plugins.begin(); | 2980 plugins.begin(); |
2977 it != plugins.end(); | 2981 it != plugins.end(); |
2978 ++it) { | 2982 ++it) { |
2979 DictionaryValue* item = new DictionaryValue; | 2983 DictionaryValue* item = new DictionaryValue; |
2980 item->SetString("name", it->name); | 2984 item->SetString("name", it->name); |
2981 item->SetString("path", it->path.value()); | 2985 item->SetString("path", it->path.value()); |
2982 item->SetString("version", it->version); | 2986 item->SetString("version", it->version); |
2983 item->SetString("desc", it->desc); | 2987 item->SetString("desc", it->desc); |
2984 item->SetBoolean("enabled", it->enabled); | 2988 item->SetBoolean("enabled", webkit::npapi::IsPluginEnabled(*it)); |
2985 // Add info about mime types. | 2989 // Add info about mime types. |
2986 ListValue* mime_types = new ListValue(); | 2990 ListValue* mime_types = new ListValue(); |
2987 for (std::vector<webkit::npapi::WebPluginMimeType>::const_iterator type_it = | 2991 for (std::vector<webkit::npapi::WebPluginMimeType>::const_iterator type_it = |
2988 it->mime_types.begin(); | 2992 it->mime_types.begin(); |
2989 type_it != it->mime_types.end(); | 2993 type_it != it->mime_types.end(); |
2990 ++type_it) { | 2994 ++type_it) { |
2991 DictionaryValue* mime_type = new DictionaryValue(); | 2995 DictionaryValue* mime_type = new DictionaryValue(); |
2992 mime_type->SetString("mimeType", type_it->mime_type); | 2996 mime_type->SetString("mimeType", type_it->mime_type); |
2993 mime_type->SetString("description", type_it->description); | 2997 mime_type->SetString("description", type_it->description); |
2994 | 2998 |
(...skipping 197 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
3192 password_form.username_element = username_element; | 3196 password_form.username_element = username_element; |
3193 password_form.password_element = password_element; | 3197 password_form.password_element = password_element; |
3194 password_form.submit_element = submit_element; | 3198 password_form.submit_element = submit_element; |
3195 password_form.action = action_target; | 3199 password_form.action = action_target; |
3196 password_form.blacklisted_by_user = blacklist; | 3200 password_form.blacklisted_by_user = blacklist; |
3197 password_form.date_created = time; | 3201 password_form.date_created = time; |
3198 | 3202 |
3199 return password_form; | 3203 return password_form; |
3200 } | 3204 } |
3201 | 3205 |
3202 } // namespace | 3206 } // namespace |
3203 | 3207 |
3204 // See AddSavedPassword() in chrome/test/functional/pyauto.py for sample json | 3208 // See AddSavedPassword() in chrome/test/functional/pyauto.py for sample json |
3205 // input. | 3209 // input. |
3206 // Sample json output: { "password_added": true } | 3210 // Sample json output: { "password_added": true } |
3207 void TestingAutomationProvider::AddSavedPassword( | 3211 void TestingAutomationProvider::AddSavedPassword( |
3208 Browser* browser, | 3212 Browser* browser, |
3209 DictionaryValue* args, | 3213 DictionaryValue* args, |
3210 IPC::Message* reply_message) { | 3214 IPC::Message* reply_message) { |
3211 AutomationJSONReply reply(this, reply_message); | 3215 AutomationJSONReply reply(this, reply_message); |
3212 DictionaryValue* password_dict = NULL; | 3216 DictionaryValue* password_dict = NULL; |
(...skipping 1299 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
4512 // If you change this, update Observer for NotificationType::SESSION_END | 4516 // If you change this, update Observer for NotificationType::SESSION_END |
4513 // below. | 4517 // below. |
4514 MessageLoop::current()->PostTask(FROM_HERE, | 4518 MessageLoop::current()->PostTask(FROM_HERE, |
4515 NewRunnableMethod(this, &TestingAutomationProvider::OnRemoveProvider)); | 4519 NewRunnableMethod(this, &TestingAutomationProvider::OnRemoveProvider)); |
4516 } | 4520 } |
4517 } | 4521 } |
4518 | 4522 |
4519 void TestingAutomationProvider::OnRemoveProvider() { | 4523 void TestingAutomationProvider::OnRemoveProvider() { |
4520 AutomationProviderList::GetInstance()->RemoveProvider(this); | 4524 AutomationProviderList::GetInstance()->RemoveProvider(this); |
4521 } | 4525 } |
OLD | NEW |