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

Side by Side Diff: chrome/browser/automation/testing_automation_provider.cc

Issue 5699005: Policy: Re-enabled plugin still disabled (Closed) Base URL: svn://svn.chromium.org/chrome/trunk/src
Patch Set: Added empty group prunning. Created 9 years, 11 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) 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 <map>
8 #include <string>
9 #include <vector>
10
7 #include "app/message_box_flags.h" 11 #include "app/message_box_flags.h"
8 #include "base/command_line.h" 12 #include "base/command_line.h"
9 #include "base/json/json_reader.h" 13 #include "base/json/json_reader.h"
10 #include "base/json/json_writer.h" 14 #include "base/json/json_writer.h"
11 #include "base/json/string_escape.h" 15 #include "base/json/string_escape.h"
12 #include "base/path_service.h" 16 #include "base/path_service.h"
13 #include "base/process.h" 17 #include "base/process.h"
14 #include "base/process_util.h" 18 #include "base/process_util.h"
15 #include "base/stringprintf.h" 19 #include "base/stringprintf.h"
16 #include "base/threading/thread_restrictions.h" 20 #include "base/threading/thread_restrictions.h"
(...skipping 2567 matching lines...) Expand 10 before | Expand all | Expand 10 after
2584 it++) { 2588 it++) {
2585 DownloadItem* curr_item = *it; 2589 DownloadItem* curr_item = *it;
2586 if (curr_item->id() == id) { 2590 if (curr_item->id() == id) {
2587 selected_item = curr_item; 2591 selected_item = curr_item;
2588 break; 2592 break;
2589 } 2593 }
2590 } 2594 }
2591 return selected_item; 2595 return selected_item;
2592 } 2596 }
2593 2597
2594 } // namespace 2598 } // namespace
2595 2599
2596 // See PerformActionOnDownload() in chrome/test/pyautolib/pyauto.py for sample 2600 // See PerformActionOnDownload() in chrome/test/pyautolib/pyauto.py for sample
2597 // json input and output. 2601 // json input and output.
2598 void TestingAutomationProvider::PerformActionOnDownload( 2602 void TestingAutomationProvider::PerformActionOnDownload(
2599 Browser* browser, 2603 Browser* browser,
2600 DictionaryValue* args, 2604 DictionaryValue* args,
2601 IPC::Message* reply_message) { 2605 IPC::Message* reply_message) {
2602 int id; 2606 int id;
2603 std::string action; 2607 std::string action;
2604 2608
(...skipping 368 matching lines...) Expand 10 before | Expand all | Expand 10 after
2973 ListValue* items = new ListValue; 2977 ListValue* items = new ListValue;
2974 for (std::vector<webkit::npapi::WebPluginInfo>::const_iterator it = 2978 for (std::vector<webkit::npapi::WebPluginInfo>::const_iterator it =
2975 plugins.begin(); 2979 plugins.begin();
2976 it != plugins.end(); 2980 it != plugins.end();
2977 ++it) { 2981 ++it) {
2978 DictionaryValue* item = new DictionaryValue; 2982 DictionaryValue* item = new DictionaryValue;
2979 item->SetString("name", it->name); 2983 item->SetString("name", it->name);
2980 item->SetString("path", it->path.value()); 2984 item->SetString("path", it->path.value());
2981 item->SetString("version", it->version); 2985 item->SetString("version", it->version);
2982 item->SetString("desc", it->desc); 2986 item->SetString("desc", it->desc);
2983 item->SetBoolean("enabled", it->enabled); 2987 item->SetBoolean("enabled", webkit::npapi::IsPluginEnabled(*it));
2984 // Add info about mime types. 2988 // Add info about mime types.
2985 ListValue* mime_types = new ListValue(); 2989 ListValue* mime_types = new ListValue();
2986 for (std::vector<webkit::npapi::WebPluginMimeType>::const_iterator type_it = 2990 for (std::vector<webkit::npapi::WebPluginMimeType>::const_iterator type_it =
2987 it->mime_types.begin(); 2991 it->mime_types.begin();
2988 type_it != it->mime_types.end(); 2992 type_it != it->mime_types.end();
2989 ++type_it) { 2993 ++type_it) {
2990 DictionaryValue* mime_type = new DictionaryValue(); 2994 DictionaryValue* mime_type = new DictionaryValue();
2991 mime_type->SetString("mimeType", type_it->mime_type); 2995 mime_type->SetString("mimeType", type_it->mime_type);
2992 mime_type->SetString("description", type_it->description); 2996 mime_type->SetString("description", type_it->description);
2993 2997
(...skipping 17 matching lines...) Expand all
3011 AutomationJSONReply(this, reply_message).SendSuccess(return_value.get()); 3015 AutomationJSONReply(this, reply_message).SendSuccess(return_value.get());
3012 } 3016 }
3013 3017
3014 // Sample json input: 3018 // Sample json input:
3015 // { "command": "EnablePlugin", 3019 // { "command": "EnablePlugin",
3016 // "path": "/Library/Internet Plug-Ins/Flash Player.plugin" } 3020 // "path": "/Library/Internet Plug-Ins/Flash Player.plugin" }
3017 void TestingAutomationProvider::EnablePlugin(Browser* browser, 3021 void TestingAutomationProvider::EnablePlugin(Browser* browser,
3018 DictionaryValue* args, 3022 DictionaryValue* args,
3019 IPC::Message* reply_message) { 3023 IPC::Message* reply_message) {
3020 FilePath::StringType path; 3024 FilePath::StringType path;
3025 string16 name;
jam 2011/01/19 20:22:09 nit: here and below, looks like name is unused?
pastarmovj 2011/01/19 23:39:17 Done. Undone small changes to following lines that
3021 AutomationJSONReply reply(this, reply_message); 3026 AutomationJSONReply reply(this, reply_message);
3022 if (!args->GetString("path", &path)) { 3027 if (!args->GetString("path", &path)) {
3023 reply.SendError("path not specified."); 3028 reply.SendError("path or name not specified.");
3024 return; 3029 return;
3025 } else if (!webkit::npapi::PluginList::Singleton()->EnablePlugin( 3030 } else if (!webkit::npapi::PluginList::Singleton()->EnablePlugin(
3026 FilePath(path))) { 3031 FilePath(path))) {
3027 reply.SendError(StringPrintf("Could not enable plugin for path %s.", 3032 reply.SendError(StringPrintf("Could not enable plugin for path %s.",
3028 path.c_str())); 3033 path.c_str()));
3029 return; 3034 return;
3030 } 3035 }
3031 reply.SendSuccess(NULL); 3036 reply.SendSuccess(NULL);
3032 } 3037 }
3033 3038
3034 // Sample json input: 3039 // Sample json input:
3035 // { "command": "DisablePlugin", 3040 // { "command": "DisablePlugin",
3036 // "path": "/Library/Internet Plug-Ins/Flash Player.plugin" } 3041 // "path": "/Library/Internet Plug-Ins/Flash Player.plugin" }
3037 void TestingAutomationProvider::DisablePlugin(Browser* browser, 3042 void TestingAutomationProvider::DisablePlugin(Browser* browser,
3038 DictionaryValue* args, 3043 DictionaryValue* args,
3039 IPC::Message* reply_message) { 3044 IPC::Message* reply_message) {
3040 FilePath::StringType path; 3045 FilePath::StringType path;
3046 string16 name;
3041 AutomationJSONReply reply(this, reply_message); 3047 AutomationJSONReply reply(this, reply_message);
3042 if (!args->GetString("path", &path)) { 3048 if (!args->GetString("path", &path)) {
3043 reply.SendError("path not specified."); 3049 reply.SendError("path or name not specified.");
3044 return; 3050 return;
3045 } else if (!webkit::npapi::PluginList::Singleton()->DisablePlugin( 3051 } else if (!webkit::npapi::PluginList::Singleton()->DisablePlugin(
3046 FilePath(path))) { 3052 FilePath(path))) {
3047 reply.SendError(StringPrintf("Could not disable plugin for path %s.", 3053 reply.SendError(StringPrintf("Could not disable plugin for path %s.",
3048 path.c_str())); 3054 path.c_str()));
3049 return; 3055 return;
3050 } 3056 }
3051 reply.SendSuccess(NULL); 3057 reply.SendSuccess(NULL);
3052 } 3058 }
3053 3059
3054 // Sample json input: 3060 // Sample json input:
3055 // { "command": "SaveTabContents", 3061 // { "command": "SaveTabContents",
3056 // "tab_index": 0, 3062 // "tab_index": 0,
(...skipping 134 matching lines...) Expand 10 before | Expand all | Expand 10 after
3191 password_form.username_element = username_element; 3197 password_form.username_element = username_element;
3192 password_form.password_element = password_element; 3198 password_form.password_element = password_element;
3193 password_form.submit_element = submit_element; 3199 password_form.submit_element = submit_element;
3194 password_form.action = action_target; 3200 password_form.action = action_target;
3195 password_form.blacklisted_by_user = blacklist; 3201 password_form.blacklisted_by_user = blacklist;
3196 password_form.date_created = time; 3202 password_form.date_created = time;
3197 3203
3198 return password_form; 3204 return password_form;
3199 } 3205 }
3200 3206
3201 } // namespace 3207 } // namespace
3202 3208
3203 // See AddSavedPassword() in chrome/test/functional/pyauto.py for sample json 3209 // See AddSavedPassword() in chrome/test/functional/pyauto.py for sample json
3204 // input. 3210 // input.
3205 // Sample json output: { "password_added": true } 3211 // Sample json output: { "password_added": true }
3206 void TestingAutomationProvider::AddSavedPassword( 3212 void TestingAutomationProvider::AddSavedPassword(
3207 Browser* browser, 3213 Browser* browser,
3208 DictionaryValue* args, 3214 DictionaryValue* args,
3209 IPC::Message* reply_message) { 3215 IPC::Message* reply_message) {
3210 AutomationJSONReply reply(this, reply_message); 3216 AutomationJSONReply reply(this, reply_message);
3211 DictionaryValue* password_dict = NULL; 3217 DictionaryValue* password_dict = NULL;
(...skipping 1299 matching lines...) Expand 10 before | Expand all | Expand 10 after
4511 // If you change this, update Observer for NotificationType::SESSION_END 4517 // If you change this, update Observer for NotificationType::SESSION_END
4512 // below. 4518 // below.
4513 MessageLoop::current()->PostTask(FROM_HERE, 4519 MessageLoop::current()->PostTask(FROM_HERE,
4514 NewRunnableMethod(this, &TestingAutomationProvider::OnRemoveProvider)); 4520 NewRunnableMethod(this, &TestingAutomationProvider::OnRemoveProvider));
4515 } 4521 }
4516 } 4522 }
4517 4523
4518 void TestingAutomationProvider::OnRemoveProvider() { 4524 void TestingAutomationProvider::OnRemoveProvider() {
4519 AutomationProviderList::GetInstance()->RemoveProvider(this); 4525 AutomationProviderList::GetInstance()->RemoveProvider(this);
4520 } 4526 }
OLDNEW

Powered by Google App Engine
This is Rietveld 408576698