| 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 4029 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 4040 } | 4040 } |
| 4041 } | 4041 } |
| 4042 | 4042 |
| 4043 // Sample json output: | 4043 // Sample json output: |
| 4044 // {u'summary': u'SYNC DISABLED'} | 4044 // {u'summary': u'SYNC DISABLED'} |
| 4045 // | 4045 // |
| 4046 // { u'authenticated': True, | 4046 // { u'authenticated': True, |
| 4047 // u'last synced': u'Just now', | 4047 // u'last synced': u'Just now', |
| 4048 // u'summary': u'READY', | 4048 // u'summary': u'READY', |
| 4049 // u'sync url': u'clients4.google.com', | 4049 // u'sync url': u'clients4.google.com', |
| 4050 // u'updates received': 42, |
| 4050 // u'synced datatypes': [ u'Bookmarks', | 4051 // u'synced datatypes': [ u'Bookmarks', |
| 4051 // u'Preferences', | 4052 // u'Preferences', |
| 4052 // u'Passwords', | 4053 // u'Passwords', |
| 4053 // u'Autofill', | 4054 // u'Autofill', |
| 4054 // u'Themes', | 4055 // u'Themes', |
| 4055 // u'Extensions', | 4056 // u'Extensions', |
| 4056 // u'Apps']} | 4057 // u'Apps']} |
| 4057 void TestingAutomationProvider::GetSyncInfo(Browser* browser, | 4058 void TestingAutomationProvider::GetSyncInfo(Browser* browser, |
| 4058 DictionaryValue* args, | 4059 DictionaryValue* args, |
| 4059 IPC::Message* reply_message) { | 4060 IPC::Message* reply_message) { |
| 4060 AutomationJSONReply reply(this, reply_message); | 4061 AutomationJSONReply reply(this, reply_message); |
| 4061 DictionaryValue* sync_info = new DictionaryValue; | 4062 DictionaryValue* sync_info = new DictionaryValue; |
| 4062 scoped_ptr<DictionaryValue> return_value(new DictionaryValue); | 4063 scoped_ptr<DictionaryValue> return_value(new DictionaryValue); |
| 4063 if (sync_waiter_.get() == NULL) { | 4064 if (sync_waiter_.get() == NULL) { |
| 4064 sync_waiter_.reset( | 4065 sync_waiter_.reset( |
| 4065 ProfileSyncServiceHarness::CreateAndAttach(browser->profile())); | 4066 ProfileSyncServiceHarness::CreateAndAttach(browser->profile())); |
| 4066 } | 4067 } |
| 4067 if (!sync_waiter_->IsSyncAlreadySetup()) { | 4068 if (!sync_waiter_->IsSyncAlreadySetup()) { |
| 4068 sync_info->SetString("summary", "SYNC DISABLED"); | 4069 sync_info->SetString("summary", "SYNC DISABLED"); |
| 4069 } else { | 4070 } else { |
| 4070 ProfileSyncService* service = sync_waiter_->service(); | 4071 ProfileSyncService* service = sync_waiter_->service(); |
| 4071 ProfileSyncService::Status status = sync_waiter_->GetStatus(); | 4072 ProfileSyncService::Status status = sync_waiter_->GetStatus(); |
| 4072 sync_info->SetString("summary", | 4073 sync_info->SetString("summary", |
| 4073 ProfileSyncService::BuildSyncStatusSummaryText(status.summary)); | 4074 ProfileSyncService::BuildSyncStatusSummaryText(status.summary)); |
| 4074 sync_info->SetString("sync url", service->sync_service_url().host()); | 4075 sync_info->SetString("sync url", service->sync_service_url().host()); |
| 4075 sync_info->SetBoolean("authenticated", status.authenticated); | 4076 sync_info->SetBoolean("authenticated", status.authenticated); |
| 4076 sync_info->SetString("last synced", service->GetLastSyncedTimeString()); | 4077 sync_info->SetString("last synced", service->GetLastSyncedTimeString()); |
| 4078 sync_info->SetInteger("updates received", status.updates_received); |
| 4077 ListValue* synced_datatype_list = new ListValue; | 4079 ListValue* synced_datatype_list = new ListValue; |
| 4078 syncable::ModelTypeSet synced_datatypes; | 4080 syncable::ModelTypeSet synced_datatypes; |
| 4079 service->GetPreferredDataTypes(&synced_datatypes); | 4081 service->GetPreferredDataTypes(&synced_datatypes); |
| 4080 for (syncable::ModelTypeSet::iterator it = synced_datatypes.begin(); | 4082 for (syncable::ModelTypeSet::iterator it = synced_datatypes.begin(); |
| 4081 it != synced_datatypes.end(); ++it) { | 4083 it != synced_datatypes.end(); ++it) { |
| 4082 synced_datatype_list->Append( | 4084 synced_datatype_list->Append( |
| 4083 new StringValue(syncable::ModelTypeToString(*it))); | 4085 new StringValue(syncable::ModelTypeToString(*it))); |
| 4084 } | 4086 } |
| 4085 sync_info->Set("synced datatypes", synced_datatype_list); | 4087 sync_info->Set("synced datatypes", synced_datatype_list); |
| 4086 } | 4088 } |
| (...skipping 1253 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 5340 // If you change this, update Observer for NotificationType::SESSION_END | 5342 // If you change this, update Observer for NotificationType::SESSION_END |
| 5341 // below. | 5343 // below. |
| 5342 MessageLoop::current()->PostTask(FROM_HERE, | 5344 MessageLoop::current()->PostTask(FROM_HERE, |
| 5343 NewRunnableMethod(this, &TestingAutomationProvider::OnRemoveProvider)); | 5345 NewRunnableMethod(this, &TestingAutomationProvider::OnRemoveProvider)); |
| 5344 } | 5346 } |
| 5345 } | 5347 } |
| 5346 | 5348 |
| 5347 void TestingAutomationProvider::OnRemoveProvider() { | 5349 void TestingAutomationProvider::OnRemoveProvider() { |
| 5348 AutomationProviderList::GetInstance()->RemoveProvider(this); | 5350 AutomationProviderList::GetInstance()->RemoveProvider(this); |
| 5349 } | 5351 } |
| OLD | NEW |