| 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 <set> | 8 #include <set> |
| 9 #include <string> | 9 #include <string> |
| 10 #include <vector> | 10 #include <vector> |
| (...skipping 1420 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 1431 new BrowserOpenedWithNewProfileNotificationObserver(this, reply_message); | 1431 new BrowserOpenedWithNewProfileNotificationObserver(this, reply_message); |
| 1432 profile_manager->CreateMultiProfileAsync(); | 1432 profile_manager->CreateMultiProfileAsync(); |
| 1433 } | 1433 } |
| 1434 | 1434 |
| 1435 // Sample json input: { "command": "GetMultiProfileInfo" } | 1435 // Sample json input: { "command": "GetMultiProfileInfo" } |
| 1436 // See GetMultiProfileInfo() in pyauto.py for sample output. | 1436 // See GetMultiProfileInfo() in pyauto.py for sample output. |
| 1437 void TestingAutomationProvider::GetMultiProfileInfo( | 1437 void TestingAutomationProvider::GetMultiProfileInfo( |
| 1438 base::DictionaryValue* args, IPC::Message* reply_message) { | 1438 base::DictionaryValue* args, IPC::Message* reply_message) { |
| 1439 scoped_ptr<DictionaryValue> return_value(new DictionaryValue); | 1439 scoped_ptr<DictionaryValue> return_value(new DictionaryValue); |
| 1440 ProfileManager* profile_manager = g_browser_process->profile_manager(); | 1440 ProfileManager* profile_manager = g_browser_process->profile_manager(); |
| 1441 const ProfileInfoCache& profile_info_cache = | 1441 const ProfileInfoCache& cache = profile_manager->GetProfileInfoCache(); |
| 1442 profile_manager->GetProfileInfoCache(); | |
| 1443 return_value->SetBoolean("enabled", | 1442 return_value->SetBoolean("enabled", |
| 1444 profile_manager->IsMultipleProfilesEnabled()); | 1443 profile_manager->IsMultipleProfilesEnabled()); |
| 1445 | 1444 |
| 1446 ListValue* profiles = new ListValue; | 1445 ListValue* profiles = new ListValue; |
| 1447 for (size_t index = 0; index < profile_info_cache.GetNumberOfProfiles(); | 1446 const std::vector<ProfileInfoEntry> entries(cache.GetProfilesSortedByName()); |
| 1448 ++index) { | 1447 for (std::vector<ProfileInfoEntry>::const_iterator it = entries.begin(); |
| 1448 it != entries.end(); ++it) { |
| 1449 DictionaryValue* item = new DictionaryValue; | 1449 DictionaryValue* item = new DictionaryValue; |
| 1450 item->SetString("name", profile_info_cache.GetNameOfProfileAtIndex(index)); | 1450 item->SetString("name", it->name()); |
| 1451 item->SetString("path", | 1451 item->SetString("path", it->path().value()); |
| 1452 profile_info_cache.GetPathOfProfileAtIndex(index).value()); | |
| 1453 profiles->Append(item); | 1452 profiles->Append(item); |
| 1454 } | 1453 } |
| 1455 return_value->Set("profiles", profiles); | 1454 return_value->Set("profiles", profiles); |
| 1456 AutomationJSONReply(this, reply_message).SendSuccess(return_value.get()); | 1455 AutomationJSONReply(this, reply_message).SendSuccess(return_value.get()); |
| 1457 } | 1456 } |
| 1458 | 1457 |
| 1459 void TestingAutomationProvider::OpenNewBrowserWindowOfType( | 1458 void TestingAutomationProvider::OpenNewBrowserWindowOfType( |
| 1460 int type, bool show, IPC::Message* reply_message) { | 1459 int type, bool show, IPC::Message* reply_message) { |
| 1461 new BrowserOpenedNotificationObserver(this, reply_message); | 1460 new BrowserOpenedNotificationObserver(this, reply_message); |
| 1462 // We may have no current browser windows open so don't rely on | 1461 // We may have no current browser windows open so don't rely on |
| (...skipping 4925 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 6388 | 6387 |
| 6389 Send(reply_message_); | 6388 Send(reply_message_); |
| 6390 redirect_query_ = 0; | 6389 redirect_query_ = 0; |
| 6391 reply_message_ = NULL; | 6390 reply_message_ = NULL; |
| 6392 } | 6391 } |
| 6393 | 6392 |
| 6394 void TestingAutomationProvider::OnRemoveProvider() { | 6393 void TestingAutomationProvider::OnRemoveProvider() { |
| 6395 if (g_browser_process) | 6394 if (g_browser_process) |
| 6396 g_browser_process->GetAutomationProviderList()->RemoveProvider(this); | 6395 g_browser_process->GetAutomationProviderList()->RemoveProvider(this); |
| 6397 } | 6396 } |
| OLD | NEW |