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/dom_ui/options/sync_options_handler.h" | 5 #include "chrome/browser/dom_ui/options/sync_options_handler.h" |
6 | 6 |
7 #include "app/l10n_util.h" | 7 #include "app/l10n_util.h" |
8 #include "base/basictypes.h" | 8 #include "base/basictypes.h" |
9 #include "base/callback.h" | 9 #include "base/callback.h" |
10 #include "base/stl_util-inl.h" | 10 #include "base/stl_util-inl.h" |
(...skipping 41 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
52 localized_strings->SetString("syncthemes", | 52 localized_strings->SetString("syncthemes", |
53 l10n_util::GetStringUTF16(IDS_SYNC_DATATYPE_THEMES)); | 53 l10n_util::GetStringUTF16(IDS_SYNC_DATATYPE_THEMES)); |
54 localized_strings->SetString("syncapps", | 54 localized_strings->SetString("syncapps", |
55 l10n_util::GetStringUTF16(IDS_SYNC_DATATYPE_APPS)); | 55 l10n_util::GetStringUTF16(IDS_SYNC_DATATYPE_APPS)); |
56 localized_strings->SetString("syncsessions", | 56 localized_strings->SetString("syncsessions", |
57 l10n_util::GetStringUTF16(IDS_SYNC_DATATYPE_SESSIONS)); | 57 l10n_util::GetStringUTF16(IDS_SYNC_DATATYPE_SESSIONS)); |
58 } | 58 } |
59 | 59 |
60 void SyncOptionsHandler::Initialize() { | 60 void SyncOptionsHandler::Initialize() { |
61 ProfileSyncService* service = | 61 ProfileSyncService* service = |
62 dom_ui_->GetProfile()->GetOriginalProfile()->GetProfileSyncService(); | 62 dom_ui_->GetProfile()->GetProfileSyncService(); |
63 // If service is unavailable for some good reason, 'IsEnabled()' method | 63 if (!service) |
64 // should return false. Otherwise something is broken. | 64 return; // Can happen in ChromeOS if called before login. |
65 DCHECK(service); | |
66 | 65 |
67 DictionaryValue args; | 66 DictionaryValue args; |
68 SyncSetupFlow::GetArgsForConfigure(service, &args); | 67 SyncSetupFlow::GetArgsForConfigure(service, &args); |
69 | 68 |
70 dom_ui_->CallJavascriptFunction( | 69 dom_ui_->CallJavascriptFunction( |
71 L"PersonalOptions.setRegisteredDataTypes", args); | 70 L"PersonalOptions.setRegisteredDataTypes", args); |
72 } | 71 } |
73 | 72 |
74 void SyncOptionsHandler::RegisterMessages() { | 73 void SyncOptionsHandler::RegisterMessages() { |
75 dom_ui_->RegisterMessageCallback("updatePreferredDataTypes", | 74 dom_ui_->RegisterMessageCallback("updatePreferredDataTypes", |
76 NewCallback(this, &SyncOptionsHandler::OnPreferredDataTypesUpdated)); | 75 NewCallback(this, &SyncOptionsHandler::OnPreferredDataTypesUpdated)); |
77 } | 76 } |
78 | 77 |
79 void SyncOptionsHandler::OnPreferredDataTypesUpdated(const ListValue* args) { | 78 void SyncOptionsHandler::OnPreferredDataTypesUpdated(const ListValue* args) { |
80 NotificationService::current()->Notify( | 79 NotificationService::current()->Notify( |
81 NotificationType::SYNC_DATA_TYPES_UPDATED, | 80 NotificationType::SYNC_DATA_TYPES_UPDATED, |
82 Source<Profile>(dom_ui_->GetProfile()), | 81 Source<Profile>(dom_ui_->GetProfile()), |
83 NotificationService::NoDetails()); | 82 NotificationService::NoDetails()); |
84 } | 83 } |
OLD | NEW |