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 5064 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
5075 return_value->SetBoolean("success", true); | 5075 return_value->SetBoolean("success", true); |
5076 reply.SendSuccess(return_value.get()); | 5076 reply.SendSuccess(return_value.get()); |
5077 } else { | 5077 } else { |
5078 reply.SendError("Signing in to sync was unsuccessful"); | 5078 reply.SendError("Signing in to sync was unsuccessful"); |
5079 } | 5079 } |
5080 } | 5080 } |
5081 | 5081 |
5082 // Sample json output: | 5082 // Sample json output: |
5083 // {u'summary': u'SYNC DISABLED'} | 5083 // {u'summary': u'SYNC DISABLED'} |
5084 // | 5084 // |
5085 // { u'authenticated': True, | 5085 // { u'last synced': u'Just now', |
5086 // u'last synced': u'Just now', | |
5087 // u'summary': u'READY', | 5086 // u'summary': u'READY', |
5088 // u'sync url': u'clients4.google.com', | 5087 // u'sync url': u'clients4.google.com', |
5089 // u'updates received': 42, | 5088 // u'updates received': 42, |
5090 // u'synced datatypes': [ u'Bookmarks', | 5089 // u'synced datatypes': [ u'Bookmarks', |
5091 // u'Preferences', | 5090 // u'Preferences', |
5092 // u'Passwords', | 5091 // u'Passwords', |
5093 // u'Autofill', | 5092 // u'Autofill', |
5094 // u'Themes', | 5093 // u'Themes', |
5095 // u'Extensions', | 5094 // u'Extensions', |
5096 // u'Apps']} | 5095 // u'Apps']} |
5097 void TestingAutomationProvider::GetSyncInfo(Browser* browser, | 5096 void TestingAutomationProvider::GetSyncInfo(Browser* browser, |
5098 DictionaryValue* args, | 5097 DictionaryValue* args, |
5099 IPC::Message* reply_message) { | 5098 IPC::Message* reply_message) { |
5100 AutomationJSONReply reply(this, reply_message); | 5099 AutomationJSONReply reply(this, reply_message); |
5101 DictionaryValue* sync_info = new DictionaryValue; | 5100 DictionaryValue* sync_info = new DictionaryValue; |
5102 scoped_ptr<DictionaryValue> return_value(new DictionaryValue); | 5101 scoped_ptr<DictionaryValue> return_value(new DictionaryValue); |
5103 if (sync_waiter_.get() == NULL) { | 5102 if (sync_waiter_.get() == NULL) { |
5104 sync_waiter_.reset( | 5103 sync_waiter_.reset( |
5105 ProfileSyncServiceHarness::CreateAndAttach(browser->profile())); | 5104 ProfileSyncServiceHarness::CreateAndAttach(browser->profile())); |
5106 } | 5105 } |
5107 if (!sync_waiter_->IsSyncAlreadySetup()) { | 5106 if (!sync_waiter_->IsSyncAlreadySetup()) { |
5108 sync_info->SetString("summary", "SYNC DISABLED"); | 5107 sync_info->SetString("summary", "SYNC DISABLED"); |
5109 } else { | 5108 } else { |
5110 ProfileSyncService* service = sync_waiter_->service(); | 5109 ProfileSyncService* service = sync_waiter_->service(); |
5111 ProfileSyncService::Status status = sync_waiter_->GetStatus(); | 5110 ProfileSyncService::Status status = sync_waiter_->GetStatus(); |
5112 sync_info->SetString("summary", | 5111 sync_info->SetString("summary", |
5113 ProfileSyncService::BuildSyncStatusSummaryText(status.summary)); | 5112 ProfileSyncService::BuildSyncStatusSummaryText(status.summary)); |
5114 sync_info->SetString("sync url", service->sync_service_url().host()); | 5113 sync_info->SetString("sync url", service->sync_service_url().host()); |
5115 sync_info->SetBoolean("authenticated", status.authenticated); | |
5116 sync_info->SetString("last synced", service->GetLastSyncedTimeString()); | 5114 sync_info->SetString("last synced", service->GetLastSyncedTimeString()); |
5117 sync_info->SetInteger("updates received", status.updates_received); | 5115 sync_info->SetInteger("updates received", status.updates_received); |
5118 ListValue* synced_datatype_list = new ListValue; | 5116 ListValue* synced_datatype_list = new ListValue; |
5119 const syncable::ModelTypeSet synced_datatypes = | 5117 const syncable::ModelTypeSet synced_datatypes = |
5120 service->GetPreferredDataTypes(); | 5118 service->GetPreferredDataTypes(); |
5121 for (syncable::ModelTypeSet::Iterator it = synced_datatypes.First(); | 5119 for (syncable::ModelTypeSet::Iterator it = synced_datatypes.First(); |
5122 it.Good(); it.Inc()) { | 5120 it.Good(); it.Inc()) { |
5123 synced_datatype_list->Append( | 5121 synced_datatype_list->Append( |
5124 new StringValue(syncable::ModelTypeToString(it.Get()))); | 5122 new StringValue(syncable::ModelTypeToString(it.Get()))); |
5125 } | 5123 } |
(...skipping 1858 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
6984 | 6982 |
6985 Send(reply_message_); | 6983 Send(reply_message_); |
6986 redirect_query_ = 0; | 6984 redirect_query_ = 0; |
6987 reply_message_ = NULL; | 6985 reply_message_ = NULL; |
6988 } | 6986 } |
6989 | 6987 |
6990 void TestingAutomationProvider::OnRemoveProvider() { | 6988 void TestingAutomationProvider::OnRemoveProvider() { |
6991 if (g_browser_process) | 6989 if (g_browser_process) |
6992 g_browser_process->GetAutomationProviderList()->RemoveProvider(this); | 6990 g_browser_process->GetAutomationProviderList()->RemoveProvider(this); |
6993 } | 6991 } |
OLD | NEW |