| OLD | NEW |
| 1 // Copyright (c) 2012 The Chromium Authors. All rights reserved. | 1 // Copyright (c) 2012 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 4982 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 4993 return_value->SetBoolean("success", true); | 4993 return_value->SetBoolean("success", true); |
| 4994 reply.SendSuccess(return_value.get()); | 4994 reply.SendSuccess(return_value.get()); |
| 4995 } else { | 4995 } else { |
| 4996 reply.SendError("Signing in to sync was unsuccessful"); | 4996 reply.SendError("Signing in to sync was unsuccessful"); |
| 4997 } | 4997 } |
| 4998 } | 4998 } |
| 4999 | 4999 |
| 5000 // Sample json output: | 5000 // Sample json output: |
| 5001 // {u'summary': u'SYNC DISABLED'} | 5001 // {u'summary': u'SYNC DISABLED'} |
| 5002 // | 5002 // |
| 5003 // { u'authenticated': True, | 5003 // { u'last synced': u'Just now', |
| 5004 // u'last synced': u'Just now', | |
| 5005 // u'summary': u'READY', | 5004 // u'summary': u'READY', |
| 5006 // u'sync url': u'clients4.google.com', | 5005 // u'sync url': u'clients4.google.com', |
| 5007 // u'updates received': 42, | 5006 // u'updates received': 42, |
| 5008 // u'synced datatypes': [ u'Bookmarks', | 5007 // u'synced datatypes': [ u'Bookmarks', |
| 5009 // u'Preferences', | 5008 // u'Preferences', |
| 5010 // u'Passwords', | 5009 // u'Passwords', |
| 5011 // u'Autofill', | 5010 // u'Autofill', |
| 5012 // u'Themes', | 5011 // u'Themes', |
| 5013 // u'Extensions', | 5012 // u'Extensions', |
| 5014 // u'Apps']} | 5013 // u'Apps']} |
| 5015 void TestingAutomationProvider::GetSyncInfo(Browser* browser, | 5014 void TestingAutomationProvider::GetSyncInfo(Browser* browser, |
| 5016 DictionaryValue* args, | 5015 DictionaryValue* args, |
| 5017 IPC::Message* reply_message) { | 5016 IPC::Message* reply_message) { |
| 5018 AutomationJSONReply reply(this, reply_message); | 5017 AutomationJSONReply reply(this, reply_message); |
| 5019 DictionaryValue* sync_info = new DictionaryValue; | 5018 DictionaryValue* sync_info = new DictionaryValue; |
| 5020 scoped_ptr<DictionaryValue> return_value(new DictionaryValue); | 5019 scoped_ptr<DictionaryValue> return_value(new DictionaryValue); |
| 5021 if (sync_waiter_.get() == NULL) { | 5020 if (sync_waiter_.get() == NULL) { |
| 5022 sync_waiter_.reset( | 5021 sync_waiter_.reset( |
| 5023 ProfileSyncServiceHarness::CreateAndAttach(browser->profile())); | 5022 ProfileSyncServiceHarness::CreateAndAttach(browser->profile())); |
| 5024 } | 5023 } |
| 5025 if (!sync_waiter_->IsSyncAlreadySetup()) { | 5024 if (!sync_waiter_->IsSyncAlreadySetup()) { |
| 5026 sync_info->SetString("summary", "SYNC DISABLED"); | 5025 sync_info->SetString("summary", "SYNC DISABLED"); |
| 5027 } else { | 5026 } else { |
| 5028 ProfileSyncService* service = sync_waiter_->service(); | 5027 ProfileSyncService* service = sync_waiter_->service(); |
| 5029 ProfileSyncService::Status status = sync_waiter_->GetStatus(); | 5028 ProfileSyncService::Status status = sync_waiter_->GetStatus(); |
| 5030 sync_info->SetString("summary", | 5029 sync_info->SetString("summary", |
| 5031 ProfileSyncService::BuildSyncStatusSummaryText(status.summary)); | 5030 ProfileSyncService::BuildSyncStatusSummaryText(status.summary)); |
| 5032 sync_info->SetString("sync url", service->sync_service_url().host()); | 5031 sync_info->SetString("sync url", service->sync_service_url().host()); |
| 5033 sync_info->SetBoolean("authenticated", status.authenticated); | |
| 5034 sync_info->SetString("last synced", service->GetLastSyncedTimeString()); | 5032 sync_info->SetString("last synced", service->GetLastSyncedTimeString()); |
| 5035 sync_info->SetInteger("updates received", status.updates_received); | 5033 sync_info->SetInteger("updates received", status.updates_received); |
| 5036 ListValue* synced_datatype_list = new ListValue; | 5034 ListValue* synced_datatype_list = new ListValue; |
| 5037 const syncable::ModelTypeSet synced_datatypes = | 5035 const syncable::ModelTypeSet synced_datatypes = |
| 5038 service->GetPreferredDataTypes(); | 5036 service->GetPreferredDataTypes(); |
| 5039 for (syncable::ModelTypeSet::Iterator it = synced_datatypes.First(); | 5037 for (syncable::ModelTypeSet::Iterator it = synced_datatypes.First(); |
| 5040 it.Good(); it.Inc()) { | 5038 it.Good(); it.Inc()) { |
| 5041 synced_datatype_list->Append( | 5039 synced_datatype_list->Append( |
| 5042 new StringValue(syncable::ModelTypeToString(it.Get()))); | 5040 new StringValue(syncable::ModelTypeToString(it.Get()))); |
| 5043 } | 5041 } |
| (...skipping 1752 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 6796 | 6794 |
| 6797 Send(reply_message_); | 6795 Send(reply_message_); |
| 6798 redirect_query_ = 0; | 6796 redirect_query_ = 0; |
| 6799 reply_message_ = NULL; | 6797 reply_message_ = NULL; |
| 6800 } | 6798 } |
| 6801 | 6799 |
| 6802 void TestingAutomationProvider::OnRemoveProvider() { | 6800 void TestingAutomationProvider::OnRemoveProvider() { |
| 6803 if (g_browser_process) | 6801 if (g_browser_process) |
| 6804 g_browser_process->GetAutomationProviderList()->RemoveProvider(this); | 6802 g_browser_process->GetAutomationProviderList()->RemoveProvider(this); |
| 6805 } | 6803 } |
| OLD | NEW |