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/sync/glue/theme_model_associator.h" | 5 #include "chrome/browser/sync/glue/theme_model_associator.h" |
6 | 6 |
7 #include "base/basictypes.h" | 7 #include "base/basictypes.h" |
8 #include "base/location.h" | 8 #include "base/location.h" |
9 #include "base/logging.h" | 9 #include "base/logging.h" |
10 #include "base/utf_string_conversions.h" | 10 #include "base/utf_string_conversions.h" |
(...skipping 50 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
61 // TODO(akalin): If the sync data does not have | 61 // TODO(akalin): If the sync data does not have |
62 // use_system_theme_by_default and we do, update that flag on the | 62 // use_system_theme_by_default and we do, update that flag on the |
63 // sync data. | 63 // sync data. |
64 sync_pb::ThemeSpecifics theme_specifics = node.GetThemeSpecifics(); | 64 sync_pb::ThemeSpecifics theme_specifics = node.GetThemeSpecifics(); |
65 if (UpdateThemeSpecificsOrSetCurrentThemeIfNecessary(profile, | 65 if (UpdateThemeSpecificsOrSetCurrentThemeIfNecessary(profile, |
66 &theme_specifics)) | 66 &theme_specifics)) |
67 node.SetThemeSpecifics(theme_specifics); | 67 node.SetThemeSpecifics(theme_specifics); |
68 } else { | 68 } else { |
69 // Set the sync data from the current theme. | 69 // Set the sync data from the current theme. |
70 sync_api::WriteNode node(&trans); | 70 sync_api::WriteNode node(&trans); |
71 if (!node.InitUniqueByCreation(syncable::THEMES, root, | 71 sync_api::WriteNode::InitUniqueByCreationResult result = |
72 kCurrentThemeClientTag)) { | 72 node.InitUniqueByCreation(syncable::THEMES, root, |
| 73 kCurrentThemeClientTag); |
| 74 if (result != sync_api::WriteNode::INIT_SUCCESS) { |
73 return error_handler_->CreateAndUploadError( | 75 return error_handler_->CreateAndUploadError( |
74 FROM_HERE, | 76 FROM_HERE, |
75 "Could not create current theme node.", | 77 "Could not create current theme node.", |
76 model_type()); | 78 model_type()); |
77 } | 79 } |
78 node.SetIsFolder(false); | 80 node.SetIsFolder(false); |
79 node.SetTitle(UTF8ToWide(kCurrentThemeNodeTitle)); | 81 node.SetTitle(UTF8ToWide(kCurrentThemeNodeTitle)); |
80 sync_pb::ThemeSpecifics theme_specifics; | 82 sync_pb::ThemeSpecifics theme_specifics; |
81 GetThemeSpecificsFromCurrentTheme(profile, &theme_specifics); | 83 GetThemeSpecificsFromCurrentTheme(profile, &theme_specifics); |
82 node.SetThemeSpecifics(theme_specifics); | 84 node.SetThemeSpecifics(theme_specifics); |
(...skipping 24 matching lines...) Expand all Loading... |
107 bool ThemeModelAssociator::CryptoReadyIfNecessary() { | 109 bool ThemeModelAssociator::CryptoReadyIfNecessary() { |
108 // We only access the cryptographer while holding a transaction. | 110 // We only access the cryptographer while holding a transaction. |
109 sync_api::ReadTransaction trans(FROM_HERE, sync_service_->GetUserShare()); | 111 sync_api::ReadTransaction trans(FROM_HERE, sync_service_->GetUserShare()); |
110 const syncable::ModelTypeSet encrypted_types = | 112 const syncable::ModelTypeSet encrypted_types = |
111 sync_api::GetEncryptedTypes(&trans); | 113 sync_api::GetEncryptedTypes(&trans); |
112 return !encrypted_types.Has(syncable::THEMES) || | 114 return !encrypted_types.Has(syncable::THEMES) || |
113 sync_service_->IsCryptographerReady(&trans); | 115 sync_service_->IsCryptographerReady(&trans); |
114 } | 116 } |
115 | 117 |
116 } // namespace browser_sync | 118 } // namespace browser_sync |
OLD | NEW |