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/testing_automation_provider.h" | 5 #include "chrome/browser/automation/testing_automation_provider.h" |
6 | 6 |
7 #include "app/message_box_flags.h" | 7 #include "app/message_box_flags.h" |
8 #include "base/command_line.h" | 8 #include "base/command_line.h" |
9 #include "base/json/json_reader.h" | 9 #include "base/json/json_reader.h" |
10 #include "base/json/json_writer.h" | 10 #include "base/json/json_writer.h" |
(...skipping 57 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
68 #include "chrome/common/chrome_constants.h" | 68 #include "chrome/common/chrome_constants.h" |
69 #include "chrome/common/chrome_paths.h" | 69 #include "chrome/common/chrome_paths.h" |
70 #include "chrome/common/chrome_switches.h" | 70 #include "chrome/common/chrome_switches.h" |
71 #include "chrome/common/net/url_request_context_getter.h" | 71 #include "chrome/common/net/url_request_context_getter.h" |
72 #include "chrome/common/notification_service.h" | 72 #include "chrome/common/notification_service.h" |
73 #include "chrome/common/url_constants.h" | 73 #include "chrome/common/url_constants.h" |
74 #include "chrome/common/automation_messages.h" | 74 #include "chrome/common/automation_messages.h" |
75 #include "net/base/cookie_store.h" | 75 #include "net/base/cookie_store.h" |
76 #include "net/url_request/url_request_context.h" | 76 #include "net/url_request/url_request_context.h" |
77 #include "views/event.h" | 77 #include "views/event.h" |
78 #include "webkit/plugins/npapi/plugin_list.h" | 78 #include "webkit/glue/plugins/plugin_list.h" |
79 | 79 |
80 namespace { | 80 namespace { |
81 | 81 |
82 void GetCookiesOnIOThread( | 82 void GetCookiesOnIOThread( |
83 const GURL& url, | 83 const GURL& url, |
84 const scoped_refptr<URLRequestContextGetter>& context_getter, | 84 const scoped_refptr<URLRequestContextGetter>& context_getter, |
85 base::WaitableEvent* event, | 85 base::WaitableEvent* event, |
86 std::string* cookies) { | 86 std::string* cookies) { |
87 *cookies = context_getter->GetCookieStore()->GetCookies(url); | 87 *cookies = context_getter->GetCookieStore()->GetCookies(url); |
88 event->Signal(); | 88 event->Signal(); |
(...skipping 2897 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
2986 reply_message, json_return, true); | 2986 reply_message, json_return, true); |
2987 Send(reply_message); | 2987 Send(reply_message); |
2988 } | 2988 } |
2989 | 2989 |
2990 // Sample json input: { "command": "GetPluginsInfo" } | 2990 // Sample json input: { "command": "GetPluginsInfo" } |
2991 // Refer chrome/test/pyautolib/plugins_info.py for sample json output. | 2991 // Refer chrome/test/pyautolib/plugins_info.py for sample json output. |
2992 void TestingAutomationProvider::GetPluginsInfo( | 2992 void TestingAutomationProvider::GetPluginsInfo( |
2993 Browser* browser, | 2993 Browser* browser, |
2994 DictionaryValue* args, | 2994 DictionaryValue* args, |
2995 IPC::Message* reply_message) { | 2995 IPC::Message* reply_message) { |
2996 std::vector<webkit::npapi::WebPluginInfo> plugins; | 2996 std::vector<WebPluginInfo> plugins; |
2997 webkit::npapi::PluginList::Singleton()->GetPlugins(false, &plugins); | 2997 NPAPI::PluginList::Singleton()->GetPlugins(false, &plugins); |
2998 ListValue* items = new ListValue; | 2998 ListValue* items = new ListValue; |
2999 for (std::vector<webkit::npapi::WebPluginInfo>::const_iterator it = | 2999 for (std::vector<WebPluginInfo>::const_iterator it = plugins.begin(); |
3000 plugins.begin(); | |
3001 it != plugins.end(); | 3000 it != plugins.end(); |
3002 ++it) { | 3001 ++it) { |
3003 DictionaryValue* item = new DictionaryValue; | 3002 DictionaryValue* item = new DictionaryValue; |
3004 item->SetString("name", it->name); | 3003 item->SetString("name", it->name); |
3005 item->SetString("path", it->path.value()); | 3004 item->SetString("path", it->path.value()); |
3006 item->SetString("version", it->version); | 3005 item->SetString("version", it->version); |
3007 item->SetString("desc", it->desc); | 3006 item->SetString("desc", it->desc); |
3008 item->SetBoolean("enabled", it->enabled); | 3007 item->SetBoolean("enabled", it->enabled); |
3009 // Add info about mime types. | 3008 // Add info about mime types. |
3010 ListValue* mime_types = new ListValue(); | 3009 ListValue* mime_types = new ListValue(); |
3011 for (std::vector<webkit::npapi::WebPluginMimeType>::const_iterator type_it = | 3010 for (std::vector<WebPluginMimeType>::const_iterator type_it = |
3012 it->mime_types.begin(); | 3011 it->mime_types.begin(); |
3013 type_it != it->mime_types.end(); | 3012 type_it != it->mime_types.end(); |
3014 ++type_it) { | 3013 ++type_it) { |
3015 DictionaryValue* mime_type = new DictionaryValue(); | 3014 DictionaryValue* mime_type = new DictionaryValue(); |
3016 mime_type->SetString("mimeType", type_it->mime_type); | 3015 mime_type->SetString("mimeType", type_it->mime_type); |
3017 mime_type->SetString("description", type_it->description); | 3016 mime_type->SetString("description", type_it->description); |
3018 | 3017 |
3019 ListValue* file_extensions = new ListValue(); | 3018 ListValue* file_extensions = new ListValue(); |
3020 for (std::vector<std::string>::const_iterator ext_it = | 3019 for (std::vector<std::string>::const_iterator ext_it = |
3021 type_it->file_extensions.begin(); | 3020 type_it->file_extensions.begin(); |
(...skipping 18 matching lines...) Expand all Loading... |
3040 // { "command": "EnablePlugin", | 3039 // { "command": "EnablePlugin", |
3041 // "path": "/Library/Internet Plug-Ins/Flash Player.plugin" } | 3040 // "path": "/Library/Internet Plug-Ins/Flash Player.plugin" } |
3042 void TestingAutomationProvider::EnablePlugin(Browser* browser, | 3041 void TestingAutomationProvider::EnablePlugin(Browser* browser, |
3043 DictionaryValue* args, | 3042 DictionaryValue* args, |
3044 IPC::Message* reply_message) { | 3043 IPC::Message* reply_message) { |
3045 FilePath::StringType path; | 3044 FilePath::StringType path; |
3046 AutomationJSONReply reply(this, reply_message); | 3045 AutomationJSONReply reply(this, reply_message); |
3047 if (!args->GetString("path", &path)) { | 3046 if (!args->GetString("path", &path)) { |
3048 reply.SendError("path not specified."); | 3047 reply.SendError("path not specified."); |
3049 return; | 3048 return; |
3050 } else if (!webkit::npapi::PluginList::Singleton()->EnablePlugin( | 3049 } else if (!NPAPI::PluginList::Singleton()->EnablePlugin(FilePath(path))) { |
3051 FilePath(path))) { | |
3052 reply.SendError(StringPrintf("Could not enable plugin for path %s.", | 3050 reply.SendError(StringPrintf("Could not enable plugin for path %s.", |
3053 path.c_str())); | 3051 path.c_str())); |
3054 return; | 3052 return; |
3055 } | 3053 } |
3056 reply.SendSuccess(NULL); | 3054 reply.SendSuccess(NULL); |
3057 } | 3055 } |
3058 | 3056 |
3059 // Sample json input: | 3057 // Sample json input: |
3060 // { "command": "DisablePlugin", | 3058 // { "command": "DisablePlugin", |
3061 // "path": "/Library/Internet Plug-Ins/Flash Player.plugin" } | 3059 // "path": "/Library/Internet Plug-Ins/Flash Player.plugin" } |
3062 void TestingAutomationProvider::DisablePlugin(Browser* browser, | 3060 void TestingAutomationProvider::DisablePlugin(Browser* browser, |
3063 DictionaryValue* args, | 3061 DictionaryValue* args, |
3064 IPC::Message* reply_message) { | 3062 IPC::Message* reply_message) { |
3065 FilePath::StringType path; | 3063 FilePath::StringType path; |
3066 AutomationJSONReply reply(this, reply_message); | 3064 AutomationJSONReply reply(this, reply_message); |
3067 if (!args->GetString("path", &path)) { | 3065 if (!args->GetString("path", &path)) { |
3068 reply.SendError("path not specified."); | 3066 reply.SendError("path not specified."); |
3069 return; | 3067 return; |
3070 } else if (!webkit::npapi::PluginList::Singleton()->DisablePlugin( | 3068 } else if (!NPAPI::PluginList::Singleton()->DisablePlugin(FilePath(path))) { |
3071 FilePath(path))) { | |
3072 reply.SendError(StringPrintf("Could not disable plugin for path %s.", | 3069 reply.SendError(StringPrintf("Could not disable plugin for path %s.", |
3073 path.c_str())); | 3070 path.c_str())); |
3074 return; | 3071 return; |
3075 } | 3072 } |
3076 reply.SendSuccess(NULL); | 3073 reply.SendSuccess(NULL); |
3077 } | 3074 } |
3078 | 3075 |
3079 // Sample json input: | 3076 // Sample json input: |
3080 // { "command": "SaveTabContents", | 3077 // { "command": "SaveTabContents", |
3081 // "tab_index": 0, | 3078 // "tab_index": 0, |
(...skipping 1441 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
4523 // If you change this, update Observer for NotificationType::SESSION_END | 4520 // If you change this, update Observer for NotificationType::SESSION_END |
4524 // below. | 4521 // below. |
4525 MessageLoop::current()->PostTask(FROM_HERE, | 4522 MessageLoop::current()->PostTask(FROM_HERE, |
4526 NewRunnableMethod(this, &TestingAutomationProvider::OnRemoveProvider)); | 4523 NewRunnableMethod(this, &TestingAutomationProvider::OnRemoveProvider)); |
4527 } | 4524 } |
4528 } | 4525 } |
4529 | 4526 |
4530 void TestingAutomationProvider::OnRemoveProvider() { | 4527 void TestingAutomationProvider::OnRemoveProvider() { |
4531 AutomationProviderList::GetInstance()->RemoveProvider(this); | 4528 AutomationProviderList::GetInstance()->RemoveProvider(this); |
4532 } | 4529 } |
OLD | NEW |