summaryrefslogtreecommitdiffstats
path: root/chrome/browser/views/sync
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/sync
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/sync')
-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
4 files changed, 79 insertions, 25 deletions
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_));
}