diff options
author | tim@chromium.org <tim@chromium.org@0039d316-1c4b-4281-b951-d872f2087c98> | 2009-08-20 18:08:16 +0000 |
---|---|---|
committer | tim@chromium.org <tim@chromium.org@0039d316-1c4b-4281-b951-d872f2087c98> | 2009-08-20 18:08:16 +0000 |
commit | ca38d8e05b6cbd729487c6ed619117ae7510e4c6 (patch) | |
tree | 7eb25a06ec77a3d590bcbe85a690d3e84a9e6bd8 /chrome/browser/sync | |
parent | a8c72ad420e48ee14106cc61340a3ce6064a3c2d (diff) | |
download | chromium_src-ca38d8e05b6cbd729487c6ed619117ae7510e4c6.zip chromium_src-ca38d8e05b6cbd729487c6ed619117ae7510e4c6.tar.gz chromium_src-ca38d8e05b6cbd729487c6ed619117ae7510e4c6.tar.bz2 |
Remove personalization.h/cc by putting things in final resting places
Review URL: http://codereview.chromium.org/173085
git-svn-id: svn://svn.chromium.org/chrome/trunk/src@23833 0039d316-1c4b-4281-b951-d872f2087c98
Diffstat (limited to 'chrome/browser/sync')
-rw-r--r-- | chrome/browser/sync/personalization.cc | 177 | ||||
-rw-r--r-- | chrome/browser/sync/personalization.h | 55 | ||||
-rw-r--r-- | chrome/browser/sync/profile_sync_service.cc | 1 | ||||
-rw-r--r-- | chrome/browser/sync/resources/new_tab_personalization.html | 117 |
4 files changed, 0 insertions, 350 deletions
diff --git a/chrome/browser/sync/personalization.cc b/chrome/browser/sync/personalization.cc deleted file mode 100644 index 866149f..0000000 --- a/chrome/browser/sync/personalization.cc +++ /dev/null @@ -1,177 +0,0 @@ -// Copyright (c) 2006-2008 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. - -#ifdef CHROME_PERSONALIZATION - -#include "chrome/browser/sync/personalization.h" - -#include "app/resource_bundle.h" -#include "base/command_line.h" -#include "base/file_path.h" -#include "base/file_util.h" -#include "base/path_service.h" -#include "base/string_util.h" -#include "chrome/app/chrome_dll_resource.h" -#include "chrome/browser/browser.h" -#include "chrome/browser/browser_process.h" -#include "chrome/browser/browser_url_handler.h" -#include "chrome/browser/command_updater.h" -#include "chrome/browser/dom_ui/new_tab_page_sync_handler.h" -#include "chrome/browser/options_window.h" -#include "chrome/browser/profile.h" -#include "chrome/browser/profile_manager.h" -#include "chrome/browser/sync/auth_error_state.h" -#include "chrome/browser/sync/personalization_strings.h" -#include "chrome/browser/sync/profile_sync_service.h" -#include "chrome/common/chrome_paths.h" -#include "chrome/common/chrome_switches.h" -#include "chrome/common/jstemplate_builder.h" -#include "chrome/common/notification_service.h" -#include "chrome/common/pref_service.h" -#include "chrome/common/url_constants.h" -#include "googleurl/src/gurl.h" -#include "grit/app_resources.h" -#include "grit/browser_resources.h" -#include "net/url_request/url_request.h" - -using sync_api::SyncManager; - -namespace Personalization { - -static std::wstring MakeAuthErrorText(AuthErrorState state) { - switch (state) { - case AUTH_ERROR_INVALID_GAIA_CREDENTIALS: - return L"INVALID_GAIA_CREDENTIALS"; - case AUTH_ERROR_USER_NOT_SIGNED_UP: - return L"USER_NOT_SIGNED_UP"; - case AUTH_ERROR_CONNECTION_FAILED: - return L"CONNECTION_FAILED"; - default: - return std::wstring(); - } -} - -bool NeedsDOMUI(const GURL& url) { - return url.SchemeIs(chrome::kChromeUIScheme) && - (url.path().find(chrome::kSyncGaiaLoginPath) != std::string::npos) || - (url.path().find(chrome::kSyncSetupFlowPath) != std::string::npos) || - (url.path().find(chrome::kSyncMergeAndSyncPath) != std::string::npos); -} - -DOMMessageHandler* CreateNewTabPageHandler(DOMUI* dom_ui) { - return (new NewTabPageSyncHandler())->Attach(dom_ui); -} - -std::string GetNewTabSource() { - static const StringPiece new_tab_html( - ResourceBundle::GetSharedInstance().GetRawDataResource( - IDR_NEW_TAB_P13N_HTML)); - - std::string data_uri("data:text/html,"); - data_uri.append(std::string(new_tab_html.data(), new_tab_html.size())); - return GURL(data_uri).spec(); -} - -std::wstring GetMenuItemInfoText(Browser* browser) { - browser->command_updater()->UpdateCommandEnabled(IDC_P13N_INFO, true); - return kMenuLabelStartSync; -} - -void HandleMenuItemClick(Profile* p) { - // The menu item is enabled either when the sync is not enabled by the user - // or when it's enabled but the user name is empty. In the former case enable - // sync. In the latter case, show the login dialog. - ProfileSyncService* service = p->GetProfileSyncService(); - if (!service) - return; // Incognito has no sync service (or TestingProfile, etc). - if (service->HasSyncSetupCompleted()) { - ShowOptionsWindow(OPTIONS_PAGE_CONTENT, OPTIONS_GROUP_NONE, p); - } else { - service->EnableForUser(); - ProfileSyncService::SyncEvent(ProfileSyncService::START_FROM_WRENCH); - } -} - -} // namespace Personalization - -namespace Personalization { - -static void AddBoolDetail(ListValue* details, const std::wstring& stat_name, - bool stat_value) { - DictionaryValue* val = new DictionaryValue; - val->SetString(L"stat_name", stat_name); - val->SetBoolean(L"stat_value", stat_value); - details->Append(val); -} - -static void AddIntDetail(ListValue* details, const std::wstring& stat_name, - int64 stat_value) { - DictionaryValue* val = new DictionaryValue; - val->SetString(L"stat_name", stat_name); - val->SetString(L"stat_value", FormatNumber(stat_value)); - details->Append(val); -} - -std::string AboutSync() { - FilePath user_data_dir; - if (!PathService::Get(chrome::DIR_USER_DATA, &user_data_dir)) - return std::string(); - ProfileManager* profile_manager = g_browser_process->profile_manager(); - Profile* profile = profile_manager->GetDefaultProfile(user_data_dir); - ProfileSyncService* service = profile->GetProfileSyncService(); - - DictionaryValue strings; - if (!service || !service->HasSyncSetupCompleted()) { - strings.SetString(L"summary", L"SYNC DISABLED"); - } else { - SyncManager::Status full_status(service->QueryDetailedSyncStatus()); - - strings.SetString(L"summary", - ProfileSyncService::BuildSyncStatusSummaryText( - full_status.summary)); - - strings.Set(L"authenticated", - new FundamentalValue(full_status.authenticated)); - strings.SetString(L"auth_problem", - MakeAuthErrorText(service->GetAuthErrorState())); - - strings.SetString(L"time_since_sync", service->GetLastSyncedTimeString()); - - ListValue* details = new ListValue(); - strings.Set(L"details", details); - AddBoolDetail(details, L"Server Up", full_status.server_up); - AddBoolDetail(details, L"Server Reachable", full_status.server_reachable); - AddBoolDetail(details, L"Server Broken", full_status.server_broken); - AddBoolDetail(details, L"Notifications Enabled", - full_status.notifications_enabled); - AddIntDetail(details, L"Notifications Received", - full_status.notifications_received); - AddIntDetail(details, L"Notifications Sent", - full_status.notifications_sent); - AddIntDetail(details, L"Unsynced Count", full_status.unsynced_count); - AddIntDetail(details, L"Conflicting Count", full_status.conflicting_count); - AddBoolDetail(details, L"Syncing", full_status.syncing); - AddBoolDetail(details, L"Syncer Paused", full_status.syncer_paused); - AddBoolDetail(details, L"Initial Sync Ended", - full_status.initial_sync_ended); - AddBoolDetail(details, L"Syncer Stuck", full_status.syncer_stuck); - AddIntDetail(details, L"Updates Available", full_status.updates_available); - AddIntDetail(details, L"Updates Received", full_status.updates_received); - AddBoolDetail(details, L"Disk Full", full_status.disk_full); - AddBoolDetail(details, L"Invalid Store", full_status.invalid_store); - AddIntDetail(details, L"Max Consecutive Errors", - full_status.max_consecutive_errors); - } - - static const StringPiece sync_html( - ResourceBundle::GetSharedInstance().GetRawDataResource( - IDR_ABOUT_SYNC_HTML)); - - return jstemplate_builder::GetTemplateHtml( - sync_html, &strings , "t" /* template root node id */); -} - -} // namespace Personalization - -#endif // CHROME_PERSONALIZATION diff --git a/chrome/browser/sync/personalization.h b/chrome/browser/sync/personalization.h deleted file mode 100644 index fb6a4ed..0000000 --- a/chrome/browser/sync/personalization.h +++ /dev/null @@ -1,55 +0,0 @@ -// Copyright (c) 2006-2008 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. - -#ifdef CHROME_PERSONALIZATION - -// TODO(timsteele): Remove this file by finding proper homes for everything in -// trunk. -#ifndef CHROME_BROWSER_SYNC_PERSONALIZATION_H_ -#define CHROME_BROWSER_SYNC_PERSONALIZATION_H_ - -#include <string> -#include "base/basictypes.h" -#include "chrome/browser/dom_ui/chrome_url_data_manager.h" - -class Browser; -class DOMUI; -class DOMMessageHandler; -class Profile; -class RenderView; -class RenderViewHost; -class WebFrame; -class WebView; - -class ProfileSyncService; -class ProfileSyncServiceObserver; - -namespace views { class View; } - -// Contains methods to perform Personalization-related tasks on behalf of the -// caller. -namespace Personalization { - -// Returns whether |url| should be loaded in a DOMUI. -bool NeedsDOMUI(const GURL& url); - -// Handler for "about:sync" -std::string AboutSync(); - -// Construct a new DOMMessageHandler for the new tab page |dom_ui|. -DOMMessageHandler* CreateNewTabPageHandler(DOMUI* dom_ui); - -// Get HTML for the Personalization iframe in the New Tab Page. -std::string GetNewTabSource(); - -// Returns the text for personalization info menu item and sets its enabled -// state. -std::wstring GetMenuItemInfoText(Browser* browser); - -// Performs appropriate action when the sync menu item is clicked. -void HandleMenuItemClick(Profile* p); -} // namespace Personalization - -#endif // CHROME_BROWSER_SYNC_PERSONALIZATION_H_ -#endif // CHROME_PERSONALIZATION diff --git a/chrome/browser/sync/profile_sync_service.cc b/chrome/browser/sync/profile_sync_service.cc index a426e53..0690273 100644 --- a/chrome/browser/sync/profile_sync_service.cc +++ b/chrome/browser/sync/profile_sync_service.cc @@ -22,7 +22,6 @@ #include "chrome/browser/history/history_types.h" #include "chrome/browser/profile.h" #include "chrome/browser/sync/engine/syncapi.h" -#include "chrome/browser/sync/personalization.h" #include "chrome/browser/sync/personalization_strings.h" #include "chrome/common/chrome_switches.h" #include "chrome/common/notification_service.h" diff --git a/chrome/browser/sync/resources/new_tab_personalization.html b/chrome/browser/sync/resources/new_tab_personalization.html deleted file mode 100644 index 73cf346..0000000 --- a/chrome/browser/sync/resources/new_tab_personalization.html +++ /dev/null @@ -1,117 +0,0 @@ -<html> -<head> -<style type="text/css"> -body { - font-family:arial; - background-color:white; - font-size:80%; - margin:0px; -} -.section-title { - color:#000; - line-height:19pt; - font-size:95%; - font-weight:bold; - margin-bottom:4px; - margin-left: 0px; -} -a { - color:#0000cc; - white-space: nowrap; -} -.sidebar { - width: 207px; - padding:3px 10px 3px 9px; - -webkit-border-radius:5px 5px; - margin-bottom:10px; -} -</style> -<script> -function resizeFrame(newsize) { - chrome.send("ResizeP13N", [newsize.toString()]); -} -</script> -</head> -<body> -<div id="sync" class="sidebar"> - <table id="titletable" width="200" cellpadding="0" cellspacing="0" - style="display:none"> - <tr> - <td id="messagetitle" align="left" class="section-title"> - </td> - <td align="right"> - <a href="#" onclick="resizeFrame(0);"> - <img id="greenclose" src="close.png"/> - </a> - </td> - </tr> - </table> - <div id="syncContainer"></div> -</div> -<script> -/* Return a DOM element with tag name |elem| and attributes |attrs|. */ -function DOM(elem, attrs) { - var elem = document.createElement(elem); - for (var attr in attrs) { - elem[attr] = attrs[attr]; - } - return elem; -} - -function renderSyncMessage(message) { - var section = document.getElementById('sync'); - var container = document.getElementById('syncContainer'); - var title = document.getElementById('messagetitle'); - var titletable = document.getElementById('titletable'); - container.innerHTML = ''; - title.innerHTML = ''; - titletable.style.display = "none"; - section.style.display = "block"; - - /* Set the sync section background color. */ - if (message.msgtype == "error") { - section.style.backgroundColor = "#f8d1ca"; - } else if (message.msgtype == "presynced") { - section.style.backgroundColor = "#e0f8ca"; - } else { - section.style.backgroundColor = "#e1ecfe"; - } - - if (message.msgtype != "synced") { - /* Any message except the status normal / synced to - message requires extra markup for a title, close button, - and links. */ - var titletxt = document.createTextNode(message.title); - title.appendChild(titletxt); - titletable.style.display = "block"; - } - - /* The main message of the sync section. */ - var txt = DOM('p'); - txt.style.margin = 0; - txt.appendChild(document.createTextNode(message.msg)); - container.appendChild(txt); - - /* If we should show a link, create the href. */ - if (message.linktext) { - var link = DOM('a', { href:"#", title: message.linktext}); - link.onclick = function(tt) { - return function() { - chrome.send("SyncLinkClicked", [tt]); - return false; - } - } (message.title); - - /* Tie it together. */ - link.appendChild(document.createTextNode(message.linktext)); - container.appendChild(link); - } - - /* Tell our container to resize to fit us appropriately. */ - resizeFrame(document.body.scrollHeight); -} - -chrome.send("GetSyncMessage"); -</script> -</body> -</html>
\ No newline at end of file |