summaryrefslogtreecommitdiffstats
path: root/chrome/browser/views
diff options
context:
space:
mode:
authortim@chromium.org <tim@chromium.org@0039d316-1c4b-4281-b951-d872f2087c98>2009-08-15 01:19:11 +0000
committertim@chromium.org <tim@chromium.org@0039d316-1c4b-4281-b951-d872f2087c98>2009-08-15 01:19:11 +0000
commit48352c11fe849f7f786c43bdfe293dc2c58d12c5 (patch)
tree57708d7e211d7cbcf2b81b1395740f5859a62aa1 /chrome/browser/views
parent20cc723d102acb16b61789714bbf443ba3d7d1f5 (diff)
downloadchromium_src-48352c11fe849f7f786c43bdfe293dc2c58d12c5.zip
chromium_src-48352c11fe849f7f786c43bdfe293dc2c58d12c5.tar.gz
chromium_src-48352c11fe849f7f786c43bdfe293dc2c58d12c5.tar.bz2
Some personalization cleanup:
- Removes ProfilePersonalization (which is why the CL appears huge) - Makes Profile do the work ProfilePersonalization did for creating PSS - cloudy:stats > about:sync - Removes the cloudy:// scheme and uses chrome:// for resources. (Note SyncResourcesSource is a straight copy of CloudyResourceSource). - Moves prefs and switches to pref_names and chrome_switches. BUG=none TEST=ProfileSyncServiceTest, LiveBookmarkSyncTests, SyncSetupWizardTest Review URL: http://codereview.chromium.org/164544 git-svn-id: svn://svn.chromium.org/chrome/trunk/src@23505 0039d316-1c4b-4281-b951-d872f2087c98
Diffstat (limited to 'chrome/browser/views')
-rw-r--r--chrome/browser/views/bookmark_bar_view.cc12
-rw-r--r--chrome/browser/views/options/content_page_view.cc14
-rw-r--r--chrome/browser/views/sync/sync_setup_flow.cc5
-rw-r--r--chrome/browser/views/sync/sync_setup_flow.h2
-rw-r--r--chrome/browser/views/sync/sync_setup_wizard.cc66
-rw-r--r--chrome/browser/views/sync/sync_setup_wizard_unittest.cc31
-rw-r--r--chrome/browser/views/toolbar_view.cc5
7 files changed, 92 insertions, 43 deletions
diff --git a/chrome/browser/views/bookmark_bar_view.cc b/chrome/browser/views/bookmark_bar_view.cc
index 1889e9a..28bdec8 100644
--- a/chrome/browser/views/bookmark_bar_view.cc
+++ b/chrome/browser/views/bookmark_bar_view.cc
@@ -409,12 +409,10 @@ BookmarkBarView::BookmarkBarView(Profile* profile, Browser* browser)
browser_(browser),
throbbing_view_(NULL) {
#ifdef CHROME_PERSONALIZATION
- // Obtain a pointer to the profile sync service and add our instance as an
- // observer.
- ProfilePersonalization* profile_p13n = profile->GetProfilePersonalization();
- if (profile_p13n) {
- sync_service_ = profile_p13n->sync_service();
- DCHECK(sync_service_);
+ if (profile->GetProfileSyncService()) {
+ // Obtain a pointer to the profile sync service and add our instance as an
+ // observer.
+ sync_service_ = profile->GetProfileSyncService();
sync_service_->AddObserver(this);
}
#endif
@@ -1862,7 +1860,7 @@ void BookmarkBarView::UpdateButtonColors() {
// not the re-login indicator button should be visible.
bool BookmarkBarView::ShouldShowSyncErrorButton() {
bool show_sync_error_button(false);
- if (sync_service_ && sync_service_->IsSyncEnabledByUser()) {
+ if (sync_service_ && sync_service_->HasSyncSetupCompleted()) {
std::wstring status_text;
std::wstring link_text;
SyncStatusUIHelper::MessageType sync_status;
diff --git a/chrome/browser/views/options/content_page_view.cc b/chrome/browser/views/options/content_page_view.cc
index af2a4df..4a1c932 100644
--- a/chrome/browser/views/options/content_page_view.cc
+++ b/chrome/browser/views/options/content_page_view.cc
@@ -69,13 +69,11 @@ ContentPageView::ContentPageView(Profile* profile)
#endif
OptionsPageView(profile) {
#ifdef CHROME_PERSONALIZATION
- ProfilePersonalization* profile_p13n = profile->GetProfilePersonalization();
- if (profile_p13n) {
- sync_service_ = profile_p13n->sync_service();
- DCHECK(sync_service_);
+ if (profile->GetProfileSyncService()) {
+ sync_service_ = profile->GetProfileSyncService();
sync_service_->AddObserver(this);
- }
#endif
+ }
}
ContentPageView::~ContentPageView() {
@@ -135,7 +133,7 @@ void ContentPageView::ButtonPressed(views::Button* sender) {
#ifdef CHROME_PERSONALIZATION
} else if (sender == sync_start_stop_button_) {
DCHECK(sync_service_);
- if (sync_service_->IsSyncEnabledByUser()) {
+ if (sync_service_->HasSyncSetupCompleted()) {
sync_service_->DisableForUser();
ProfileSyncService::SyncEvent(ProfileSyncService::STOP_FROM_OPTIONS);
} else {
@@ -457,10 +455,10 @@ void ContentPageView::UpdateSyncControls() {
std::wstring status_label;
std::wstring link_label;
std::wstring button_label;
- bool sync_enabled = sync_service_->IsSyncEnabledByUser();
+ bool sync_setup_completed = sync_service_->HasSyncSetupCompleted();
bool status_has_error = SyncStatusUIHelper::GetLabels(sync_service_,
&status_label, &link_label) == SyncStatusUIHelper::SYNC_ERROR;
- button_label = sync_enabled ? kStopSyncButtonLabel :
+ button_label = sync_setup_completed ? kStopSyncButtonLabel :
sync_service_->SetupInProgress() ? UTF8ToWide(kSettingUpText)
: kStartSyncButtonLabel;
diff --git a/chrome/browser/views/sync/sync_setup_flow.cc b/chrome/browser/views/sync/sync_setup_flow.cc
index c0386a3..5eb2423 100644
--- a/chrome/browser/views/sync/sync_setup_flow.cc
+++ b/chrome/browser/views/sync/sync_setup_flow.cc
@@ -16,7 +16,6 @@
#include "chrome/browser/sync/profile_sync_service.h"
#include "chrome/browser/tab_contents/tab_contents.h"
#include "chrome/browser/views/sync/sync_setup_flow.h"
-#include "chrome/common/pref_service.h"
static const int kSyncDialogWidth = 270;
static const int kSyncDialogHeight = 369;
@@ -139,9 +138,7 @@ void SyncSetupFlow::OnDialogClosed(const std::string& json_retval) {
DCHECK(json_retval.empty());
container_->set_flow(NULL); // Sever ties from the wizard.
if (current_state_ == SyncSetupWizard::DONE) {
- PrefService* prefs = service_->profile()->GetPrefs();
- prefs->SetBoolean(prefs::kSyncHasSetupCompleted, true);
- prefs->ScheduleSavePersistentPrefs();
+ service_->SetSyncSetupCompleted();
}
// Record the state at which the user cancelled the signon dialog.
diff --git a/chrome/browser/views/sync/sync_setup_flow.h b/chrome/browser/views/sync/sync_setup_flow.h
index 6412a74..1e22cf0 100644
--- a/chrome/browser/views/sync/sync_setup_flow.h
+++ b/chrome/browser/views/sync/sync_setup_flow.h
@@ -44,7 +44,7 @@ class SyncSetupFlow : public HtmlDialogUIDelegate {
// HtmlDialogUIDelegate implementation.
// Get the HTML file path for the content to load in the dialog.
virtual GURL GetDialogContentURL() const {
- return GURL("cloudy://resources/setup");
+ return GURL("chrome://syncresources/setup");
}
// HtmlDialogUIDelegate implementation.
diff --git a/chrome/browser/views/sync/sync_setup_wizard.cc b/chrome/browser/views/sync/sync_setup_wizard.cc
index 18ef7b8..2e86bfd 100644
--- a/chrome/browser/views/sync/sync_setup_wizard.cc
+++ b/chrome/browser/views/sync/sync_setup_wizard.cc
@@ -6,12 +6,78 @@
#include "chrome/browser/views/sync/sync_setup_wizard.h"
+#include "app/resource_bundle.h"
+#include "base/message_loop.h"
+#include "chrome/common/pref_names.h"
#include "chrome/common/pref_service.h"
+#include "chrome/browser/browser_process.h"
+#include "chrome/browser/dom_ui/chrome_url_data_manager.h"
#include "chrome/browser/sync/profile_sync_service.h"
#include "chrome/browser/views/sync/sync_setup_flow.h"
+#include "chrome/common/url_constants.h"
+#include "grit/app_resources.h"
+#include "grit/browser_resources.h"
+
+class SyncResourcesSource : public ChromeURLDataManager::DataSource {
+ public:
+ SyncResourcesSource()
+ : DataSource(chrome::kSyncResourcesPath, MessageLoop::current()) {
+ }
+ virtual ~SyncResourcesSource() { }
+
+ virtual void StartDataRequest(const std::string& path, int request_id);
+
+ virtual std::string GetMimeType(const std::string& path) const {
+ if (path == chrome::kSyncThrobberPath)
+ return "image/png";
+ else
+ return "text/html";
+ }
+ private:
+ DISALLOW_COPY_AND_ASSIGN(SyncResourcesSource);
+};
+
+void SyncResourcesSource::StartDataRequest(const std::string& path_raw,
+ int request_id) {
+ scoped_refptr<RefCountedBytes> html_bytes(new RefCountedBytes);
+ if (path_raw == chrome::kSyncThrobberPath) {
+ ResourceBundle::GetSharedInstance().LoadImageResourceBytes(IDR_THROBBER,
+ &html_bytes->data);
+ SendResponse(request_id, html_bytes);
+ return;
+ }
+
+ std::string response;
+ if (path_raw == chrome::kSyncGaiaLoginPath) {
+ static const StringPiece html(ResourceBundle::GetSharedInstance()
+ .GetRawDataResource(IDR_GAIA_LOGIN_HTML));
+ response = html.as_string();
+ } else if (path_raw == chrome::kSyncMergeAndSyncPath) {
+ static const StringPiece html(ResourceBundle::GetSharedInstance()
+ .GetRawDataResource(IDR_MERGE_AND_SYNC_HTML));
+ response = html.as_string();
+ } else if (path_raw == chrome::kSyncSetupFlowPath) {
+ static const StringPiece html(ResourceBundle::GetSharedInstance()
+ .GetRawDataResource(IDR_SYNC_SETUP_FLOW_HTML));
+ response = html.as_string();
+ }
+ // Send the response.
+ html_bytes->data.resize(response.size());
+ std::copy(response.begin(), response.end(), html_bytes->data.begin());
+ SendResponse(request_id, html_bytes);
+}
SyncSetupWizard::SyncSetupWizard(ProfileSyncService* service)
: service_(service), flow_container_(new SyncSetupFlowContainer()) {
+ // Register data sources for HTML content we require.
+ // g_browser_process and/or io_thread may not exist during testing.
+ if (g_browser_process && g_browser_process->io_thread()) {
+ // Add our network layer data source for 'cloudy' URLs.
+ g_browser_process->io_thread()->message_loop()->PostTask(FROM_HERE,
+ NewRunnableMethod(&chrome_url_data_manager,
+ &ChromeURLDataManager::AddDataSource,
+ new SyncResourcesSource()));
+ }
}
SyncSetupWizard::~SyncSetupWizard() {
diff --git a/chrome/browser/views/sync/sync_setup_wizard_unittest.cc b/chrome/browser/views/sync/sync_setup_wizard_unittest.cc
index 75afa11..88dae75 100644
--- a/chrome/browser/views/sync/sync_setup_wizard_unittest.cc
+++ b/chrome/browser/views/sync/sync_setup_wizard_unittest.cc
@@ -14,6 +14,8 @@
#include "chrome/browser/sync/profile_sync_service.h"
#include "chrome/browser/views/sync/sync_setup_flow.h"
#include "chrome/browser/views/sync/sync_setup_wizard.h"
+#include "chrome/common/pref_names.h"
+#include "chrome/common/pref_service.h"
#include "chrome/test/browser_with_test_window_test.h"
#include "chrome/test/testing_profile.h"
#include "chrome/test/test_browser_window.h"
@@ -27,6 +29,7 @@ class ProfileSyncServiceForWizardTest : public ProfileSyncService {
explicit ProfileSyncServiceForWizardTest(Profile* profile)
: ProfileSyncService(profile), user_accepted_merge_and_sync_(false),
user_cancelled_dialog_(false) {
+ RegisterPreferences();
}
virtual ~ProfileSyncServiceForWizardTest() { }
@@ -68,27 +71,17 @@ class ProfileSyncServiceForWizardTest : public ProfileSyncService {
DISALLOW_COPY_AND_ASSIGN(ProfileSyncServiceForWizardTest);
};
-class ProfilePersonalizationTestImpl : public ProfilePersonalization {
+class TestingProfileWithSyncService : public TestingProfile {
public:
- explicit ProfilePersonalizationTestImpl(Profile* p)
- : sync_service_(new ProfileSyncServiceForWizardTest(p)) {
+ TestingProfileWithSyncService() {
+ sync_service_.reset(new ProfileSyncServiceForWizardTest(this));
}
- virtual ProfileSyncService* sync_service() { return sync_service_.get(); }
- private:
- scoped_ptr<ProfileSyncService> sync_service_;
-};
-class TestingProfileWithPersonalization : public TestingProfile {
- public:
- TestingProfileWithPersonalization() {
- personalization_.reset(new ProfilePersonalizationTestImpl(this));
- }
-
- virtual ProfilePersonalization* GetProfilePersonalization() {
- return personalization_.get();
+ virtual ProfileSyncService* GetProfileSyncService() {
+ return sync_service_.get();
}
private:
- scoped_ptr<ProfilePersonalization> personalization_;
+ scoped_ptr<ProfileSyncService> sync_service_;
};
class TestBrowserWindowForWizardTest : public TestBrowserWindow {
@@ -154,19 +147,17 @@ class SyncSetupWizardTest : public BrowserWithTestWindowTest {
SyncSetupWizardTest() : test_window_(NULL), wizard_(NULL) { }
virtual ~SyncSetupWizardTest() { }
virtual void SetUp() {
- set_profile(new TestingProfileWithPersonalization());
+ set_profile(new TestingProfileWithSyncService());
profile()->CreateBookmarkModel(false);
// Wait for the bookmarks model to load.
profile()->BlockUntilBookmarkModelLoaded();
- profile()->GetPrefs()->RegisterBooleanPref(prefs::kSyncHasSetupCompleted,
- false);
set_browser(new Browser(Browser::TYPE_NORMAL, profile()));
test_window_ = new TestBrowserWindowForWizardTest(browser());
set_window(test_window_);
browser()->set_window(window());
BrowserList::SetLastActive(browser());
service_ = static_cast<ProfileSyncServiceForWizardTest*>(
- profile()->GetProfilePersonalization()->sync_service());
+ profile()->GetProfileSyncService());
wizard_.reset(new SyncSetupWizard(service_));
}
diff --git a/chrome/browser/views/toolbar_view.cc b/chrome/browser/views/toolbar_view.cc
index dce39b1..6d0b8cf 100644
--- a/chrome/browser/views/toolbar_view.cc
+++ b/chrome/browser/views/toolbar_view.cc
@@ -1085,9 +1085,8 @@ void ToolbarView::CreateAppMenu() {
IDS_SHOW_DOWNLOADS);
app_menu_contents_->AddSeparator();
#ifdef CHROME_PERSONALIZATION
- if (Personalization::IsSyncEnabled(profile_)) {
- app_menu_contents_->AddItem(
- IDC_P13N_INFO,
+ if (CommandLine::ForCurrentProcess()->HasSwitch(switches::kEnableSync)) {
+ app_menu_contents_->AddItem(IDC_P13N_INFO,
Personalization::GetMenuItemInfoText(browser()));
}
#endif