OLD | NEW |
(Empty) | |
| 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 |
| 3 // found in the LICENSE file. |
| 4 |
| 5 #include "chrome/browser/dom_ui/import_data_handler.h" |
| 6 |
| 7 #include "app/l10n_util.h" |
| 8 #include "base/basictypes.h" |
| 9 #include "base/values.h" |
| 10 #include "base/callback.h" |
| 11 #include "grit/chromium_strings.h" |
| 12 #include "grit/generated_resources.h" |
| 13 #include "chrome/browser/importer/importer_data_types.h" |
| 14 |
| 15 ImportDataHandler::ImportDataHandler() { |
| 16 } |
| 17 |
| 18 ImportDataHandler::~ImportDataHandler() { |
| 19 } |
| 20 |
| 21 void ImportDataHandler::Initialize() { |
| 22 importer_host_ = new ImporterHost(); |
| 23 DetectSupportedBrowsers(); |
| 24 } |
| 25 |
| 26 void ImportDataHandler::GetLocalizedValues( |
| 27 DictionaryValue* localized_strings) { |
| 28 DCHECK(localized_strings); |
| 29 localized_strings->SetString(L"import_data_title", |
| 30 l10n_util::GetString(IDS_IMPORT_SETTINGS_TITLE)); |
| 31 localized_strings->SetString(L"import_from_label", |
| 32 l10n_util::GetString(IDS_IMPORT_FROM_LABEL)); |
| 33 localized_strings->SetString(L"import_commit", |
| 34 l10n_util::GetString(IDS_IMPORT_COMMIT)); |
| 35 localized_strings->SetString(L"import_description", |
| 36 l10n_util::GetString(IDS_IMPORT_ITEMS_LABEL)); |
| 37 localized_strings->SetString(L"import_favorites", |
| 38 l10n_util::GetString(IDS_IMPORT_FAVORITES_CHKBOX)); |
| 39 localized_strings->SetString(L"import_search", |
| 40 l10n_util::GetString(IDS_IMPORT_SEARCH_ENGINES_CHKBOX)); |
| 41 localized_strings->SetString(L"import_passwords", |
| 42 l10n_util::GetString(IDS_IMPORT_PASSWORDS_CHKBOX)); |
| 43 localized_strings->SetString(L"import_history", |
| 44 l10n_util::GetString(IDS_IMPORT_HISTORY_CHKBOX)); |
| 45 } |
| 46 |
| 47 void ImportDataHandler::RegisterMessages() { |
| 48 } |
| 49 |
| 50 void ImportDataHandler::DetectSupportedBrowsers() { |
| 51 ListValue supported_browsers; |
| 52 int profiles_count = importer_host_->GetAvailableProfileCount(); |
| 53 |
| 54 if (profiles_count > 0) { |
| 55 for (int i = 0; i < profiles_count; i++) { |
| 56 std::wstring profile = importer_host_->GetSourceProfileNameAt(i); |
| 57 DictionaryValue* entry = new DictionaryValue(); |
| 58 entry->SetString(L"name", profile); |
| 59 entry->SetInteger(L"index", i); |
| 60 supported_browsers.Append(entry); |
| 61 } |
| 62 } else { |
| 63 DictionaryValue* entry = new DictionaryValue(); |
| 64 entry->SetString(L"name", l10n_util::GetString(IDS_IMPORT_FROM_LABEL)); |
| 65 entry->SetInteger(L"index", 0); |
| 66 supported_browsers.Append(entry); |
| 67 } |
| 68 |
| 69 dom_ui_->CallJavascriptFunction( |
| 70 L"ImportDataOverlay.updateSupportedBrowsers", supported_browsers); |
| 71 } |
OLD | NEW |