Commit b9cf9558 authored by zea@chromium.org's avatar zea@chromium.org

[Sync] Add passphrase/encryption info to chrome://sync.

BUG=91134
TEST=Set up sync, inspect chrome://sync


Review URL: http://codereview.chromium.org/7550023

git-svn-id: svn://svn.chromium.org/chrome/trunk/src@95536 0039d316-1c4b-4281-b951-d872f2087c98
parent e87dbfd4
...@@ -12,15 +12,16 @@ ...@@ -12,15 +12,16 @@
#include "chrome/browser/sync/protocol/service_constants.h" #include "chrome/browser/sync/protocol/service_constants.h"
#include "chrome/browser/sync/sessions/session_state.h" #include "chrome/browser/sync/sessions/session_state.h"
#include "chrome/browser/sync/syncable/directory_manager.h" #include "chrome/browser/sync/syncable/directory_manager.h"
#include "chrome/browser/sync/syncable/model_type.h"
namespace browser_sync { namespace browser_sync {
static const sync_api::SyncManager::Status init_status = AllStatus::AllStatus() {
{ sync_api::SyncManager::Status::OFFLINE }; status_.summary = sync_api::SyncManager::Status::OFFLINE;
AllStatus::AllStatus() : status_(init_status) {
status_.initial_sync_ended = true; status_.initial_sync_ended = true;
status_.notifications_enabled = false; status_.notifications_enabled = false;
status_.cryptographer_ready = false;
status_.crypto_has_pending_keys = false;
} }
AllStatus::~AllStatus() { AllStatus::~AllStatus() {
...@@ -165,6 +166,21 @@ void AllStatus::IncrementNotificationsReceived() { ...@@ -165,6 +166,21 @@ void AllStatus::IncrementNotificationsReceived() {
++status_.notifications_received; ++status_.notifications_received;
} }
void AllStatus::SetEncryptedTypes(const syncable::ModelTypeSet& types) {
ScopedStatusLock lock(this);
status_.encrypted_types = types;
}
void AllStatus::SetCryptographerReady(bool ready) {
ScopedStatusLock lock(this);
status_.cryptographer_ready = ready;
}
void AllStatus::SetCryptoHasPendingKeys(bool has_pending_keys) {
ScopedStatusLock lock(this);
status_.crypto_has_pending_keys = has_pending_keys;
}
ScopedStatusLock::ScopedStatusLock(AllStatus* allstatus) ScopedStatusLock::ScopedStatusLock(AllStatus* allstatus)
: allstatus_(allstatus) { : allstatus_(allstatus) {
allstatus->mutex_.Acquire(); allstatus->mutex_.Acquire();
......
...@@ -15,6 +15,7 @@ ...@@ -15,6 +15,7 @@
#include "base/synchronization/lock.h" #include "base/synchronization/lock.h"
#include "chrome/browser/sync/engine/syncapi.h" #include "chrome/browser/sync/engine/syncapi.h"
#include "chrome/browser/sync/engine/syncer_types.h" #include "chrome/browser/sync/engine/syncer_types.h"
#include "chrome/browser/sync/syncable/model_type.h"
namespace browser_sync { namespace browser_sync {
...@@ -46,6 +47,10 @@ class AllStatus : public SyncEngineEventListener { ...@@ -46,6 +47,10 @@ class AllStatus : public SyncEngineEventListener {
void IncrementNotificationsReceived(); void IncrementNotificationsReceived();
void SetEncryptedTypes(const syncable::ModelTypeSet& types);
void SetCryptographerReady(bool ready);
void SetCryptoHasPendingKeys(bool has_pending_keys);
protected: protected:
// Examines syncer to calculate syncing and the unsynced count, // Examines syncer to calculate syncing and the unsynced count,
// and returns a Status with new values. // and returns a Status with new values.
......
...@@ -1641,6 +1641,12 @@ SyncManager::Observer::~Observer() {} ...@@ -1641,6 +1641,12 @@ SyncManager::Observer::~Observer() {}
SyncManager::SyncManager(const std::string& name) SyncManager::SyncManager(const std::string& name)
: data_(new SyncInternal(name)) {} : data_(new SyncInternal(name)) {}
SyncManager::Status::Status() {
}
SyncManager::Status::~Status() {
}
bool SyncManager::Init( bool SyncManager::Init(
const FilePath& database_location, const FilePath& database_location,
const WeakHandle<JsEventHandler>& event_handler, const WeakHandle<JsEventHandler>& event_handler,
...@@ -1865,6 +1871,9 @@ bool SyncManager::SyncInternal::UpdateCryptographerFromNigori() { ...@@ -1865,6 +1871,9 @@ bool SyncManager::SyncInternal::UpdateCryptographerFromNigori() {
OnPassphraseRequired(sync_api::REASON_DECRYPTION)); OnPassphraseRequired(sync_api::REASON_DECRYPTION));
} }
allstatus_.SetCryptographerReady(cryptographer->is_ready());
allstatus_.SetCryptoHasPendingKeys(cryptographer->has_pending_keys());
return cryptographer->is_ready(); return cryptographer->is_ready();
} }
...@@ -2103,6 +2112,7 @@ void SyncManager::SyncInternal::EncryptDataTypes( ...@@ -2103,6 +2112,7 @@ void SyncManager::SyncInternal::EncryptDataTypes(
encrypted_types.begin(), encrypted_types.end(), encrypted_types.begin(), encrypted_types.end(),
std::inserter(newly_encrypted_types, std::inserter(newly_encrypted_types,
newly_encrypted_types.begin())); newly_encrypted_types.begin()));
allstatus_.SetEncryptedTypes(newly_encrypted_types);
if (newly_encrypted_types == current_encrypted_types) if (newly_encrypted_types == current_encrypted_types)
return; // Set of encrypted types did not change. return; // Set of encrypted types did not change.
syncable::FillNigoriEncryptedTypes(newly_encrypted_types, &nigori); syncable::FillNigoriEncryptedTypes(newly_encrypted_types, &nigori);
...@@ -2561,6 +2571,11 @@ void SyncManager::SyncInternal::OnSyncEngineEvent( ...@@ -2561,6 +2571,11 @@ void SyncManager::SyncInternal::OnSyncEngineEvent(
FOR_EACH_OBSERVER(SyncManager::Observer, temp_obs_list, FOR_EACH_OBSERVER(SyncManager::Observer, temp_obs_list,
OnPassphraseRequired(sync_api::REASON_ENCRYPTION)); OnPassphraseRequired(sync_api::REASON_ENCRYPTION));
} }
allstatus_.SetCryptographerReady(cryptographer->is_ready());
allstatus_.SetCryptoHasPendingKeys(cryptographer->has_pending_keys());
allstatus_.SetEncryptedTypes(cryptographer->GetEncryptedTypes());
// If everything is in order(we have the passphrase) then there is no // If everything is in order(we have the passphrase) then there is no
// need to inform the listeners. They will just wait for sync // need to inform the listeners. They will just wait for sync
// completion event and if no errors have been raised it means // completion event and if no errors have been raised it means
......
...@@ -702,6 +702,9 @@ class SyncManager { ...@@ -702,6 +702,9 @@ class SyncManager {
SUMMARY_STATUS_COUNT, SUMMARY_STATUS_COUNT,
}; };
Status();
~Status();
Summary summary; Summary summary;
bool authenticated; // Successfully authenticated via GAIA. bool authenticated; // Successfully authenticated via GAIA.
bool server_up; // True if we have received at least one good bool server_up; // True if we have received at least one good
...@@ -747,6 +750,11 @@ class SyncManager { ...@@ -747,6 +750,11 @@ class SyncManager {
// Count of useless and useful syncs we perform. // Count of useless and useful syncs we perform.
int useless_sync_cycles; int useless_sync_cycles;
int useful_sync_cycles; int useful_sync_cycles;
// Encryption related.
syncable::ModelTypeSet encrypted_types;
bool cryptographer_ready;
bool crypto_has_pending_keys;
}; };
// An interface the embedding application implements to receive notifications // An interface the embedding application implements to receive notifications
......
...@@ -830,8 +830,8 @@ SyncBackendHost::Status ProfileSyncService::QueryDetailedSyncStatus() { ...@@ -830,8 +830,8 @@ SyncBackendHost::Status ProfileSyncService::QueryDetailedSyncStatus() {
if (backend_.get() && backend_initialized_) { if (backend_.get() && backend_initialized_) {
return backend_->GetDetailedStatus(); return backend_->GetDetailedStatus();
} else { } else {
SyncBackendHost::Status status = SyncBackendHost::Status status;
{ SyncBackendHost::Status::OFFLINE_UNUSABLE }; status.summary = SyncBackendHost::Status::OFFLINE_UNUSABLE;
return status; return status;
} }
} }
......
...@@ -12,6 +12,7 @@ ...@@ -12,6 +12,7 @@
#include "chrome/browser/profiles/profile_manager.h" #include "chrome/browser/profiles/profile_manager.h"
#include "chrome/browser/sync/profile_sync_service.h" #include "chrome/browser/sync/profile_sync_service.h"
#include "chrome/browser/sync/protocol/proto_enum_conversions.h" #include "chrome/browser/sync/protocol/proto_enum_conversions.h"
#include "chrome/browser/sync/syncable/model_type.h"
#include "chrome/browser/sync/sessions/session_state.h" #include "chrome/browser/sync/sessions/session_state.h"
#include "chrome/browser/ui/browser.h" #include "chrome/browser/ui/browser.h"
#include "chrome/browser/ui/browser_window.h" #include "chrome/browser/ui/browser_window.h"
...@@ -425,6 +426,21 @@ void ConstructAboutInformation(ProfileSyncService* service, ...@@ -425,6 +426,21 @@ void ConstructAboutInformation(ProfileSyncService* service,
sync_ui_util::AddIntSyncDetail(details, sync_ui_util::AddIntSyncDetail(details,
"Useful Sync Cycles", "Useful Sync Cycles",
full_status.useful_sync_cycles); full_status.useful_sync_cycles);
sync_ui_util::AddBoolSyncDetail(details,
"Explicit Passphrase",
service->IsUsingSecondaryPassphrase());
sync_ui_util::AddBoolSyncDetail(details,
"Passphrase Required",
service->IsPassphraseRequired());
sync_ui_util::AddBoolSyncDetail(details,
"Cryptographer Ready",
full_status.cryptographer_ready);
sync_ui_util::AddBoolSyncDetail(details,
"Cryptographer Has Pending Keys",
full_status.crypto_has_pending_keys);
sync_ui_util::AddStringSyncDetails(details,
"Encrypted Types",
syncable::ModelTypeSetToString(full_status.encrypted_types));
const browser_sync::sessions::SyncSessionSnapshot* snapshot = const browser_sync::sessions::SyncSessionSnapshot* snapshot =
service->sync_initialized() ? service->sync_initialized() ?
......
...@@ -72,5 +72,8 @@ void ConstructAboutInformation(ProfileSyncService* service, ...@@ -72,5 +72,8 @@ void ConstructAboutInformation(ProfileSyncService* service,
void AddIntSyncDetail(base::ListValue* details, void AddIntSyncDetail(base::ListValue* details,
const std::string& stat_name, const std::string& stat_name,
int64 stat_value); int64 stat_value);
void AddStringSyncDetails(ListValue* details, const std::string& stat_name,
const std::string& stat_value);
} // namespace sync_ui_util } // namespace sync_ui_util
#endif // CHROME_BROWSER_SYNC_SYNC_UI_UTIL_H_ #endif // CHROME_BROWSER_SYNC_SYNC_UI_UTIL_H_
...@@ -22,8 +22,8 @@ TEST(SyncUIUtilTest, ConstructAboutInformationWithUnrecoverableErrorTest) { ...@@ -22,8 +22,8 @@ TEST(SyncUIUtilTest, ConstructAboutInformationWithUnrecoverableErrorTest) {
// Will be released when the dictionary is destroyed // Will be released when the dictionary is destroyed
string16 str(ASCIIToUTF16("none")); string16 str(ASCIIToUTF16("none"));
browser_sync::SyncBackendHost::Status status = browser_sync::SyncBackendHost::Status status;
{ browser_sync::SyncBackendHost::Status::OFFLINE_UNUSABLE }; status.summary = browser_sync::SyncBackendHost::Status::OFFLINE_UNUSABLE;
EXPECT_CALL(service, HasSyncSetupCompleted()) EXPECT_CALL(service, HasSyncSetupCompleted())
.WillOnce(Return(true)); .WillOnce(Return(true));
......
Markdown is supported
0%
or
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment