diff options
author | sail@chromium.org <sail@chromium.org@0039d316-1c4b-4281-b951-d872f2087c98> | 2012-03-20 22:22:22 +0000 |
---|---|---|
committer | sail@chromium.org <sail@chromium.org@0039d316-1c4b-4281-b951-d872f2087c98> | 2012-03-20 22:22:22 +0000 |
commit | ea423a68cc76c7d6133bbfcd6d7630d8e8d29b1a (patch) | |
tree | 791560159efc2078426eeb083a74a700edb129aa /chrome | |
parent | 6f4fa5151be236013c97bfc266f8f7b328826231 (diff) | |
download | chromium_src-ea423a68cc76c7d6133bbfcd6d7630d8e8d29b1a.zip chromium_src-ea423a68cc76c7d6133bbfcd6d7630d8e8d29b1a.tar.gz chromium_src-ea423a68cc76c7d6133bbfcd6d7630d8e8d29b1a.tar.bz2 |
Remove experimental sync promo layouts
We added four experimental sync promo layouts for M18. The experiment is now over and we've decided to use layout 3 (simple version).
This CL removes the experimental layouts from the C++ code. I'll send out a second CL to remove the DOM UI code.
BUG=119014
TEST=
Review URL: http://codereview.chromium.org/9730021
git-svn-id: svn://svn.chromium.org/chrome/trunk/src@127813 0039d316-1c4b-4281-b951-d872f2087c98
Diffstat (limited to 'chrome')
18 files changed, 17 insertions, 690 deletions
diff --git a/chrome/browser/chrome_browser_main.cc b/chrome/browser/chrome_browser_main.cc index c0aa18e..70e791f 100644 --- a/chrome/browser/chrome_browser_main.cc +++ b/chrome/browser/chrome_browser_main.cc @@ -80,7 +80,6 @@ #include "chrome/browser/ui/browser_init.h" #include "chrome/browser/ui/webui/chrome_url_data_manager_backend.h" #include "chrome/browser/ui/webui/ntp/new_tab_ui.h" -#include "chrome/browser/ui/webui/sync_promo/sync_promo_trial.h" #include "chrome/common/child_process_logging.h" #include "chrome/common/chrome_constants.h" #include "chrome/common/chrome_paths.h" @@ -1028,7 +1027,6 @@ void ChromeBrowserMainParts::SetupFieldTrials(bool metrics_recording_enabled, DefaultAppsFieldTrial(); AutoLaunchChromeFieldTrial(); AutocompleteFieldTrial::Activate(); - sync_promo_trial::Activate(); NewTabUI::SetupFieldTrials(); } diff --git a/chrome/browser/ui/browser_init.cc b/chrome/browser/ui/browser_init.cc index 82cc367..29b953d 100644 --- a/chrome/browser/ui/browser_init.cc +++ b/chrome/browser/ui/browser_init.cc @@ -68,14 +68,11 @@ #include "chrome/browser/tab_contents/simple_alert_infobar_delegate.h" #include "chrome/browser/tabs/pinned_tab_codec.h" #include "chrome/browser/tabs/tab_strip_model.h" -#include "chrome/browser/ui/browser_dialogs.h" #include "chrome/browser/ui/browser_list.h" #include "chrome/browser/ui/browser_navigator.h" #include "chrome/browser/ui/browser_window.h" -#include "chrome/browser/ui/dialog_style.h" #include "chrome/browser/ui/tab_contents/tab_contents_wrapper.h" #include "chrome/browser/ui/webui/ntp/app_launcher_handler.h" -#include "chrome/browser/ui/webui/sync_promo/sync_promo_dialog.h" #include "chrome/browser/ui/webui/sync_promo/sync_promo_trial.h" #include "chrome/browser/ui/webui/sync_promo/sync_promo_ui.h" #include "chrome/common/chrome_constants.h" @@ -1246,8 +1243,8 @@ Browser* BrowserInit::LaunchWithProfile::OpenURLsInBrowser( Browser* BrowserInit::LaunchWithProfile::OpenTabsInBrowser( Browser* browser, bool process_startup, - const std::vector<Tab>& in_tabs) { - DCHECK(!in_tabs.empty()); + const std::vector<Tab>& tabs) { + DCHECK(!tabs.empty()); // If we don't yet have a profile, try to use the one we're given from // |browser|. While we may not end up actually using |browser| (since it @@ -1255,11 +1252,6 @@ Browser* BrowserInit::LaunchWithProfile::OpenTabsInBrowser( if (!profile_ && browser) profile_ = browser->profile(); - std::vector<Tab> tabs(in_tabs); - size_t active_tab_index = - ShowSyncPromoDialog(process_startup, &browser, &tabs); - bool first_tab = active_tab_index == std::string::npos; - if (!browser || !browser->is_type_tabbed()) { browser = Browser::Create(profile_); } else { @@ -1277,6 +1269,7 @@ Browser* BrowserInit::LaunchWithProfile::OpenTabsInBrowser( browser->ToggleFullscreenMode(); #endif + bool first_tab = true; for (size_t i = 0; i < tabs.size(); ++i) { // We skip URLs that we'd have to launch an external protocol handler for. // This avoids us getting into an infinite loop asking ourselves to open @@ -1288,27 +1281,17 @@ Browser* BrowserInit::LaunchWithProfile::OpenTabsInBrowser( if (!process_startup && !handled_by_chrome) continue; - size_t index; - if (tabs[i].url.SchemeIs(chrome::kChromeUIScheme) && - tabs[i].url.host() == chrome::kChromeUISyncPromoHost) { - // The sync promo must always be the first tab. If the browser window - // was spawned from the sync promo dialog then it might have other tabs - // in it already. Explicilty set it to 0 to ensure that it's first. - index = 0; - } else { - index = browser->GetIndexForInsertionDuringRestore(i); - } - - int add_types = (first_tab || index == active_tab_index) ? - TabStripModel::ADD_ACTIVE : TabStripModel::ADD_NONE; + int add_types = first_tab ? TabStripModel::ADD_ACTIVE : + TabStripModel::ADD_NONE; add_types |= TabStripModel::ADD_FORCE_INDEX; if (tabs[i].is_pinned) add_types |= TabStripModel::ADD_PINNED; + int index = browser->GetIndexForInsertionDuringRestore(i); browser::NavigateParams params(browser, tabs[i].url, content::PAGE_TRANSITION_START_PAGE); - params.disposition = (first_tab || index == active_tab_index) ? - NEW_FOREGROUND_TAB : NEW_BACKGROUND_TAB; + params.disposition = first_tab ? NEW_FOREGROUND_TAB : + NEW_BACKGROUND_TAB; params.tabstrip_index = index; params.tabstrip_add_types = add_types; params.extension_app_id = tabs[i].app_id; @@ -1516,9 +1499,7 @@ void BrowserInit::LaunchWithProfile::AddStartupURLs( // If the sync promo page is going to be displayed then insert it at the front // of the list. - bool promo_suppressed = false; - if (SyncPromoUI::ShouldShowSyncPromoAtStartup(profile_, is_first_run_, - &promo_suppressed)) { + if (SyncPromoUI::ShouldShowSyncPromoAtStartup(profile_, is_first_run_)) { SyncPromoUI::DidShowSyncPromoAtStartup(profile_); GURL old_url = (*startup_urls)[0]; (*startup_urls)[0] = @@ -1542,8 +1523,6 @@ void BrowserInit::LaunchWithProfile::AddStartupURLs( if (it != startup_urls->end()) startup_urls->erase(it); } - } else if (promo_suppressed) { - sync_promo_trial::RecordSyncPromoSuppressedForCurrentTrial(); } } @@ -1604,49 +1583,6 @@ bool BrowserInit::LaunchWithProfile::CheckIfAutoLaunched(Profile* profile) { return false; } -size_t BrowserInit::LaunchWithProfile::ShowSyncPromoDialog( - bool process_startup, - Browser** browser, - std::vector<Tab>* tabs) { - DCHECK(browser); - DCHECK(tabs); - - // The dialog is only shown on process startup if no browser window is already - // being displayed. - if (!profile_ || profile_->IsOffTheRecord() || *browser || !process_startup || - SyncPromoUI::GetSyncPromoVersion() != SyncPromoUI::VERSION_DIALOG) { - return std::string::npos; - } - - for (size_t i = 0; i < tabs->size(); ++i) { - GURL url((*tabs)[i].url); - if (url.SchemeIs(chrome::kChromeUIScheme) && - url.host() == chrome::kChromeUISyncPromoHost) { - SyncPromoDialog dialog(profile_, url); - dialog.ShowDialog(); - *browser = dialog.spawned_browser(); - if (!*browser) { - // If no browser window was spawned then just replace the sync promo - // with the next URL. - (*tabs)[i].url = SyncPromoUI::GetNextPageURLForSyncPromoURL(url); - return i; - } else if (dialog.sync_promo_was_closed()) { - tabs->erase(tabs->begin() + i); - // The tab spawned by the dialog is at tab index 0 so return 0 to make - // it the active tab. - return 0; - } else { - // Since the sync promo is not closed it will be inserted at tab - // index 0. The tab spawned by the dialog will be at index 1 so return - // 0 to make it the active tab. - return 1; - } - } - } - - return std::string::npos; -} - std::vector<GURL> BrowserInit::GetURLsFromCommandLine( const CommandLine& command_line, const FilePath& cur_dir, diff --git a/chrome/browser/ui/browser_init.h b/chrome/browser/ui/browser_init.h index a12df57..29a2f5f 100644 --- a/chrome/browser/ui/browser_init.h +++ b/chrome/browser/ui/browser_init.h @@ -238,16 +238,6 @@ class BrowserInit { // Returns true if so. bool CheckIfAutoLaunched(Profile* profile); - // Shows a sync promo dialog if necessary. When called |browser| should be - // the browser that's being used for startup. On return |browser| is set - // to the browser spawned from the sync promo dialog (if any). On input - // |tabs| should be the set of tabs to show on startup. On return |tabs| - // will contain the new set of tabs to show on startup. Returns the index - // of the tab to activate. - size_t ShowSyncPromoDialog(bool process_startup, - Browser** browser, - std::vector<Tab>* tabs); - const FilePath cur_dir_; const CommandLine& command_line_; Profile* profile_; diff --git a/chrome/browser/ui/webui/sync_promo/sync_promo_dialog.cc b/chrome/browser/ui/webui/sync_promo/sync_promo_dialog.cc deleted file mode 100644 index 038f91f..0000000 --- a/chrome/browser/ui/webui/sync_promo/sync_promo_dialog.cc +++ /dev/null @@ -1,117 +0,0 @@ -// Copyright (c) 2012 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/ui/webui/sync_promo/sync_promo_dialog.h" - -#include "base/bind.h" -#include "base/message_loop.h" -#include "chrome/browser/ui/browser_dialogs.h" -#include "chrome/browser/ui/webui/html_dialog_tab_contents_delegate.h" -#include "chrome/browser/ui/webui/sync_promo/sync_promo_ui.h" -#include "content/public/browser/page_navigator.h" -#include "grit/chromium_strings.h" -#include "grit/generated_resources.h" -#include "ui/base/l10n/l10n_util.h" -#include "ui/gfx/size.h" - -SyncPromoDialog::SyncPromoDialog(Profile* profile, GURL url) - : profile_(profile), - spawned_browser_(NULL), - sync_promo_was_closed_(false), - url_(url), - window_(NULL) { -} - -SyncPromoDialog::~SyncPromoDialog() { -} - -void SyncPromoDialog::ShowDialog() { - window_ = browser::ShowHtmlDialog(NULL, profile_, NULL, this, STYLE_GENERIC); - - // Wait for the dialog to close. - MessageLoop::current()->Run(); -} - -ui::ModalType SyncPromoDialog::GetDialogModalType() const { - return ui::MODAL_TYPE_SYSTEM; -} - -string16 SyncPromoDialog::GetDialogTitle() const { - return l10n_util::GetStringFUTF16( - IDS_SYNC_PROMO_TITLE, - l10n_util::GetStringUTF16(IDS_PRODUCT_NAME)); -} - -GURL SyncPromoDialog::GetDialogContentURL() const { - return url_; -} - -void SyncPromoDialog::GetWebUIMessageHandlers( - std::vector<content::WebUIMessageHandler*>* handlers) const { -} - -void SyncPromoDialog::GetDialogSize(gfx::Size* size) const { - DCHECK(size); - const int kDialogWidth = 530; - const int kDialogHeight = 540; - *size = gfx::Size(kDialogWidth, kDialogHeight); -} - -std::string SyncPromoDialog::GetDialogArgs() const { - return std::string(); -} - -void SyncPromoDialog::OnDialogClosed(const std::string& json_retval) { - MessageLoop::current()->Quit(); -} - -void SyncPromoDialog::OnCloseContents(content::WebContents* source, - bool* out_close_dialog) { -} - -bool SyncPromoDialog::ShouldShowDialogTitle() const { - return true; -} - -bool SyncPromoDialog::HandleContextMenu( - const content::ContextMenuParams& params) { - return true; -} - -bool SyncPromoDialog::HandleOpenURLFromTab( - content::WebContents* source, - const content::OpenURLParams& params, - content::WebContents** out_new_contents) { - spawned_browser_ = HtmlDialogTabContentsDelegate::StaticOpenURLFromTab( - profile_, source, params, out_new_contents); - // If the open URL request is for the current tab then that means the sync - // promo page will be closed. - sync_promo_was_closed_ = params.disposition == CURRENT_TAB; - CloseDialog(); - return true; -} - -bool SyncPromoDialog::HandleAddNewContents( - content::WebContents* source, - content::WebContents* new_contents, - WindowOpenDisposition disposition, - const gfx::Rect& initial_pos, - bool user_gesture) { - spawned_browser_ = HtmlDialogTabContentsDelegate::StaticAddNewContents( - profile_, source, new_contents, disposition, initial_pos, user_gesture); - CloseDialog(); - return true; -} - -void SyncPromoDialog::CloseDialog() { - // Only close the window once. - if (!window_) - return; - - // Close the dialog asynchronously since closing it will cause this and other - // WebUI handlers to be deleted. - MessageLoop::current()->PostTask( - FROM_HERE, base::Bind(browser::CloseHtmlDialog, window_)); - window_ = NULL; -} diff --git a/chrome/browser/ui/webui/sync_promo/sync_promo_dialog.h b/chrome/browser/ui/webui/sync_promo/sync_promo_dialog.h deleted file mode 100644 index ca1f2c0..0000000 --- a/chrome/browser/ui/webui/sync_promo/sync_promo_dialog.h +++ /dev/null @@ -1,76 +0,0 @@ -// Copyright (c) 2012 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_UI_WEBUI_SYNC_PROMO_SYNC_PROMO_DIALOG_H_ -#define CHROME_BROWSER_UI_WEBUI_SYNC_PROMO_SYNC_PROMO_DIALOG_H_ -#pragma once - -#include "chrome/browser/ui/webui/html_dialog_ui.h" - -class Profile; -class Browser; - -// Shows the sync promo in an HTML dialog. -class SyncPromoDialog : public HtmlDialogUIDelegate { - public: - // |profile| is the profile that should own the HTML dialog. |url| is the - // URL to display inside the dialog. - SyncPromoDialog(Profile* profile, GURL url); - virtual ~SyncPromoDialog(); - - // Shows the dialog and blocks until the dialog is dismissed. - void ShowDialog(); - - // Returns the browser spawned from the sync promo dialog (if any). - Browser* spawned_browser() const { return spawned_browser_; } - - // Returns true if the sync promo was closed. - bool sync_promo_was_closed() const { return sync_promo_was_closed_; } - - // Returns the dialog window. - gfx::NativeWindow window() const { return window_; } - - private: - // HtmlDialogUIDelegate: - virtual ui::ModalType GetDialogModalType() const OVERRIDE; - virtual string16 GetDialogTitle() const OVERRIDE; - virtual GURL GetDialogContentURL() const OVERRIDE; - virtual void GetWebUIMessageHandlers( - std::vector<content::WebUIMessageHandler*>* handlers) const OVERRIDE; - virtual void GetDialogSize(gfx::Size* size) const OVERRIDE; - virtual std::string GetDialogArgs() const OVERRIDE; - virtual void OnDialogClosed(const std::string& json_retval) OVERRIDE; - virtual void OnCloseContents(content::WebContents* source, - bool* out_close_dialog) OVERRIDE; - virtual bool ShouldShowDialogTitle() const OVERRIDE; - virtual bool HandleContextMenu( - const content::ContextMenuParams& params) OVERRIDE; - virtual bool HandleOpenURLFromTab( - content::WebContents* source, - const content::OpenURLParams& params, - content::WebContents** out_new_contents) OVERRIDE; - virtual bool HandleAddNewContents(content::WebContents* source, - content::WebContents* new_contents, - WindowOpenDisposition disposition, - const gfx::Rect& initial_pos, - bool user_gesture) OVERRIDE; - - // Close this dialog. - void CloseDialog(); - - // The profile that should own the HTML dialog. - Profile* profile_; - // The browser spawned from the sync promo dialog (if any). - Browser* spawned_browser_; - // This is set to true if the sync promo was closed. - bool sync_promo_was_closed_; - // The URL to dispaly in the HTML dialog. - GURL url_; - // The dialog window. - gfx::NativeWindow window_; - - DISALLOW_COPY_AND_ASSIGN(SyncPromoDialog); -}; - -#endif // CHROME_BROWSER_UI_WEBUI_SYNC_PROMO_SYNC_PROMO_DIALOG_H_ diff --git a/chrome/browser/ui/webui/sync_promo/sync_promo_dialog_browsertest.cc b/chrome/browser/ui/webui/sync_promo/sync_promo_dialog_browsertest.cc deleted file mode 100644 index 4e66d378..0000000 --- a/chrome/browser/ui/webui/sync_promo/sync_promo_dialog_browsertest.cc +++ /dev/null @@ -1,82 +0,0 @@ -// Copyright (c) 2012 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/ui/webui/sync_promo/sync_promo_dialog.h" - -#include "base/bind.h" -#include "base/message_loop.h" -#include "chrome/browser/ui/browser.h" -#include "chrome/browser/ui/browser_dialogs.h" -#include "chrome/browser/ui/webui/sync_promo/sync_promo_ui.h" -#include "chrome/test/base/in_process_browser_test.h" -#include "content/public/browser/web_contents.h" - -namespace { - -GURL GetSyncPromoURL() { - return SyncPromoUI::GetSyncPromoURL(GURL("http://a/"), true, ""); -} - -void OpenLink(content::WebContents* source) { - content::Referrer referrer(GURL(), WebKit::WebReferrerPolicyAlways); - content::OpenURLParams params(GURL("http://b/"), referrer, NEW_FOREGROUND_TAB, - content::PAGE_TRANSITION_LINK, true); - source->GetDelegate()->OpenURLFromTab(source, params); -} - -class TestSyncPromoDialog : public SyncPromoDialog { - public: - TestSyncPromoDialog(Profile* profile, GURL url) - : SyncPromoDialog(profile, url), - on_load_close_(false), - on_load_open_link_(false) { - } - - void set_on_load_close(bool flag) { on_load_close_ = flag; } - void set_on_load_open_link(bool flag) { on_load_open_link_ = flag; } - - virtual void OnLoadingStateChanged(content::WebContents* source) OVERRIDE { - if (!source || source->IsLoading()) - return; - if (on_load_close_) { - MessageLoop::current()->PostTask( - FROM_HERE, base::Bind(&browser::CloseHtmlDialog, window())); - } else if (on_load_open_link_) { - MessageLoop::current()->PostTask( - FROM_HERE, base::Bind(&OpenLink, source)); - } - } - - private: - bool on_load_close_; - bool on_load_open_link_; -}; - -typedef InProcessBrowserTest SyncPromoDialogBrowserTest; - -// Test that closing the dialog window spawns a new browser and end the modal -// session. -IN_PROC_BROWSER_TEST_F(SyncPromoDialogBrowserTest, Close) { - TestSyncPromoDialog dialog(browser()->profile(), GetSyncPromoURL()); - SyncPromoUI::DidShowSyncPromoAtStartup(browser()->profile()); - dialog.set_on_load_close(true); - dialog.ShowDialog(); - - EXPECT_FALSE(dialog.spawned_browser()); - EXPECT_FALSE(dialog.sync_promo_was_closed()); -} - -// Test that clicking a link in the dialog window spawns a new browser window -// and ends the modal session. -IN_PROC_BROWSER_TEST_F(SyncPromoDialogBrowserTest, OpenLink) { - TestSyncPromoDialog dialog(browser()->profile(), GetSyncPromoURL()); - SyncPromoUI::DidShowSyncPromoAtStartup(browser()->profile()); - dialog.set_on_load_open_link(true); - dialog.ShowDialog(); - - EXPECT_TRUE(dialog.spawned_browser()); - EXPECT_FALSE(dialog.sync_promo_was_closed()); -} - -} // namespace diff --git a/chrome/browser/ui/webui/sync_promo/sync_promo_handler.cc b/chrome/browser/ui/webui/sync_promo/sync_promo_handler.cc index ac9ae86..cbe9ec6 100644 --- a/chrome/browser/ui/webui/sync_promo/sync_promo_handler.cc +++ b/chrome/browser/ui/webui/sync_promo/sync_promo_handler.cc @@ -201,27 +201,9 @@ void SyncPromoHandler::HandleCloseSyncPromo(const base::ListValue* args) { } } -int SyncPromoHandler::GetPromoVersion() { - switch (SyncPromoUI::GetSyncPromoVersion()) { - case SyncPromoUI::VERSION_DEFAULT: - return 0; - case SyncPromoUI::VERSION_DEVICES: - return 1; - case SyncPromoUI::VERSION_VERBOSE: - return 2; - case SyncPromoUI::VERSION_SIMPLE: - return 3; - case SyncPromoUI::VERSION_DIALOG: - // Use the simple sync promo layout for the dialog version. - return 3; - default: - NOTREACHED(); - return 0; - } -} - void SyncPromoHandler::HandleInitializeSyncPromo(const base::ListValue* args) { - base::FundamentalValue version(GetPromoVersion()); + // TODO(sail): The version argument is going away, remove this. + base::FundamentalValue version(3); web_ui()->CallJavascriptFunction("SyncSetupOverlay.showPromoVersion", version); diff --git a/chrome/browser/ui/webui/sync_promo/sync_promo_handler.h b/chrome/browser/ui/webui/sync_promo/sync_promo_handler.h index f83d8de..6c62c50 100644 --- a/chrome/browser/ui/webui/sync_promo/sync_promo_handler.h +++ b/chrome/browser/ui/webui/sync_promo/sync_promo_handler.h @@ -41,9 +41,6 @@ class SyncPromoHandler : public SyncSetupHandler { // JavaScript callback handler to close the sync promo. void HandleCloseSyncPromo(const base::ListValue* args); - // Gets the sync promo layout for the current sync promo version. - int GetPromoVersion(); - // JavaScript callback handler to initialize the sync promo. void HandleInitializeSyncPromo(const base::ListValue* args); diff --git a/chrome/browser/ui/webui/sync_promo/sync_promo_handler2.cc b/chrome/browser/ui/webui/sync_promo/sync_promo_handler2.cc index f1b316a..fdc5c88 100644 --- a/chrome/browser/ui/webui/sync_promo/sync_promo_handler2.cc +++ b/chrome/browser/ui/webui/sync_promo/sync_promo_handler2.cc @@ -208,27 +208,9 @@ void SyncPromoHandler2::HandleCloseSyncPromo(const base::ListValue* args) { } } -int SyncPromoHandler2::GetPromoVersion() { - switch (SyncPromoUI::GetSyncPromoVersion()) { - case SyncPromoUI::VERSION_DEFAULT: - return 0; - case SyncPromoUI::VERSION_DEVICES: - return 1; - case SyncPromoUI::VERSION_VERBOSE: - return 2; - case SyncPromoUI::VERSION_SIMPLE: - return 3; - case SyncPromoUI::VERSION_DIALOG: - // Use the simple sync promo layout for the dialog version. - return 3; - default: - NOTREACHED(); - return 0; - } -} - void SyncPromoHandler2::HandleInitializeSyncPromo(const base::ListValue* args) { - base::FundamentalValue version(GetPromoVersion()); + // TODO(sail): The version argument is going away, remove this. + base::FundamentalValue version(3); web_ui_->CallJavascriptFunction("SyncSetupOverlay.showPromoVersion", version); diff --git a/chrome/browser/ui/webui/sync_promo/sync_promo_handler2.h b/chrome/browser/ui/webui/sync_promo/sync_promo_handler2.h index 7d86cd2..329ff57 100644 --- a/chrome/browser/ui/webui/sync_promo/sync_promo_handler2.h +++ b/chrome/browser/ui/webui/sync_promo/sync_promo_handler2.h @@ -44,9 +44,6 @@ class SyncPromoHandler2 : public SyncSetupHandler2 { // JavaScript callback handler to close the sync promo. void HandleCloseSyncPromo(const base::ListValue* args); - // Gets the sync promo layout for the current sync promo version. - int GetPromoVersion(); - // JavaScript callback handler to initialize the sync promo. void HandleInitializeSyncPromo(const base::ListValue* args); diff --git a/chrome/browser/ui/webui/sync_promo/sync_promo_trial.cc b/chrome/browser/ui/webui/sync_promo/sync_promo_trial.cc index 6f6b564..278b22d 100644 --- a/chrome/browser/ui/webui/sync_promo/sync_promo_trial.cc +++ b/chrome/browser/ui/webui/sync_promo/sync_promo_trial.cc @@ -4,210 +4,14 @@ #include "chrome/browser/ui/webui/sync_promo/sync_promo_trial.h" -#include "base/command_line.h" -#include "base/metrics/field_trial.h" -#include "base/string_number_conversions.h" -#include "base/string_util.h" -#include "chrome/browser/google/google_util.h" -#include "chrome/browser/metrics/metrics_service.h" -#include "chrome/browser/prefs/pref_service.h" -#include "chrome/browser/profiles/profile.h" -#include "chrome/browser/ui/webui/sync_promo/sync_promo_ui.h" -#include "chrome/common/chrome_switches.h" -#include "chrome/common/chrome_version_info.h" -#include "content/public/browser/web_contents.h" -#include "content/public/browser/web_ui.h" -#include "grit/generated_resources.h" - -namespace { - -const char kLayoutExperimentTrialName[] = "SyncPromoLayoutExperiment"; - -enum LayoutExperimentType { - LAYOUT_EXPERIMENT_DEFAULT = 0, - LAYOUT_EXPERIMENT_DEVICES, - LAYOUT_EXPERIMENT_VERBOSE, - LAYOUT_EXPERIMENT_SIMPLE, - LAYOUT_EXPERIMENT_NONE, - LAYOUT_EXPERIMENT_DIALOG, - LAYOUT_EXPERIMENT_BOUNDARY, -}; - -// Flag to make sure sync_promo_trial::Activate() has been called. -bool sync_promo_trial_initialized; - -// Checks if a sync promo layout experiment is active. If it is active then the -// layout type is return in |type|. -bool GetActiveLayoutExperiment(LayoutExperimentType* type) { - DCHECK(type); - - int version = 0; - if (base::StringToInt(CommandLine::ForCurrentProcess()-> - GetSwitchValueASCII(switches::kSyncPromoVersion), &version)) { - switch (version) { - case SyncPromoUI::VERSION_DEFAULT: - *type = LAYOUT_EXPERIMENT_DEFAULT; - return true; - case SyncPromoUI::VERSION_DEVICES: - *type = LAYOUT_EXPERIMENT_DEVICES; - return true; - case SyncPromoUI::VERSION_VERBOSE: - *type = LAYOUT_EXPERIMENT_VERBOSE; - return true; - case SyncPromoUI::VERSION_SIMPLE: - *type = LAYOUT_EXPERIMENT_SIMPLE; - return true; - case SyncPromoUI::VERSION_DIALOG: - *type = LAYOUT_EXPERIMENT_DIALOG; - return true; - default: - return false; - } - } - - if (chrome::VersionInfo::GetChannel() == - chrome::VersionInfo::CHANNEL_STABLE) { - std::string brand; - if (!google_util::GetBrand(&brand)) - return false; - - if (brand == "GGRG" || brand == "CHCG") - *type = LAYOUT_EXPERIMENT_DEFAULT; - else if (brand == "GGRH" || brand == "CHCH") - *type = LAYOUT_EXPERIMENT_DEVICES; - else if (brand == "GGRI" || brand == "CHCI") - *type = LAYOUT_EXPERIMENT_VERBOSE; - else if (brand == "GGRJ" || brand == "CHCJ") - *type = LAYOUT_EXPERIMENT_SIMPLE; - else if (brand == "GGRL" || brand == "CHCL") - *type = LAYOUT_EXPERIMENT_NONE; - else if (brand == "GGRK" || brand == "CHCK") - *type = LAYOUT_EXPERIMENT_DIALOG; - else - return false; - } else { - if (!base::FieldTrialList::TrialExists(kLayoutExperimentTrialName)) - return false; - int value = base::FieldTrialList::FindValue(kLayoutExperimentTrialName) - - base::FieldTrial::kDefaultGroupNumber; - *type = static_cast<LayoutExperimentType>(value); - } - - return true; -} - -} // namespace - namespace sync_promo_trial { -void Activate() { - DCHECK(!sync_promo_trial_initialized); - sync_promo_trial_initialized = true; - - // For stable builds we'll use brand codes to enroll uesrs into experiments. - // For dev and beta we don't have brand codes so we randomly enroll users. - if (chrome::VersionInfo::GetChannel() != - chrome::VersionInfo::CHANNEL_STABLE) { -#if defined(GOOGLE_CHROME_BUILD) - // Create a field trial that expires in August 8, 2012. It contains 6 groups - // with each group having an equal chance of enrollment. - scoped_refptr<base::FieldTrial> trial(new base::FieldTrial( - kLayoutExperimentTrialName, 6, "default", 2012, 8, 1)); - if (base::FieldTrialList::IsOneTimeRandomizationEnabled()) - trial->UseOneTimeRandomization(); - trial->AppendGroup("", 1); - trial->AppendGroup("", 1); - trial->AppendGroup("", 1); - trial->AppendGroup("", 1); - trial->AppendGroup("", 1); -#endif - } -} - -StartupOverride GetStartupOverrideForCurrentTrial() { - DCHECK(sync_promo_trial_initialized); - - LayoutExperimentType type; - if (GetActiveLayoutExperiment(&type)) { - return type == LAYOUT_EXPERIMENT_NONE ? STARTUP_OVERRIDE_HIDE : - STARTUP_OVERRIDE_SHOW; - } - return STARTUP_OVERRIDE_NONE; -} - void RecordUserShownPromo(content::WebUI* web_ui) { - DCHECK(sync_promo_trial_initialized); - - LayoutExperimentType type; - if (GetActiveLayoutExperiment(&type)) { - bool is_at_startup = SyncPromoUI::GetIsLaunchPageForSyncPromoURL( - web_ui->GetWebContents()->GetURL()); - if (is_at_startup) { - DCHECK(SyncPromoUI::HasShownPromoAtStartup(Profile::FromWebUI(web_ui))); - UMA_HISTOGRAM_ENUMERATION("SyncPromo.ShownPromoWithLayoutExpAtStartup", - type, LAYOUT_EXPERIMENT_BOUNDARY); - } else { - UMA_HISTOGRAM_ENUMERATION("SyncPromo.ShownPromoWithLayoutExp", - type, LAYOUT_EXPERIMENT_BOUNDARY); - } - } -} - -void RecordSyncPromoSuppressedForCurrentTrial() { - DCHECK(sync_promo_trial_initialized); - LayoutExperimentType type = LAYOUT_EXPERIMENT_DEFAULT; - DCHECK(GetActiveLayoutExperiment(&type) && type == LAYOUT_EXPERIMENT_NONE); - // Avoid warning about unused variable in release builds. - (void)type; - UMA_HISTOGRAM_ENUMERATION("SyncPromo.ShownPromoWithLayoutExpAtStartup", - LAYOUT_EXPERIMENT_NONE, LAYOUT_EXPERIMENT_BOUNDARY); + // TODO(sail): Add new UMA stats here. } void RecordUserSignedIn(content::WebUI* web_ui) { - DCHECK(sync_promo_trial_initialized); - - LayoutExperimentType type; - if (GetActiveLayoutExperiment(&type)) { - bool is_at_startup = SyncPromoUI::GetIsLaunchPageForSyncPromoURL( - web_ui->GetWebContents()->GetURL()); - if (is_at_startup) { - DCHECK(SyncPromoUI::HasShownPromoAtStartup(Profile::FromWebUI(web_ui))); - UMA_HISTOGRAM_ENUMERATION("SyncPromo.SignedInWithLayoutExpAtStartup", - type, LAYOUT_EXPERIMENT_BOUNDARY); - } else { - UMA_HISTOGRAM_ENUMERATION("SyncPromo.SignedInWithLayoutExp", - type, LAYOUT_EXPERIMENT_BOUNDARY); - } - } -} - -bool GetSyncPromoVersionForCurrentTrial(SyncPromoUI::Version* version) { - DCHECK(sync_promo_trial_initialized); - DCHECK(version); - - LayoutExperimentType type; - if (!GetActiveLayoutExperiment(&type)) - return false; - - switch (type) { - case LAYOUT_EXPERIMENT_DEFAULT: - *version = SyncPromoUI::VERSION_DEFAULT; - return true; - case LAYOUT_EXPERIMENT_DEVICES: - *version = SyncPromoUI::VERSION_DEVICES; - return true; - case LAYOUT_EXPERIMENT_VERBOSE: - *version = SyncPromoUI::VERSION_VERBOSE; - return true; - case LAYOUT_EXPERIMENT_SIMPLE: - *version = SyncPromoUI::VERSION_SIMPLE; - return true; - case LAYOUT_EXPERIMENT_DIALOG: - *version = SyncPromoUI::VERSION_DIALOG; - return true; - default: - return false; - } + // TODO(sail): Add new UMA stats here. } } // namespace sync_promo_trial diff --git a/chrome/browser/ui/webui/sync_promo/sync_promo_trial.h b/chrome/browser/ui/webui/sync_promo/sync_promo_trial.h index 4378668..c4510ea 100644 --- a/chrome/browser/ui/webui/sync_promo/sync_promo_trial.h +++ b/chrome/browser/ui/webui/sync_promo/sync_promo_trial.h @@ -15,36 +15,14 @@ class WebUI; namespace sync_promo_trial { -enum StartupOverride { - STARTUP_OVERRIDE_NONE, - STARTUP_OVERRIDE_SHOW, - STARTUP_OVERRIDE_HIDE, -}; - -// Activate the field trial. -void Activate(); - -// Returns the start up override value for any currently running sync promo -// trials. -StartupOverride GetStartupOverrideForCurrentTrial(); - // Records that the user was shown the sync promo for any currently running sync // promo trials. |web_ui| is the web UI where the promo was shown. void RecordUserShownPromo(content::WebUI* web_ui); -// Records that the sync promo was not shown to the user (when it normally -// would have been shown) because of the current trial. -void RecordSyncPromoSuppressedForCurrentTrial(); - // Records that the user signed into sync for any currently running sync promo // trials. |web_ui| is the web UI where the user signed into sync. void RecordUserSignedIn(content::WebUI* web_ui); -// Returns true if a sync promo trial is running that overrides the sync promo -// version. If such a trial is running then on return |version| will contain the -// version of the sync promo to show. |version| must not be NULL. -bool GetSyncPromoVersionForCurrentTrial(SyncPromoUI::Version* version); - } // namespace sync_promo_trial #endif // CHROME_BROWSER_UI_WEBUI_SYNC_PROMO_SYNC_PROMO_TRIAL_H_ diff --git a/chrome/browser/ui/webui/sync_promo/sync_promo_ui.cc b/chrome/browser/ui/webui/sync_promo/sync_promo_ui.cc index 659d0e7..8a8d229 100644 --- a/chrome/browser/ui/webui/sync_promo/sync_promo_ui.cc +++ b/chrome/browser/ui/webui/sync_promo/sync_promo_ui.cc @@ -173,11 +173,8 @@ void SyncPromoUI::RegisterUserPrefs(PrefService* prefs) { // static bool SyncPromoUI::ShouldShowSyncPromoAtStartup(Profile* profile, - bool is_new_profile, - bool* promo_suppressed) { + bool is_new_profile) { DCHECK(profile); - DCHECK(promo_suppressed); - *promo_suppressed = false; if (!ShouldShowSyncPromo(profile)) return false; @@ -203,19 +200,6 @@ bool SyncPromoUI::ShouldShowSyncPromoAtStartup(Profile* profile, if (show_count >= kSyncPromoShowAtStartupMaximum) return false; - // If the current install is part of trial then let the trial determine if we - // should show the promo or not. - switch (sync_promo_trial::GetStartupOverrideForCurrentTrial()) { - case sync_promo_trial::STARTUP_OVERRIDE_NONE: - // No override so simply continue. - break; - case sync_promo_trial::STARTUP_OVERRIDE_SHOW: - return true; - case sync_promo_trial::STARTUP_OVERRIDE_HIDE: - *promo_suppressed = true; - return false; - } - // This pref can be set in the master preferences file to allow or disallow // showing the sync promo at startup. if (prefs->HasPrefPath(prefs::kSyncPromoShowOnFirstRunAllowed)) @@ -298,25 +282,3 @@ std::string SyncPromoUI::GetSourceForSyncPromoURL(const GURL& url) { return GetValueForKeyInQuery(url, kSyncPromoQueryKeySource, &value) ? value : std::string(); } - -// static -SyncPromoUI::Version SyncPromoUI::GetSyncPromoVersion() { - Version version; - if (sync_promo_trial::GetSyncPromoVersionForCurrentTrial(&version)) { - // Currently the sync promo dialog has two problems. First, it's not modal - // so the user can interact with other browser windows. Second, it uses - // a nested message loop that can cause the sync promo page not to render. - // To work around these problems the sync promo dialog is only shown for - // the first profile. TODO(sail): Fix these issues if the sync promo dialog - // is more widely deployed. - ProfileInfoCache& cache = - g_browser_process->profile_manager()->GetProfileInfoCache(); - if (cache.GetNumberOfProfiles() > 1 && - version == SyncPromoUI::VERSION_DIALOG) { - return SyncPromoUI::VERSION_SIMPLE; - } - return version; - } - - return VERSION_SIMPLE; -} diff --git a/chrome/browser/ui/webui/sync_promo/sync_promo_ui.h b/chrome/browser/ui/webui/sync_promo/sync_promo_ui.h index 650362a..0c46872 100644 --- a/chrome/browser/ui/webui/sync_promo/sync_promo_ui.h +++ b/chrome/browser/ui/webui/sync_promo/sync_promo_ui.h @@ -14,15 +14,6 @@ class PrefService; // The Web UI handler for chrome://signin. class SyncPromoUI : public content::WebUIController { public: - enum Version { - VERSION_DEFAULT = 0, - VERSION_DEVICES, - VERSION_VERBOSE, - VERSION_SIMPLE, - VERSION_DIALOG, - VERSION_COUNT, - }; - // Constructs a SyncPromoUI. explicit SyncPromoUI(content::WebUI* web_ui); @@ -31,11 +22,8 @@ class SyncPromoUI : public content::WebUIController { static bool ShouldShowSyncPromo(Profile* profile); // Returns true if we should show the sync promo at startup. - // On return |promo_suppressed| is true if a sync promo would normally - // have been shown but was suppressed due to a experiment. static bool ShouldShowSyncPromoAtStartup(Profile* profile, - bool is_new_profile, - bool* promo_suppressed); + bool is_new_profile); // Called when the sync promo has been shown so that we can keep track // of the number of times we've displayed it. @@ -73,11 +61,6 @@ class SyncPromoUI : public content::WebUIController { // Gets the source from the query portion of the sync promo URL. static std::string GetSourceForSyncPromoURL(const GURL& url); - // Returns the version of the sync promo UI that we should display. - // Each version changes the UI slightly (for example, replacing text with - // an infographic). - static Version GetSyncPromoVersion(); - private: DISALLOW_COPY_AND_ASSIGN(SyncPromoUI); }; diff --git a/chrome/chrome_browser.gypi b/chrome/chrome_browser.gypi index 682ee03..a852e95 100644 --- a/chrome/chrome_browser.gypi +++ b/chrome/chrome_browser.gypi @@ -3944,8 +3944,6 @@ 'browser/ui/webui/signin/login_ui_service_factory.h', 'browser/ui/webui/sync_internals_ui.cc', 'browser/ui/webui/sync_internals_ui.h', - 'browser/ui/webui/sync_promo/sync_promo_dialog.cc', - 'browser/ui/webui/sync_promo/sync_promo_dialog.h', 'browser/ui/webui/sync_promo/sync_promo_handler.cc', 'browser/ui/webui/sync_promo/sync_promo_handler.h', 'browser/ui/webui/sync_promo/sync_promo_trial.cc', diff --git a/chrome/chrome_tests.gypi b/chrome/chrome_tests.gypi index 09e4d2b..a7383c1 100644 --- a/chrome/chrome_tests.gypi +++ b/chrome/chrome_tests.gypi @@ -2835,7 +2835,6 @@ 'browser/ui/webui/options/password_manager_browsertest.js', 'browser/ui/webui/options/personal_options_browsertest.js', 'browser/ui/webui/options/search_engine_manager_browsertest.js', - 'browser/ui/webui/sync_promo/sync_promo_dialog_browsertest.cc', 'browser/ui/webui/sync_setup_browsertest.js', 'browser/ui/webui/test_html_dialog_ui_delegate.cc', 'browser/ui/webui/test_html_dialog_ui_delegate.h', diff --git a/chrome/common/chrome_switches.cc b/chrome/common/chrome_switches.cc index 27cc310..de22ab6 100644 --- a/chrome/common/chrome_switches.cc +++ b/chrome/common/chrome_switches.cc @@ -1100,9 +1100,6 @@ const char kSyncNotificationMethod[] = "sync-notification-method"; // Overrides the default host:port used for sync notifications. const char kSyncNotificationHostPort[] = "sync-notification-host-port"; -// Specifies the sync promo version to display. -const char kSyncPromoVersion[] = "sync-promo-version"; - // Overrides the default server used for profile sync. const char kSyncServiceURL[] = "sync-url"; diff --git a/chrome/common/chrome_switches.h b/chrome/common/chrome_switches.h index 13c4aba..baf4906 100644 --- a/chrome/common/chrome_switches.h +++ b/chrome/common/chrome_switches.h @@ -297,7 +297,6 @@ extern const char kSyncAllowInsecureXmppConnection[]; extern const char kSyncInvalidateXmppLogin[]; extern const char kSyncNotificationMethod[]; extern const char kSyncNotificationHostPort[]; -extern const char kSyncPromoVersion[]; extern const char kSyncServiceURL[]; extern const char kSyncThrowUnrecoverableError[]; extern const char kSyncTrySsltcpFirstForXmpp[]; |