Commit 819e0f66 authored by sargrass@google.com's avatar sargrass@google.com

add files

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

git-svn-id: svn://svn.chromium.org/chrome/trunk/src@54067 0039d316-1c4b-4281-b951-d872f2087c98
parent 1e2f4690
// Copyright (c) 2010 The Chromium Authors. All rights reserved.
// Use of this source code is governed by a BSD-style license that can be
// found in the LICENSE file.
#include "chrome/browser/dom_ui/import_data_handler.h"
#include "app/l10n_util.h"
#include "base/basictypes.h"
#include "base/values.h"
#include "base/callback.h"
#include "grit/chromium_strings.h"
#include "grit/generated_resources.h"
#include "chrome/browser/importer/importer_data_types.h"
ImportDataHandler::ImportDataHandler() {
}
ImportDataHandler::~ImportDataHandler() {
}
void ImportDataHandler::Initialize() {
importer_host_ = new ImporterHost();
DetectSupportedBrowsers();
}
void ImportDataHandler::GetLocalizedValues(
DictionaryValue* localized_strings) {
DCHECK(localized_strings);
localized_strings->SetString(L"import_data_title",
l10n_util::GetString(IDS_IMPORT_SETTINGS_TITLE));
localized_strings->SetString(L"import_from_label",
l10n_util::GetString(IDS_IMPORT_FROM_LABEL));
localized_strings->SetString(L"import_commit",
l10n_util::GetString(IDS_IMPORT_COMMIT));
localized_strings->SetString(L"import_description",
l10n_util::GetString(IDS_IMPORT_ITEMS_LABEL));
localized_strings->SetString(L"import_favorites",
l10n_util::GetString(IDS_IMPORT_FAVORITES_CHKBOX));
localized_strings->SetString(L"import_search",
l10n_util::GetString(IDS_IMPORT_SEARCH_ENGINES_CHKBOX));
localized_strings->SetString(L"import_passwords",
l10n_util::GetString(IDS_IMPORT_PASSWORDS_CHKBOX));
localized_strings->SetString(L"import_history",
l10n_util::GetString(IDS_IMPORT_HISTORY_CHKBOX));
}
void ImportDataHandler::RegisterMessages() {
}
void ImportDataHandler::DetectSupportedBrowsers() {
ListValue supported_browsers;
int profiles_count = importer_host_->GetAvailableProfileCount();
if (profiles_count > 0) {
for (int i = 0; i < profiles_count; i++) {
std::wstring profile = importer_host_->GetSourceProfileNameAt(i);
DictionaryValue* entry = new DictionaryValue();
entry->SetString(L"name", profile);
entry->SetInteger(L"index", i);
supported_browsers.Append(entry);
}
} else {
DictionaryValue* entry = new DictionaryValue();
entry->SetString(L"name", l10n_util::GetString(IDS_IMPORT_FROM_LABEL));
entry->SetInteger(L"index", 0);
supported_browsers.Append(entry);
}
dom_ui_->CallJavascriptFunction(
L"ImportDataOverlay.updateSupportedBrowsers", supported_browsers);
}
// Copyright (c) 2010 The Chromium Authors. All rights reserved.
// Use of this source code is governed by a BSD-style license that can be
// found in the LICENSE file.
#ifndef CHROME_BROWSER_DOM_UI_IMPORT_DATA_HANDLER_H_
#define CHROME_BROWSER_DOM_UI_IMPORT_DATA_HANDLER_H_
#include "chrome/browser/dom_ui/options_ui.h"
#include "chrome/browser/importer/importer.h"
// Chrome personal stuff import data overlay UI handler.
class ImportDataHandler : public OptionsPageUIHandler {
public:
ImportDataHandler();
virtual ~ImportDataHandler();
virtual void Initialize();
// OptionsUIHandler implementation.
virtual void GetLocalizedValues(DictionaryValue* localized_strings);
// DOMMessageHandler implementation.
virtual void RegisterMessages();
private:
void DetectSupportedBrowsers();
// Utility class that does the actual import.
scoped_refptr<ImporterHost> importer_host_;
DISALLOW_COPY_AND_ASSIGN(ImportDataHandler);
};
#endif // CHROME_BROWSER_DOM_UI_IMPORT_DATA_HANDLER_H_
// Copyright (c) 2010 The Chromium Authors. All rights reserved.
// Use of this source code is governed by a BSD-style license that can be
// found in the LICENSE file.
#include "chrome/browser/dom_ui/stop_syncing_handler.h"
#include "app/l10n_util.h"
#include "base/basictypes.h"
#include "base/values.h"
#include "base/callback.h"
#include "grit/chromium_strings.h"
#include "grit/generated_resources.h"
#include "chrome/browser/sync/profile_sync_service.h"
#include "chrome/browser/profile.h"
#include "chrome/browser/profile_manager.h"
StopSyncingHandler::StopSyncingHandler() {
}
StopSyncingHandler::~StopSyncingHandler() {
}
void StopSyncingHandler::GetLocalizedValues(
DictionaryValue* localized_strings) {
DCHECK(localized_strings);
localized_strings->SetString(L"stop_syncing_explanation",
l10n_util::GetStringF(IDS_SYNC_STOP_SYNCING_EXPLANATION_LABEL,
l10n_util::GetString(IDS_PRODUCT_NAME)));
localized_strings->SetString(L"stop_syncing_title",
l10n_util::GetString(IDS_SYNC_STOP_SYNCING_DIALOG_TITLE));
localized_strings->SetString(L"stop_syncing_confirm",
l10n_util::GetString(IDS_SYNC_STOP_SYNCING_CONFIRM_BUTTON_LABEL));
}
void StopSyncingHandler::RegisterMessages() {
DCHECK(dom_ui_);
dom_ui_->RegisterMessageCallback("stopSyncing",
NewCallback(this, &StopSyncingHandler::StopSyncing));
}
void StopSyncingHandler::StopSyncing(const Value* value){
DCHECK(dom_ui_);
ProfileSyncService* service = dom_ui_->GetProfile()->GetProfileSyncService();
if(service != NULL && ProfileSyncService::IsSyncEnabled()) {
service->DisableForUser();
ProfileSyncService::SyncEvent(ProfileSyncService::STOP_FROM_OPTIONS);
}
}
// Copyright (c) 2010 The Chromium Authors. All rights reserved.
// Use of this source code is governed by a BSD-style license that can be
// found in the LICENSE file.
#ifndef CHROME_BROWSER_DOM_UI_STOP_SYNCING_HANDLER_H_
#define CHROME_BROWSER_DOM_UI_STOP_SYNCING_HANDLER_H_
#include "chrome/browser/dom_ui/options_ui.h"
// Chrome personal stuff stop syncing overlay UI handler.
class StopSyncingHandler : public OptionsPageUIHandler {
public:
StopSyncingHandler();
virtual ~StopSyncingHandler();
// OptionsUIHandler implementation.
virtual void GetLocalizedValues(DictionaryValue* localized_strings);
// DOMMessageHandler implementation.
virtual void RegisterMessages();
private:
void StopSyncing(const Value* value);
DISALLOW_COPY_AND_ASSIGN(StopSyncingHandler);
};
#endif // CHROME_BROWSER_DOM_UI_STOP_SYNCING_HANDLER_H_
<div class="page hidden" id="importDataOverlay">
<h1 i18n-content="import_data_title"></h1>
<div>
<span i18n-content="import_from_label"></span>
<select id="supported-browsers"></select>
</div>
<div>
<span i18n-content="import_description"></span>
<label>
<input id="import-favorites" type="checkbox">
<span i18n-content="import_favorites">
</label><br>
<label>
<input id="import-search" type="checkbox">
<span i18n-content="import_search">
</label><br>
<label>
<input id="import-passwords" type="checkbox">
<span i18n-content="import_passwords">
</label><br>
<label>
<input id="import-history" type="checkbox">
<span i18n-content="import_history">
</label><br>
</div>
<button id="import-data-cancel" i18n-content="cancel"></button>
<button id="import-data-commit" i18n-content="import_commit"></button>
</div>
// Copyright (c) 2010 The Chromium Authors. All rights reserved.
// Use of this source code is governed by a BSD-style license that can be
// found in the LICENSE file.
/**
* ImportDataOverlay class
* Encapsulated handling of the 'Import Data' overlay page.
* @class
*/
function ImportDataOverlay() {
OptionsPage.call(this, 'importDataOverlay',
templateData.import_data_title,
'importDataOverlay');
}
cr.addSingletonGetter(ImportDataOverlay);
ImportDataOverlay.prototype = {
// Inherit ImportDataOverlay from OptionsPage.
__proto__: OptionsPage.prototype,
/**
* Initialize the page.
*/
initializePage: function() {
// Call base class implementation to starts preference initialization.
OptionsPage.prototype.initializePage.call(this);
$('import-data-cancel').onclick = function(e) {
OptionsPage.clearOverlays();
}
$('import-data-commit').onclick = function(e) {
var paramList = new Array();
}
},
/**
* Clear the supported browsers popup
* @private
*/
clearSupportedBrowsers_: function() {
$('supported-browsers').textContent = '';
},
/**
* Update the supported browsers popup with given entries.
* @param {Array} list of supported browsers name.
*/
updateSupportedBrowsers_: function(browsers) {
this.clearSupportedBrowsers_();
browserSelect = $('supported-browsers');
browserCount = browsers.length
for (var i = 0; i < browserCount; i++) {
var browser = browsers[i]
var option = new Option(browser['name'], browser['index']);
browserSelect.appendChild(option);
}
},
};
ImportDataOverlay.updateSupportedBrowsers = function(browsers) {
ImportDataOverlay.getInstance().updateSupportedBrowsers_(browsers);
}
<div class="page hidden" id="stopSyncingOverlay">
<h1 i18n-content="stop_syncing_title"></h1>
<div i18n-content="stop_syncing_explanation"></div>
<button id="stop-syncing-cancel" i18n-content="cancel"></button>
<button id="stop-syncing-confirm"
i18n-content="stop_syncing_confirm"></button>
</div>
// Copyright (c) 2010 The Chromium Authors. All rights reserved.
// Use of this source code is governed by a BSD-style license that can be
// found in the LICENSE file.
/**
* StopSyncingOverlay class
* Encapsulated handling of the 'Stop Syncing This Account' overlay page.
* @class
*/
function StopSyncingOverlay() {
OptionsPage.call(this, 'stopSyncingOverlay',
templateData.stop_syncing_title,
'stopSyncingOverlay');
}
cr.addSingletonGetter(StopSyncingOverlay);
StopSyncingOverlay.prototype = {
// Inherit StopSyncingOverlay from OptionsPage.
__proto__: OptionsPage.prototype,
/**
* Initialize the page.
*/
initializePage: function() {
// Call base class implementation to starts preference initialization.
OptionsPage.prototype.initializePage.call(this);
$('stop-syncing-cancel').onclick = function(e) {
OptionsPage.clearOverlays();
}
$('stop-syncing-confirm').onclick = function(e) {
chrome.send('stopSyncing');
OptionsPage.clearOverlays();
}
}
};
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