OLD | NEW |
1 // Copyright (c) 2010 The Chromium Authors. All rights reserved. | 1 // Copyright (c) 2010 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/logging.h" | 8 #include "base/logging.h" |
9 #include "base/utf_string_conversions.h" | 9 #include "base/utf_string_conversions.h" |
10 #include "chrome/browser/browser_theme_provider.h" | 10 #include "chrome/browser/browser_theme_provider.h" |
11 #include "chrome/browser/sync/engine/syncapi.h" | 11 #include "chrome/browser/sync/engine/syncapi.h" |
12 #include "chrome/browser/sync/glue/sync_backend_host.h" | 12 #include "chrome/browser/sync/glue/sync_backend_host.h" |
13 #include "chrome/browser/sync/glue/theme_util.h" | 13 #include "chrome/browser/sync/glue/theme_util.h" |
14 #include "chrome/browser/sync/profile_sync_service.h" | 14 #include "chrome/browser/sync/profile_sync_service.h" |
15 #include "chrome/browser/sync/protocol/theme_specifics.pb.h" | 15 #include "chrome/browser/sync/protocol/theme_specifics.pb.h" |
16 #include "chrome/browser/sync/unrecoverable_error_handler.h" | |
17 | 16 |
18 namespace browser_sync { | 17 namespace browser_sync { |
19 | 18 |
20 namespace { | 19 namespace { |
21 | 20 |
22 static const char kThemesTag[] = "google_chrome_themes"; | 21 static const char kThemesTag[] = "google_chrome_themes"; |
23 static const char kCurrentThemeNodeTitle[] = "Current Theme"; | 22 static const char kCurrentThemeNodeTitle[] = "Current Theme"; |
24 | 23 |
25 static const char kNoThemesFolderError[] = | 24 static const char kNoThemesFolderError[] = |
26 "Server did not create the top-level themes node. We " | 25 "Server did not create the top-level themes node. We " |
27 "might be running against an out-of-date server."; | 26 "might be running against an out-of-date server."; |
28 | 27 |
29 } // namespace | 28 } // namespace |
30 | 29 |
31 ThemeModelAssociator::ThemeModelAssociator( | 30 ThemeModelAssociator::ThemeModelAssociator( |
32 ProfileSyncService* sync_service, | 31 ProfileSyncService* sync_service) |
33 UnrecoverableErrorHandler* error_handler) | 32 : sync_service_(sync_service) { |
34 : sync_service_(sync_service), | |
35 error_handler_(error_handler) { | |
36 DCHECK(sync_service_); | 33 DCHECK(sync_service_); |
37 DCHECK(error_handler_); | |
38 } | 34 } |
39 | 35 |
40 ThemeModelAssociator::~ThemeModelAssociator() {} | 36 ThemeModelAssociator::~ThemeModelAssociator() {} |
41 | 37 |
42 bool ThemeModelAssociator::AssociateModels() { | 38 bool ThemeModelAssociator::AssociateModels() { |
43 sync_api::WriteTransaction trans( | 39 sync_api::WriteTransaction trans( |
44 sync_service_->backend()->GetUserShareHandle()); | 40 sync_service_->backend()->GetUserShareHandle()); |
45 sync_api::ReadNode root(&trans); | 41 sync_api::ReadNode root(&trans); |
46 if (!root.InitByTagLookup(kThemesTag)) { | 42 if (!root.InitByTagLookup(kThemesTag)) { |
47 LOG(ERROR) << kNoThemesFolderError; | 43 LOG(ERROR) << kNoThemesFolderError; |
(...skipping 51 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
99 } | 95 } |
100 | 96 |
101 bool ThemeModelAssociator::ChromeModelHasUserCreatedNodes(bool* has_nodes) { | 97 bool ThemeModelAssociator::ChromeModelHasUserCreatedNodes(bool* has_nodes) { |
102 DCHECK(has_nodes); | 98 DCHECK(has_nodes); |
103 // Assume the themes model always has user-created nodes. | 99 // Assume the themes model always has user-created nodes. |
104 *has_nodes = true; | 100 *has_nodes = true; |
105 return true; | 101 return true; |
106 } | 102 } |
107 | 103 |
108 } // namespace browser_sync | 104 } // namespace browser_sync |
OLD | NEW |