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> | 7 #include <map> |
8 #include <string> | 8 #include <string> |
9 #include <vector> | 9 #include <vector> |
10 | 10 |
(...skipping 2773 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... | |
2784 AutomationJSONReply(this, reply_message).SendError( | 2784 AutomationJSONReply(this, reply_message).SendError( |
2785 StringPrintf("Invalid action: %s", action.c_str())); | 2785 StringPrintf("Invalid action: %s", action.c_str())); |
2786 } | 2786 } |
2787 } | 2787 } |
2788 | 2788 |
2789 // Sample json input: { "command": "GetPrefsInfo" } | 2789 // Sample json input: { "command": "GetPrefsInfo" } |
2790 // Refer chrome/test/pyautolib/prefs_info.py for sample json output. | 2790 // Refer chrome/test/pyautolib/prefs_info.py for sample json output. |
2791 void TestingAutomationProvider::GetPrefsInfo(Browser* browser, | 2791 void TestingAutomationProvider::GetPrefsInfo(Browser* browser, |
2792 DictionaryValue* args, | 2792 DictionaryValue* args, |
2793 IPC::Message* reply_message) { | 2793 IPC::Message* reply_message) { |
2794 const PrefService::PreferenceSet& prefs = | |
2795 profile_->GetPrefs()->preference_set(); | |
2796 DictionaryValue* items = new DictionaryValue; | 2794 DictionaryValue* items = new DictionaryValue; |
2797 for (PrefService::PreferenceSet::const_iterator it = prefs.begin(); | 2795 profile_->GetPrefs()->GetPreferenceValues(items); |
Mattias Nissler (ping if slow)
2011/01/26 17:55:11
Seems like we could create the DictionaryValue in
battre
2011/01/27 09:53:27
Done.
| |
2798 it != prefs.end(); ++it) { | 2796 |
2799 items->Set((*it)->name(), (*it)->GetValue()->DeepCopy()); | |
2800 } | |
2801 scoped_ptr<DictionaryValue> return_value(new DictionaryValue); | 2797 scoped_ptr<DictionaryValue> return_value(new DictionaryValue); |
2802 return_value->Set("prefs", items); // return_value owns items. | 2798 return_value->Set("prefs", items); // return_value owns items. |
2803 AutomationJSONReply(this, reply_message).SendSuccess(return_value.get()); | 2799 AutomationJSONReply(this, reply_message).SendSuccess(return_value.get()); |
2804 } | 2800 } |
2805 | 2801 |
2806 // Sample json input: { "command": "SetPrefs", "path": path, "value": value } | 2802 // Sample json input: { "command": "SetPrefs", "path": path, "value": value } |
2807 void TestingAutomationProvider::SetPrefs(Browser* browser, | 2803 void TestingAutomationProvider::SetPrefs(Browser* browser, |
2808 DictionaryValue* args, | 2804 DictionaryValue* args, |
2809 IPC::Message* reply_message) { | 2805 IPC::Message* reply_message) { |
2810 std::string path; | 2806 std::string path; |
(...skipping 1703 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... | |
4514 // If you change this, update Observer for NotificationType::SESSION_END | 4510 // If you change this, update Observer for NotificationType::SESSION_END |
4515 // below. | 4511 // below. |
4516 MessageLoop::current()->PostTask(FROM_HERE, | 4512 MessageLoop::current()->PostTask(FROM_HERE, |
4517 NewRunnableMethod(this, &TestingAutomationProvider::OnRemoveProvider)); | 4513 NewRunnableMethod(this, &TestingAutomationProvider::OnRemoveProvider)); |
4518 } | 4514 } |
4519 } | 4515 } |
4520 | 4516 |
4521 void TestingAutomationProvider::OnRemoveProvider() { | 4517 void TestingAutomationProvider::OnRemoveProvider() { |
4522 AutomationProviderList::GetInstance()->RemoveProvider(this); | 4518 AutomationProviderList::GetInstance()->RemoveProvider(this); |
4523 } | 4519 } |
OLD | NEW |