diff options
author | ivankr@chromium.org <ivankr@chromium.org@0039d316-1c4b-4281-b951-d872f2087c98> | 2012-12-05 16:02:24 +0000 |
---|---|---|
committer | ivankr@chromium.org <ivankr@chromium.org@0039d316-1c4b-4281-b951-d872f2087c98> | 2012-12-05 16:02:24 +0000 |
commit | 427e48fd18a420b8eb322cbb249b12c0211eea13 (patch) | |
tree | cb84662caecaa59d869418932a4ee648102eacdb | |
parent | 4c416a31ee3ac9a4b00ed6d2f8f7dc48c9d89d89 (diff) | |
download | chromium_src-427e48fd18a420b8eb322cbb249b12c0211eea13.zip chromium_src-427e48fd18a420b8eb322cbb249b12c0211eea13.tar.gz chromium_src-427e48fd18a420b8eb322cbb249b12c0211eea13.tar.bz2 |
[rlz,cros] RLZ glue for ChromeOS.
BUG=157348,160059
TBR=nirnimesh,sky
Review URL: https://chromiumcodereview.appspot.com/11412067
git-svn-id: svn://svn.chromium.org/chrome/trunk/src@171233 0039d316-1c4b-4281-b951-d872f2087c98
31 files changed, 429 insertions, 197 deletions
diff --git a/chrome/app/chromeos_strings.grdp b/chrome/app/chromeos_strings.grdp index f98b1fe..40de813 100644 --- a/chrome/app/chromeos_strings.grdp +++ b/chrome/app/chromeos_strings.grdp @@ -1383,17 +1383,23 @@ Press any key to continue exploring. <message name="IDS_EULA_ACCEPT_AND_CONTINUE_BUTTON" desc="Accept button text below EULA terms of service"> Accept and continue </message> - <message name="IDS_EULA_SYSTEM_SECURITY_SETTING" desc="Link from the EULA wizard screen and title of the according dialog box"> - System security setting + <message name="IDS_EULA_SYSTEM_INSTALLATION_SETTINGS" desc="Link from the EULA wizard screen and title of the TPM and RLZ info dialog"> + System installation settings </message> - <message name="IDS_EULA_SYSTEM_SECURITY_SETTING_DESCRIPTION" desc="Dialog box text"> + <message name="IDS_EULA_TPM_DESCRIPTION" desc="Dialog box text"> Your computer contains a Trusted Platform Module (TPM) security device, which is used to implement many critical security features in Chrome OS. </message> - <message name="IDS_EULA_SYSTEM_SECURITY_SETTING_DESCRIPTION_KEY" desc="Dialog box text"> + <message name="IDS_EULA_TPM_KEY_DESCRIPTION" desc="Dialog box text"> Below is the randomly generated TPM password that has been assigned to your computer: </message> - <message name="IDS_EULA_SYSTEM_SECURITY_SETTING_WAIT" desc="Dialog box text"> - The TPM is being set up. Please be patient; this may take a few minutes. + <message name="IDS_EULA_TPM_WAIT" desc="Dialog box text"> + The TPM is being set up. Please be patient; this may take a few minutes. + </message> + <message name="IDS_EULA_RLZ_DESCRIPTION" desc="Dialog box text"> + Your computer also comes with <ph name="SHORT_PRODUCT_NAME">$1<ex>Chrome</ex></ph>'s RLZ library built in. RLZ assigns a non-unique, non-personally identifiable tag to measure the searches and <ph name="SHORT_PRODUCT_NAME">$1<ex>Chrome</ex></ph> usage driven by a particular promotional campaign. These labels sometimes appear in Google Search queries in <ph name="PRODUCT_NAME">$2<ex>Google Chrome</ex></ph>. + </message> + <message name="IDS_EULA_RLZ_ENABLE" desc="Check box text for enabling RLZ tracking on TPM/RLZ info dialog."> + Enable RLZ tracking on <ph name="SHORT_PRODUCT_OS_NAME">$1<ex>Chrome OS</ex></ph>. </message> <message name="IDS_EULA_TPM_BUSY" desc="Message bubble text"> TPM is being prepared, please wait (this may take a few minutes)... diff --git a/chrome/browser/automation/testing_automation_provider_chromeos.cc b/chrome/browser/automation/testing_automation_provider_chromeos.cc index 98c9ab8..5ec4c56 100644 --- a/chrome/browser/automation/testing_automation_provider_chromeos.cc +++ b/chrome/browser/automation/testing_automation_provider_chromeos.cc @@ -255,8 +255,10 @@ void TestingAutomationProvider::AcceptOOBEEula(DictionaryValue* args, IPC::Message* reply_message) { bool accepted; bool usage_stats_reporting; + bool rlz_enabled; if (!args->GetBoolean("accepted", &accepted) || - !args->GetBoolean("usage_stats_reporting", &usage_stats_reporting)) { + !args->GetBoolean("usage_stats_reporting", &usage_stats_reporting) || + !args->GetBoolean("rlz_enabled", &rlz_enabled)) { AutomationJSONReply(this, reply_message).SendError( "Invalid or missing args."); return; @@ -271,7 +273,8 @@ void TestingAutomationProvider::AcceptOOBEEula(DictionaryValue* args, } // Observer will delete itself. new WizardControllerObserver(wizard_controller, this, reply_message); - wizard_controller->GetEulaScreen()->OnExit(accepted, usage_stats_reporting); + wizard_controller->GetEulaScreen()->OnExit( + accepted, usage_stats_reporting, rlz_enabled); } void TestingAutomationProvider::CancelOOBEUpdate(DictionaryValue* args, diff --git a/chrome/browser/chrome_browser_main.cc b/chrome/browser/chrome_browser_main.cc index 3266165..c0b2531 100644 --- a/chrome/browser/chrome_browser_main.cc +++ b/chrome/browser/chrome_browser_main.cc @@ -8,7 +8,6 @@ #include <gtk/gtk.h> #endif -#include <algorithm> #include <string> #include <vector> @@ -443,12 +442,6 @@ void LaunchDevToolsHandlerIfNeeded(Profile* profile, } } -#if defined(ENABLE_RLZ) -bool IsGoogleUrl(const GURL& url) { - return google_util::IsGoogleHomePageUrl(url.possibly_invalid_spec()); -} -#endif - } // namespace namespace chrome_browser { @@ -1226,44 +1219,13 @@ int ChromeBrowserMainParts::PreMainMessageLoopRunImpl() { #endif // OS_WIN #if defined(ENABLE_RLZ) && !defined(OS_CHROMEOS) - // TODO(ivankr): do this on user login on ChromeOS. // Init the RLZ library. This just binds the dll and schedules a task on the // file thread to be run sometime later. If this is the first run we record // the installation event. - bool is_google_default_search = false; - TemplateURLService* template_url_service = - TemplateURLServiceFactory::GetForProfile(profile_); - if (template_url_service) { - const TemplateURL* url_template = - template_url_service->GetDefaultSearchProvider(); - is_google_default_search = - url_template && url_template->url_ref().HasGoogleBaseURLs(); - } - PrefService* pref_service = profile_->GetPrefs(); - bool is_google_homepage = google_util::IsGoogleHomePageUrl( - pref_service->GetString(prefs::kHomePage)); - - bool is_google_in_startpages = false; - SessionStartupPref session_startup_prefs = - StartupBrowserCreator::GetSessionStartupPref(parsed_command_line(), - profile_); - if (session_startup_prefs.type == SessionStartupPref::URLS) { - is_google_in_startpages = std::count_if(session_startup_prefs.urls.begin(), - session_startup_prefs.urls.end(), - IsGoogleUrl) > 0; - } - int ping_delay = is_first_run_ ? master_prefs_->ping_delay : pref_service->GetInteger(first_run::GetPingDelayPrefName().c_str()); - RLZTracker::InitRlzDelayed(is_first_run_, ping_delay, - is_google_default_search, is_google_homepage, - is_google_in_startpages); - - // Prime the RLZ cache for the home page access point so that its avaiable - // for the startup page if needed (i.e., when the startup page is set to - // the home page). - RLZTracker::GetAccessPointRlz(RLZTracker::CHROME_HOME_PAGE, NULL); + RLZTracker::InitRlzFromProfileDelayed(profile_, is_first_run_, ping_delay); #endif // defined(ENABLE_RLZ) && !defined(OS_CHROMEOS) // Configure modules that need access to resources. diff --git a/chrome/browser/chromeos/login/eula_screen.cc b/chrome/browser/chromeos/login/eula_screen.cc index 4ad1c72..7f9af22 100644 --- a/chrome/browser/chromeos/login/eula_screen.cc +++ b/chrome/browser/chromeos/login/eula_screen.cc @@ -66,8 +66,11 @@ GURL EulaScreen::GetOemEulaUrl() const { return GURL(); } -void EulaScreen::OnExit(bool accepted, bool is_usage_stats_checked) { - get_screen_observer()->SetUsageStatisticsReporting(is_usage_stats_checked); +void EulaScreen::OnExit(bool accepted, + bool usage_stats_enabled, + bool rlz_enabled) { + get_screen_observer()->SetUsageStatisticsReporting(usage_stats_enabled); + get_screen_observer()->SetRlzEnabled(rlz_enabled); get_screen_observer()->OnExit(accepted ? ScreenObserver::EULA_ACCEPTED : ScreenObserver::EULA_BACK); diff --git a/chrome/browser/chromeos/login/eula_screen.h b/chrome/browser/chromeos/login/eula_screen.h index 46497ae..983b99c 100644 --- a/chrome/browser/chromeos/login/eula_screen.h +++ b/chrome/browser/chromeos/login/eula_screen.h @@ -32,7 +32,9 @@ class EulaScreen : public WizardScreen, // EulaScreenActor::Delegate implementation: virtual GURL GetOemEulaUrl() const OVERRIDE; - virtual void OnExit(bool accepted, bool is_usage_stats_checked) OVERRIDE; + virtual void OnExit(bool accepted, + bool usage_stats_enabled, + bool rlz_enabled) OVERRIDE; virtual void InitiatePasswordFetch() OVERRIDE; virtual bool IsUsageStatsEnabled() const OVERRIDE; virtual void OnActorDestroyed(EulaScreenActor* actor) OVERRIDE; diff --git a/chrome/browser/chromeos/login/eula_screen_actor.h b/chrome/browser/chromeos/login/eula_screen_actor.h index 0ef2cb5..83386de 100644 --- a/chrome/browser/chromeos/login/eula_screen_actor.h +++ b/chrome/browser/chromeos/login/eula_screen_actor.h @@ -27,7 +27,9 @@ class EulaScreenActor { // Called when screen is exited. |accepted| indicates if EULA was // accepted or not. - virtual void OnExit(bool accepted, bool is_usage_stats_checked) = 0; + virtual void OnExit(bool accepted, + bool usage_stats_enabled, + bool rlz_enabled) = 0; // Initiate TPM password fetch. Will call actor's OnPasswordFetched() when // done. diff --git a/chrome/browser/chromeos/login/login_utils.cc b/chrome/browser/chromeos/login/login_utils.cc index 0bd7658..2b1bf0c 100644 --- a/chrome/browser/chromeos/login/login_utils.cc +++ b/chrome/browser/chromeos/login/login_utils.cc @@ -56,6 +56,7 @@ #include "chrome/browser/prefs/pref_service.h" #include "chrome/browser/profiles/profile.h" #include "chrome/browser/profiles/profile_manager.h" +#include "chrome/browser/rlz/rlz.h" #include "chrome/browser/signin/signin_manager.h" #include "chrome/browser/signin/signin_manager_factory.h" #include "chrome/browser/signin/token_service.h" @@ -634,6 +635,14 @@ void LoginUtilsImpl::OnProfileCreated( content::NotificationService::AllSources(), content::Details<Profile>(user_profile)); +#if defined(ENABLE_RLZ) + // Init the RLZ library. + int ping_delay = user_profile->GetPrefs()->GetInteger( + first_run::GetPingDelayPrefName().c_str()); + RLZTracker::InitRlzFromProfileDelayed( + user_profile, UserManager::Get()->IsCurrentUserNew(), ping_delay); +#endif + // TODO(altimofeev): This pointer should probably never be NULL, but it looks // like LoginUtilsImpl::OnProfileCreated() may be getting called before // LoginUtilsImpl::PrepareProfile() has set |delegate_| when Chrome is killed diff --git a/chrome/browser/chromeos/login/mock_screen_observer.h b/chrome/browser/chromeos/login/mock_screen_observer.h index 96c295e..181555f 100644 --- a/chrome/browser/chromeos/login/mock_screen_observer.h +++ b/chrome/browser/chromeos/login/mock_screen_observer.h @@ -25,6 +25,8 @@ class MockScreenObserver : public ScreenObserver { void(const std::string&, const std::string&)); MOCK_METHOD1(SetUsageStatisticsReporting, void(bool)); MOCK_CONST_METHOD0(GetUsageStatisticsReporting, bool()); + MOCK_METHOD1(SetRlzEnabled, void(bool)); + MOCK_CONST_METHOD0(GetRlzEnabled, bool()); }; } // namespace chromeos diff --git a/chrome/browser/chromeos/login/screen_observer.h b/chrome/browser/chromeos/login/screen_observer.h index d2ab39b..4cd9973 100644 --- a/chrome/browser/chromeos/login/screen_observer.h +++ b/chrome/browser/chromeos/login/screen_observer.h @@ -49,10 +49,14 @@ class ScreenObserver { virtual void OnSetUserNamePassword(const std::string& username, const std::string& password) = 0; - // Set/get usage statistics reporting checkbox status on EULA screen. + // Whether usage statistics reporting is enabled on EULA screen. virtual void SetUsageStatisticsReporting(bool val) = 0; virtual bool GetUsageStatisticsReporting() const = 0; + // Whether RLZ tracking is enabled on EULA screen. + virtual void SetRlzEnabled(bool val) = 0; + virtual bool GetRlzEnabled() const = 0; + protected: virtual ~ScreenObserver() {} }; diff --git a/chrome/browser/chromeos/login/wizard_controller.cc b/chrome/browser/chromeos/login/wizard_controller.cc index 9815748..0cdd957 100644 --- a/chrome/browser/chromeos/login/wizard_controller.cc +++ b/chrome/browser/chromeos/login/wizard_controller.cc @@ -39,6 +39,7 @@ #include "chrome/browser/chromeos/login/user_manager.h" #include "chrome/browser/chromeos/settings/cros_settings.h" #include "chrome/browser/chromeos/settings/cros_settings_names.h" +#include "chrome/browser/google/google_util_chromeos.h" #include "chrome/browser/prefs/pref_service.h" #include "chrome/browser/profiles/profile_manager.h" #include "chrome/browser/ui/options/options_util.h" @@ -146,8 +147,10 @@ WizardController::WizardController(chromeos::LoginDisplayHost* host, host_(host), oobe_display_(oobe_display), usage_statistics_reporting_(true), + rlz_enabled_(false), skip_update_enroll_after_eula_(false), - login_screen_started_(false) { + login_screen_started_(false), + ALLOW_THIS_IN_INITIALIZER_LIST(weak_ptr_factory_(this)) { DCHECK(default_controller_ == NULL); default_controller_ = this; } @@ -418,6 +421,10 @@ void WizardController::RegisterPrefs(PrefService* local_state) { local_state->RegisterBooleanPref(prefs::kOwnerPrimaryMouseButtonRight, false); local_state->RegisterBooleanPref(prefs::kOwnerTapToClickEnabled, true); local_state->RegisterBooleanPref(prefs::kFactoryResetRequested, false); + local_state->RegisterStringPref(prefs::kRLZBrand, std::string(), + PrefService::UNSYNCABLE_PREF); + local_state->RegisterBooleanPref(prefs::kRLZEnabled, false, + PrefService::UNSYNCABLE_PREF); } /////////////////////////////////////////////////////////////////////////////// @@ -456,7 +463,7 @@ void WizardController::OnUpdateCompleted() { void WizardController::OnEulaAccepted() { time_eula_accepted_ = base::Time::Now(); MarkEulaAccepted(); - bool enabled = + bool uma_enabled = OptionsUtil::ResolveMetricsReportingEnabled(usage_statistics_reporting_); content::NotificationService::current()->Notify( @@ -464,8 +471,8 @@ void WizardController::OnEulaAccepted() { content::NotificationSource(content::Source<WizardController>(this)), content::NotificationService::NoDetails()); - CrosSettings::Get()->SetBoolean(kStatsReportingPref, enabled); - if (enabled) { + CrosSettings::Get()->SetBoolean(kStatsReportingPref, uma_enabled); + if (uma_enabled) { #if defined(USE_LINUX_BREAKPAD) // The crash reporter initialization needs IO to complete. base::ThreadRestrictions::ScopedAllowIO allow_io; @@ -473,6 +480,23 @@ void WizardController::OnEulaAccepted() { #endif } + // TODO(ivankr): post-AU action when |kRLZEnabled| is unset. +#if defined(ENABLE_RLZ) + SaveBoolPreferenceForced(prefs::kRLZEnabled, rlz_enabled_); +#endif + if (rlz_enabled_) + LoadBrandCodeFromFile(); + else + OnEulaBlockingTasksDone(); +} + +void WizardController::LoadBrandCodeFromFile() { + google_util::chromeos::SetBrandFromFile( + base::Bind(&WizardController::OnEulaBlockingTasksDone, + weak_ptr_factory_.GetWeakPtr())); +} + +void WizardController::OnEulaBlockingTasksDone() { if (skip_update_enroll_after_eula_) { PerformPostEulaActions(); PerformPostUpdateActions(); @@ -828,6 +852,16 @@ bool WizardController::GetUsageStatisticsReporting() const { return usage_statistics_reporting_; } +void WizardController::SetRlzEnabled(bool val) { +#if defined(ENABLE_RLZ) + rlz_enabled_ = val; +#endif +} + +bool WizardController::GetRlzEnabled() const { + return rlz_enabled_; +} + // static bool WizardController::IsZeroDelayEnabled() { return zero_delay_enabled_; diff --git a/chrome/browser/chromeos/login/wizard_controller.h b/chrome/browser/chromeos/login/wizard_controller.h index 9af70b3..ea15f2b 100644 --- a/chrome/browser/chromeos/login/wizard_controller.h +++ b/chrome/browser/chromeos/login/wizard_controller.h @@ -10,6 +10,7 @@ #include "base/compiler_specific.h" #include "base/gtest_prod_util.h" #include "base/memory/scoped_ptr.h" +#include "base/memory/weak_ptr.h" #include "base/observer_list.h" #include "base/time.h" #include "base/timer.h" @@ -191,6 +192,12 @@ class WizardController : public ScreenObserver { void OnResetCanceled(); void OnOOBECompleted(); + // Loads brand code on I/O enabled thread and stores to Local State. + void LoadBrandCodeFromFile(); + + // Called after all post-EULA blocking tasks have been completed. + void OnEulaBlockingTasksDone(); + // Shows update screen and starts update process. void InitiateOOBEUpdate(); @@ -208,6 +215,8 @@ class WizardController : public ScreenObserver { const std::string& password) OVERRIDE; virtual void SetUsageStatisticsReporting(bool val) OVERRIDE; virtual bool GetUsageStatisticsReporting() const OVERRIDE; + virtual void SetRlzEnabled(bool val) OVERRIDE; + virtual bool GetRlzEnabled() const OVERRIDE; // Switches from one screen to another. void SetCurrentScreen(WizardScreen* screen); @@ -272,6 +281,9 @@ class WizardController : public ScreenObserver { // during wizard lifetime. bool usage_statistics_reporting_; + // Whether RLZ tracking is enabled. + bool rlz_enabled_; + // If true then update check is cancelled and enrollment is started after // EULA is accepted. bool skip_update_enroll_after_eula_; @@ -284,6 +296,8 @@ class WizardController : public ScreenObserver { bool login_screen_started_; + base::WeakPtrFactory<WizardController> weak_ptr_factory_; + FRIEND_TEST_ALL_PREFIXES(EnterpriseEnrollmentScreenTest, TestCancel); FRIEND_TEST_ALL_PREFIXES(WizardControllerFlowTest, Accelerators); friend class WizardControllerFlowTest; diff --git a/chrome/browser/google/google_util.cc b/chrome/browser/google/google_util.cc index 0d47f56..f48856b 100644 --- a/chrome/browser/google/google_util.cc +++ b/chrome/browser/google/google_util.cc @@ -23,6 +23,8 @@ #if defined(OS_MACOSX) #include "chrome/browser/mac/keystone_glue.h" +#elif defined(OS_CHROMEOS) +#include "chrome/browser/google/google_util_chromeos.h" #endif #if defined(GOOGLE_CHROME_BUILD) @@ -140,6 +142,8 @@ bool GetBrand(std::string* brand) { #if defined(OS_MACOSX) brand->assign(keystone_glue::BrandCode()); +#elif defined(OS_CHROMEOS) + brand->assign(google_util::chromeos::GetBrand()); #else brand->clear(); #endif diff --git a/chrome/browser/google/google_util_chromeos.cc b/chrome/browser/google/google_util_chromeos.cc new file mode 100644 index 0000000..2892efc --- /dev/null +++ b/chrome/browser/google/google_util_chromeos.cc @@ -0,0 +1,62 @@ +// 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 "base/basictypes.h" +#include "base/bind.h" +#include "base/file_path.h" +#include "base/file_util.h" +#include "base/logging.h" +#include "base/string_util.h" +#include "base/task_runner_util.h" +#include "base/threading/worker_pool.h" +#include "chrome/browser/browser_process.h" +#include "chrome/browser/prefs/pref_service.h" +#include "chrome/common/pref_names.h" +#include "content/public/browser/browser_thread.h" + +namespace google_util { +namespace chromeos { + +namespace { + +// Path to file that stores the RLZ brand code on ChromeOS. +const char kRLZBrandFilePath[] = + FILE_PATH_LITERAL("/opt/oem/etc/BRAND_CODE"); + +// Reads the brand code from file |kRLZBrandFilePath|. +std::string ReadBrandFromFile() { + std::string brand; + FilePath brand_file_path(kRLZBrandFilePath); + if (!file_util::ReadFileToString(brand_file_path, &brand)) + LOG(WARNING) << "Brand code file missing: " << brand_file_path.value(); + TrimWhitespace(brand, TRIM_ALL, &brand); + return brand; +} + +// Sets the brand code to |brand|. +void SetBrand(const base::Closure& callback, const std::string& brand) { + g_browser_process->local_state()->SetString(prefs::kRLZBrand, brand); + callback.Run(); +} + +} // namespace + +std::string GetBrand() { + DCHECK( + !content::BrowserThread::IsWellKnownThread(content::BrowserThread::UI) || + content::BrowserThread::CurrentlyOn(content::BrowserThread::UI)); + DCHECK(g_browser_process->local_state()); + return g_browser_process->local_state()->GetString(prefs::kRLZBrand); +} + +void SetBrandFromFile(const base::Closure& callback) { + base::PostTaskAndReplyWithResult( + base::WorkerPool::GetTaskRunner(false /* task_is_slow */), + FROM_HERE, + base::Bind(&ReadBrandFromFile), + base::Bind(&SetBrand, callback)); +} + +} // namespace chromeos +} // namespace google_util diff --git a/chrome/browser/google/google_util_chromeos.h b/chrome/browser/google/google_util_chromeos.h new file mode 100644 index 0000000..94443ee --- /dev/null +++ b/chrome/browser/google/google_util_chromeos.h @@ -0,0 +1,26 @@ +// 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_GOOGLE_GOOGLE_UTIL_CHROMEOS_H_ +#define CHROME_BROWSER_GOOGLE_GOOGLE_UTIL_CHROMEOS_H_ + +#include <string> + +#include "base/callback_forward.h" + +namespace google_util { +namespace chromeos { + +// Returns the brand code stored in Local State that has been assigned to a +// partner. Returns empty string if the information is not available. +std::string GetBrand(); + +// Reads the brand code from a board-specific file and stores it to Local State. +// |callback| is invoked on the calling thread after that. +void SetBrandFromFile(const base::Closure& callback); + +} // namespace chromeos +} // namespace google_util + +#endif // CHROME_BROWSER_GOOGLE_GOOGLE_UTIL_CHROMEOS_H_ diff --git a/chrome/browser/resources/chromeos/login/oobe.css b/chrome/browser/resources/chromeos/login/oobe.css index 619002a..6daf31a 100644 --- a/chrome/browser/resources/chromeos/login/oobe.css +++ b/chrome/browser/resources/chromeos/login/oobe.css @@ -138,16 +138,6 @@ html[oobe=new] #inner-container.down { -webkit-transform: translateY(50px) rotateX(-2.5deg); } -#security-info a, -#security-tpm a, -#connect-accessibility a, -#eula-accessibility a, -#update-accessibility a, -#eula a { - color: rgb(0, 102, 104); - text-decoration: none; -} - #eula #stats-help-link { color: rgb(49, 106, 197); } @@ -780,7 +770,8 @@ html[oobe=old] .step-controls { } .step.loading .step-contents, -.step.loading .step-controls { +.step.loading .step-controls, +.step.loading .step-extra-controls { visibility: hidden; } @@ -788,6 +779,10 @@ html[oobe=old] .step-controls { visibility: hidden; } +.step:not(.loading) #eula-busy { + visibility: hidden; +} + /* Center spinner wrapper vertically and horizontally. * Vertical centering uses top: 50% and negative margin * instead of top: 0; bottom: 0 due to http://crbug.com/155320. @@ -854,7 +849,7 @@ html[oobe=old] .step-controls { } /* TODO(nkostylev): Cleanup, security-info - old design, - security-tpm - new design. */ + installation-settings - new design. */ #security-info { bottom: 10px; left: 0; @@ -878,44 +873,32 @@ html[oobe=new] #security-info { display: none; } -/* TODO(nkostylev): Remove #security-tpm element and rules. */ -html[oobe=old] #security-tpm { +/* TODO(nkostylev): Remove #security-info element and rules. */ +html[oobe=old] #installation-settings { display: none; } -#security-tpm a, -#connect-accessibility a, -#eula-accessibility a, -#update-accessibility a { +#security-info a, +#eula a, +.step-extra-controls a { color: #8c8c8c; font-size: 12px; + text-decoration: none; } .step-extra-controls { bottom: 26px; display: -webkit-box; + left: 49px; position: absolute; } -#security-tpm { - margin-left: 25px; -} - -#connect-accessibility, -#update-accessibility { - bottom: 26px; - position: absolute; -} - -html[dir=ltr] #connect-accessibility, -html[dir=ltr] #update-accessibility, -html[dir=ltr] .step-extra-controls { - left: 49px; +.step-extra-controls > *:not(:first-child) { + -webkit-margin-start: 25px; } -html[dir=rtl] #connect-accessibility, -html[dir=rtl] #update-accessibility, html[dir=rtl] .step-extra-controls { + left: auto; right: 49px; } @@ -1056,7 +1039,7 @@ html[oobe=new] #oem-eula { display: none; } -#security-info-popup { +#installation-settings-popup { background: white; border: 1px solid rgb(188, 193, 208); border-radius: 2px; @@ -1067,7 +1050,7 @@ html[oobe=new] #oem-eula { z-index: 10; } -#security-info-popup h1 { +#installation-settings-popup h1 { -webkit-padding-end: 24px; -webkit-user-select: none; background: -webkit-linear-gradient(white, #F8F8F8); @@ -1083,7 +1066,7 @@ html[oobe=new] #oem-eula { padding: 0 20px 60px 20px; } -#security-info-popup button { +#installation-settings-popup button { bottom: 20px; position: absolute; right: 20px; @@ -1098,6 +1081,15 @@ html[oobe=new] #oem-eula { text-align: center; } +html[rlz=disabled] #rlz-settings { + display: none; +} + +#rlz-enable { + -webkit-margin-end: 10px; + -webkit-margin-start: 20px; +} + [hidden] { display: none !important; } diff --git a/chrome/browser/resources/chromeos/login/oobe.html b/chrome/browser/resources/chromeos/login/oobe.html index e9243cf..f3ee5a1 100644 --- a/chrome/browser/resources/chromeos/login/oobe.html +++ b/chrome/browser/resources/chromeos/login/oobe.html @@ -1,5 +1,5 @@ <!DOCTYPE HTML> -<html i18n-values="dir:textdirection;oobe:oobeType;screen:screenType;lockanimations:lockAnimationsType"> +<html i18n-values="dir:textdirection;oobe:oobeType;screen:screenType;lockanimations:lockAnimationsType;rlz:rlzEnabled"> <head> <title i18n-content="title"></title> <link rel="stylesheet" href="chrome://resources/css/dialogs.css"></link> @@ -84,23 +84,33 @@ <div id="progress-dots" class="down"></div> </div> <div id="security-info"> - <a id="security-link" href="#" i18n-content="eulaSystemSecuritySetting"> + <a id="security-link" href="#" + i18n-content="eulaSystemInstallationSettings"> </a> </div> </div> <div id="popup-overlay" hidden> - <div id="security-info-popup"> - <h1 i18n-content="eulaSystemSecuritySetting"></h1> + <div id="installation-settings-popup"> + <h1 i18n-content="eulaSystemInstallationSettings"></h1> <div class="popup-content-area"> - <p i18n-content="eulaTpmDesc"></p> - <p i18n-content="eulaTpmKeyDesc"></p> - <div id="tpm-busy"> - <div id="spinner" class="inline-spinner"></div> - <span i18n-content="eulaTpmBusy"></span> + <div id="tpm-settings"> + <p i18n-content="eulaTpmDesc"></p> + <p i18n-content="eulaTpmKeyDesc"></p> + <div id="tpm-busy"> + <div id="spinner" class="inline-spinner"></div> + <span i18n-content="eulaTpmBusy"></span> + </div> + <p id="tpm-password"></p> + </div> + <div id="rlz-settings"> + <p id="rlz-desc" i18n-content="eulaRlzDesc"></p> + <input id="rlz-enable" type="checkbox" checked> + <label for="rlz-enable" i18n-content="eulaRlzEnable"></label> </div> - <p id="tpm-password" hidden></p> </div> - <button id="security-ok-button" i18n-content="eulaTpmOkButton"></button> + <button id="installation-settings-ok-button" + i18n-content="eulaSystemInstallationSettingsOkButton"> + </button> </div> </div> <div id="bubble" class="bubble faded" hidden></div> diff --git a/chrome/browser/resources/chromeos/login/oobe.js b/chrome/browser/resources/chromeos/login/oobe.js index 3f0b5f1..97daba4 100644 --- a/chrome/browser/resources/chromeos/login/oobe.js +++ b/chrome/browser/resources/chromeos/login/oobe.js @@ -81,29 +81,13 @@ cr.define('cr.ui', function() { // TODO: Cleanup with old OOBE style removal. $('security-link').addEventListener('click', function(event) { - chrome.send('eulaOnTpmPopupOpened'); + chrome.send('eulaOnInstallationSettingsPopupOpened'); $('popup-overlay').hidden = false; - $('security-ok-button').focus(); - }); - $('security-tpm-link').addEventListener('click', function(event) { - chrome.send('eulaOnTpmPopupOpened'); - $('popup-overlay').hidden = false; - $('security-ok-button').focus(); + $('installation-settings-ok-button').focus(); }); Oobe.initializeA11yMenu(); - $('security-ok-button').addEventListener('click', function(event) { - $('popup-overlay').hidden = true; - }); - - // Do not allow focus leaving the overlay. - $('popup-overlay').addEventListener('focusout', function(event) { - // WebKit does not allow immediate focus return. - setTimeout(function() { $('security-ok-button').focus(); }, 0); - event.preventDefault(); - }); - chrome.send('screenStateInitialize'); }; diff --git a/chrome/browser/resources/chromeos/login/oobe_screen_eula.html b/chrome/browser/resources/chromeos/login/oobe_screen_eula.html index d8c60d6..d08eca4d 100644 --- a/chrome/browser/resources/chromeos/login/oobe_screen_eula.html +++ b/chrome/browser/resources/chromeos/login/oobe_screen_eula.html @@ -25,9 +25,13 @@ <a id="eula-accessibility-link" href="#" i18n-content="accessibilityLink"></a> </div> - <div id="security-tpm"> - <a id="security-tpm-link" href="#" - i18n-content="eulaSystemSecuritySetting"></a> + <div id="installation-settings"> + <a id="installation-settings-link" href="#" + i18n-content="eulaSystemInstallationSettings"> + </a> </div> </div> + <div id="eula-busy" class="step-loading"> + <div class="spinner"></div> + </div> </div> diff --git a/chrome/browser/resources/chromeos/login/oobe_screen_eula.js b/chrome/browser/resources/chromeos/login/oobe_screen_eula.js index c58272c..48956d4 100644 --- a/chrome/browser/resources/chromeos/login/oobe_screen_eula.js +++ b/chrome/browser/resources/chromeos/login/oobe_screen_eula.js @@ -31,6 +31,25 @@ cr.define('oobe', function() { $('stats-help-link').addEventListener('click', function(event) { chrome.send('eulaOnLearnMore'); }); + $('installation-settings-link').addEventListener( + 'click', function(event) { + chrome.send('eulaOnInstallationSettingsPopupOpened'); + $('popup-overlay').hidden = false; + $('installation-settings-ok-button').focus(); + }); + $('installation-settings-ok-button').addEventListener( + 'click', function(event) { + $('popup-overlay').hidden = true; + }); + // Do not allow focus leaving the overlay. + $('popup-overlay').addEventListener('focusout', function(event) { + // WebKit does not allow immediate focus return. + window.setTimeout(function() { + // TODO(ivankr): focus cycling. + $('installation-settings-ok-button').focus(); + }, 0); + event.preventDefault(); + }); }, /** @@ -52,7 +71,8 @@ cr.define('oobe', function() { backButton.id = 'back-button'; backButton.textContent = localStrings.getString('back'); backButton.addEventListener('click', function(e) { - chrome.send('eulaOnExit', [false, $('usage-stats').checked]); + chrome.send('eulaOnExit', + [false, $('usage-stats').checked, $('rlz-enable').checked]); e.stopPropagation(); }); buttons.push(backButton); @@ -61,7 +81,9 @@ cr.define('oobe', function() { acceptButton.id = 'accept-button'; acceptButton.textContent = localStrings.getString('acceptAgreement'); acceptButton.addEventListener('click', function(e) { - chrome.send('eulaOnExit', [true, $('usage-stats').checked]); + $('eula').classList.add('loading'); // Mark EULA screen busy. + chrome.send('eulaOnExit', + [true, $('usage-stats').checked, $('rlz-enable').checked]); e.stopPropagation(); }); buttons.push(acceptButton); diff --git a/chrome/browser/resources/chromeos/login/oobe_screen_network.html b/chrome/browser/resources/chromeos/login/oobe_screen_network.html index 1e02167..68761c4 100644 --- a/chrome/browser/resources/chromeos/login/oobe_screen_network.html +++ b/chrome/browser/resources/chromeos/login/oobe_screen_network.html @@ -25,8 +25,10 @@ </div> </div> <div id="connect-controls" class="step-controls"></div> - <div id="connect-accessibility"> - <a id="connect-accessibility-link" href="#" - i18n-content="accessibilityLink"></a> + <div id="connect-extra-controls" class="step-extra-controls"> + <div id="connect-accessibility"> + <a id="connect-accessibility-link" href="#" + i18n-content="accessibilityLink"></a> + </div> </div> </div> diff --git a/chrome/browser/resources/chromeos/login/oobe_screen_update.html b/chrome/browser/resources/chromeos/login/oobe_screen_update.html index 1093e04..d8ebbaf 100644 --- a/chrome/browser/resources/chromeos/login/oobe_screen_update.html +++ b/chrome/browser/resources/chromeos/login/oobe_screen_update.html @@ -19,8 +19,10 @@ <p id="progress-message" class="progress-message" hidden></p> </div> </div> - <div id="update-accessibility"> - <a id="update-accessibility-link" href="#" - i18n-content="accessibilityLink"></a> + <div id="update-extra-controls" class="step-extra-controls"> + <div id="update-accessibility"> + <a id="update-accessibility-link" href="#" + i18n-content="accessibilityLink"></a> + </div> </div> </div> diff --git a/chrome/browser/rlz/rlz.cc b/chrome/browser/rlz/rlz.cc index 6032dd9..7048b92 100644 --- a/chrome/browser/rlz/rlz.cc +++ b/chrome/browser/rlz/rlz.cc @@ -11,16 +11,21 @@ #include <algorithm> #include "base/bind.h" +#include "base/command_line.h" #include "base/debug/trace_event.h" #include "base/message_loop.h" #include "base/string_util.h" #include "base/utf_string_conversions.h" #include "chrome/browser/browser_process.h" #include "chrome/browser/google/google_util.h" +#include "chrome/browser/prefs/pref_service.h" +#include "chrome/browser/prefs/session_startup_pref.h" #include "chrome/browser/search_engines/template_url.h" #include "chrome/browser/search_engines/template_url_service.h" #include "chrome/browser/search_engines/template_url_service_factory.h" +#include "chrome/browser/ui/startup/startup_browser_creator.h" #include "chrome/common/chrome_notification_types.h" +#include "chrome/common/pref_names.h" #include "content/public/browser/browser_thread.h" #include "content/public/browser/navigation_entry.h" #include "content/public/browser/notification_service.h" @@ -52,6 +57,10 @@ using content::NavigationEntry; namespace { +bool IsGoogleUrl(const GURL& url) { + return google_util::IsGoogleHomePageUrl(url.possibly_invalid_spec()); +} + bool IsBrandOrganic(const std::string& brand) { return brand.empty() || google_util::IsOrganic(brand); } @@ -189,6 +198,48 @@ bool RLZTracker::InitRlzDelayed(bool first_run, is_google_homepage, is_google_in_startpages); } +// static +bool RLZTracker::InitRlzFromProfileDelayed(Profile* profile, + bool first_run, + int delay) { + bool is_google_default_search = false; + TemplateURLService* template_url_service = + TemplateURLServiceFactory::GetForProfile(profile); + if (template_url_service) { + const TemplateURL* url_template = + template_url_service->GetDefaultSearchProvider(); + is_google_default_search = + url_template && url_template->url_ref().HasGoogleBaseURLs(); + } + + PrefService* pref_service = profile->GetPrefs(); + bool is_google_homepage = google_util::IsGoogleHomePageUrl( + pref_service->GetString(prefs::kHomePage)); + + bool is_google_in_startpages = false; + SessionStartupPref session_startup_prefs = + StartupBrowserCreator::GetSessionStartupPref( + *CommandLine::ForCurrentProcess(), profile); + if (session_startup_prefs.type == SessionStartupPref::URLS) { + is_google_in_startpages = std::count_if(session_startup_prefs.urls.begin(), + session_startup_prefs.urls.end(), + IsGoogleUrl) > 0; + } + + if (!InitRlzDelayed(first_run, delay, + is_google_default_search, is_google_homepage, + is_google_in_startpages)) { + return false; + } + + // Prime the RLZ cache for the home page access point so that its avaiable + // for the startup page if needed (i.e., when the startup page is set to + // the home page). + GetAccessPointRlz(CHROME_HOME_PAGE, NULL); + + return true; +} + bool RLZTracker::Init(bool first_run, int delay, bool is_google_default_search, @@ -217,8 +268,7 @@ bool RLZTracker::Init(bool first_run, delay = (delay < kMinDelay) ? kMinDelay : delay; delay = (delay > kMaxDelay) ? kMaxDelay : delay; - std::string brand; - if (google_util::GetBrand(&brand) && !IsBrandOrganic(brand)) { + if (google_util::GetBrand(&brand_) && !IsBrandOrganic(brand_)) { // Register for notifications from the omnibox so that we can record when // the user performs a first search. registrar_.Add(this, chrome::NOTIFICATION_OMNIBOX_OPENED_URL, @@ -233,6 +283,7 @@ bool RLZTracker::Init(bool first_run, registrar_.Add(this, content::NOTIFICATION_NAV_ENTRY_PENDING, content::NotificationService::AllSources()); } + google_util::GetReactivationBrand(&reactivation_brand_); rlz_lib::SetURLRequestContext(g_browser_process->system_request_context()); ScheduleDelayedInit(delay); @@ -256,8 +307,7 @@ void RLZTracker::DelayedInit() { // For organic brandcodes do not use rlz at all. Empty brandcode usually // means a chromium install. This is ok. - std::string brand; - if (google_util::GetBrand(&brand) && !IsBrandOrganic(brand)) { + if (!IsBrandOrganic(brand_)) { RecordProductEvents(first_run_, is_google_default_search_, is_google_homepage_, is_google_in_startpages_, already_ran_, omnibox_used_, homepage_used_); @@ -266,10 +316,8 @@ void RLZTracker::DelayedInit() { // If chrome has been reactivated, record the events for this brand // as well. - std::string reactivation_brand; - if (google_util::GetReactivationBrand(&reactivation_brand) && - !IsBrandOrganic(reactivation_brand)) { - rlz_lib::SupplementaryBranding branding(reactivation_brand.c_str()); + if (!IsBrandOrganic(reactivation_brand_)) { + rlz_lib::SupplementaryBranding branding(reactivation_brand_.c_str()); RecordProductEvents(first_run_, is_google_default_search_, is_google_homepage_, is_google_in_startpages_, already_ran_, omnibox_used_, homepage_used_); @@ -298,9 +346,7 @@ void RLZTracker::PingNowImpl() { string16 referral; GoogleUpdateSettings::GetReferral(&referral); - std::string brand; - if (google_util::GetBrand(&brand) && !IsBrandOrganic(brand) && - SendFinancialPing(brand, lang, referral)) { + if (!IsBrandOrganic(brand_) && SendFinancialPing(brand_, lang, referral)) { GoogleUpdateSettings::ClearReferral(); { @@ -313,11 +359,9 @@ void RLZTracker::PingNowImpl() { GetAccessPointRlz(RLZTracker::CHROME_HOME_PAGE, NULL); } - std::string reactivation_brand; - if (google_util::GetReactivationBrand(&reactivation_brand) && - !IsBrandOrganic(reactivation_brand)) { - rlz_lib::SupplementaryBranding branding(reactivation_brand.c_str()); - SendFinancialPing(reactivation_brand, lang, referral); + if (!IsBrandOrganic(reactivation_brand_)) { + rlz_lib::SupplementaryBranding branding(reactivation_brand_.c_str()); + SendFinancialPing(reactivation_brand_, lang, referral); } } @@ -375,9 +419,8 @@ bool RLZTracker::RecordProductEventImpl(rlz_lib::Product product, bool ret = rlz_lib::RecordProductEvent(product, point, event_id); // If chrome has been reactivated, record the event for this brand as well. - std::string reactivation_brand; - if (google_util::GetReactivationBrand(&reactivation_brand)) { - rlz_lib::SupplementaryBranding branding(reactivation_brand.c_str()); + if (!reactivation_brand_.empty()) { + rlz_lib::SupplementaryBranding branding(reactivation_brand_.c_str()); ret &= rlz_lib::RecordProductEvent(product, point, event_id); } diff --git a/chrome/browser/rlz/rlz.h b/chrome/browser/rlz/rlz.h index e41b5a3..aa02d49 100644 --- a/chrome/browser/rlz/rlz.h +++ b/chrome/browser/rlz/rlz.h @@ -20,6 +20,7 @@ #include "content/public/browser/notification_registrar.h" #include "rlz/lib/rlz_lib.h" +class Profile; namespace net { class URLRequestContextGetter; } @@ -41,11 +42,9 @@ class RLZTracker : public content::NotificationObserver { // registers some events when 'first-run' is true. // // If the chrome brand is organic (no partners) then the pings don't occur. - static bool InitRlzDelayed(bool first_run, - int delay, - bool is_google_default_search, - bool is_google_homepage, - bool is_google_in_startpages); + static bool InitRlzFromProfileDelayed(Profile* profile, + bool first_run, + int delay); // Records an RLZ event. Some events can be access point independent. // Returns false it the event could not be recorded. Requires write access @@ -82,6 +81,13 @@ class RLZTracker : public content::NotificationObserver { RLZTracker(); virtual ~RLZTracker(); + // Called by InitRlzFromProfileDelayed with values taken from |profile|. + static bool InitRlzDelayed(bool first_run, + int delay, + bool is_google_default_search, + bool is_google_homepage, + bool is_google_in_startpages); + // Performs initialization of RLZ tracker that is purposefully delayed so // that it does not interfere with chrome startup time. virtual void DelayedInit(); @@ -186,6 +192,10 @@ class RLZTracker : public content::NotificationObserver { bool omnibox_used_; bool homepage_used_; + // Main and (optionally) reactivation brand codes, assigned on UI thread. + std::string brand_; + std::string reactivation_brand_; + content::NotificationRegistrar registrar_; DISALLOW_COPY_AND_ASSIGN(RLZTracker); diff --git a/chrome/browser/rlz/rlz_unittest.cc b/chrome/browser/rlz/rlz_unittest.cc index 165652f..8693091 100644 --- a/chrome/browser/rlz/rlz_unittest.cc +++ b/chrome/browser/rlz/rlz_unittest.cc @@ -96,6 +96,7 @@ AssertionResult CmpHelperSTRNC(const char* str_expression, // overrides others to make it easier to test. class TestRLZTracker : public RLZTracker { public: + using RLZTracker::InitRlzDelayed; using RLZTracker::DelayedInit; using RLZTracker::Observe; @@ -389,7 +390,7 @@ TEST_F(RlzLibTest, RecordProductEvent) { } TEST_F(RlzLibTest, QuickStopAfterStart) { - RLZTracker::InitRlzDelayed(true, 20, true, true, true); + TestRLZTracker::InitRlzDelayed(true, 20, true, true, true); // Omnibox events. ExpectEventRecorded(kOmniboxInstall, false); @@ -405,7 +406,7 @@ TEST_F(RlzLibTest, QuickStopAfterStart) { } TEST_F(RlzLibTest, DelayedInitOnly) { - RLZTracker::InitRlzDelayed(true, 20, true, true, false); + TestRLZTracker::InitRlzDelayed(true, 20, true, true, false); InvokeDelayedInit(); // Omnibox events. @@ -422,7 +423,7 @@ TEST_F(RlzLibTest, DelayedInitOnly) { } TEST_F(RlzLibTest, DelayedInitOnlyGoogleAsStartup) { - RLZTracker::InitRlzDelayed(true, 20, false, false, true); + TestRLZTracker::InitRlzDelayed(true, 20, false, false, true); InvokeDelayedInit(); // Omnibox events. @@ -439,7 +440,7 @@ TEST_F(RlzLibTest, DelayedInitOnlyGoogleAsStartup) { } TEST_F(RlzLibTest, DelayedInitOnlyNoFirstRunNoRlzStrings) { - RLZTracker::InitRlzDelayed(false, 20, true, true, false); + TestRLZTracker::InitRlzDelayed(false, 20, true, true, false); InvokeDelayedInit(); // Omnibox events. @@ -456,7 +457,7 @@ TEST_F(RlzLibTest, DelayedInitOnlyNoFirstRunNoRlzStrings) { } TEST_F(RlzLibTest, DelayedInitOnlyNoFirstRunNoRlzStringsGoogleAsStartup) { - RLZTracker::InitRlzDelayed(false, 20, false, false, true); + TestRLZTracker::InitRlzDelayed(false, 20, false, false, true); InvokeDelayedInit(); // Omnibox events. @@ -478,7 +479,7 @@ TEST_F(RlzLibTest, DelayedInitOnlyNoFirstRun) { rlz_lib::SetAccessPointRlz(RLZTracker::CHROME_OMNIBOX, kOmniboxRlzString); rlz_lib::SetAccessPointRlz(RLZTracker::CHROME_HOME_PAGE, kHomepageRlzString); - RLZTracker::InitRlzDelayed(false, 20, true, true, true); + TestRLZTracker::InitRlzDelayed(false, 20, true, true, true); InvokeDelayedInit(); // Omnibox events. @@ -495,7 +496,7 @@ TEST_F(RlzLibTest, DelayedInitOnlyNoFirstRun) { } TEST_F(RlzLibTest, DelayedInitOnlyNoGoogleDefaultSearchOrHomepageOrStartup) { - RLZTracker::InitRlzDelayed(true, 20, false, false, false); + TestRLZTracker::InitRlzDelayed(true, 20, false, false, false); InvokeDelayedInit(); // Omnibox events. @@ -512,7 +513,7 @@ TEST_F(RlzLibTest, DelayedInitOnlyNoGoogleDefaultSearchOrHomepageOrStartup) { } TEST_F(RlzLibTest, OmniboxUsageOnly) { - RLZTracker::InitRlzDelayed(true, 20, true, true, false); + TestRLZTracker::InitRlzDelayed(true, 20, true, true, false); SimulateOmniboxUsage(); // Omnibox events. @@ -529,7 +530,7 @@ TEST_F(RlzLibTest, OmniboxUsageOnly) { } TEST_F(RlzLibTest, HomepageUsageOnly) { - RLZTracker::InitRlzDelayed(true, 20, true, true, false); + TestRLZTracker::InitRlzDelayed(true, 20, true, true, false); SimulateHomepageUsage(); // Omnibox events. @@ -546,7 +547,7 @@ TEST_F(RlzLibTest, HomepageUsageOnly) { } TEST_F(RlzLibTest, UsageBeforeDelayedInit) { - RLZTracker::InitRlzDelayed(true, 20, true, true, false); + TestRLZTracker::InitRlzDelayed(true, 20, true, true, false); SimulateOmniboxUsage(); SimulateHomepageUsage(); InvokeDelayedInit(); @@ -565,7 +566,7 @@ TEST_F(RlzLibTest, UsageBeforeDelayedInit) { } TEST_F(RlzLibTest, OmniboxUsageAfterDelayedInit) { - RLZTracker::InitRlzDelayed(true, 20, true, true, false); + TestRLZTracker::InitRlzDelayed(true, 20, true, true, false); InvokeDelayedInit(); SimulateOmniboxUsage(); SimulateHomepageUsage(); @@ -584,7 +585,7 @@ TEST_F(RlzLibTest, OmniboxUsageAfterDelayedInit) { } TEST_F(RlzLibTest, OmniboxUsageSendsPingWhenDelayNegative) { - RLZTracker::InitRlzDelayed(true, -20, true, true, false); + TestRLZTracker::InitRlzDelayed(true, -20, true, true, false); SimulateOmniboxUsage(); // Omnibox events. @@ -601,7 +602,7 @@ TEST_F(RlzLibTest, OmniboxUsageSendsPingWhenDelayNegative) { } TEST_F(RlzLibTest, HomepageUsageDoesNotSendPingWhenDelayNegative) { - RLZTracker::InitRlzDelayed(true, -20, true, true, false); + TestRLZTracker::InitRlzDelayed(true, -20, true, true, false); SimulateHomepageUsage(); // Omnibox events. @@ -618,7 +619,7 @@ TEST_F(RlzLibTest, HomepageUsageDoesNotSendPingWhenDelayNegative) { } TEST_F(RlzLibTest, StartupUsageDoesNotSendPingWhenDelayNegative) { - RLZTracker::InitRlzDelayed(true, -20, true, false, true); + TestRLZTracker::InitRlzDelayed(true, -20, true, false, true); SimulateHomepageUsage(); // Omnibox events. @@ -700,7 +701,7 @@ TEST_F(RlzLibTest, PingUpdatesRlzCache) { // Perform ping. tracker_.set_assume_not_ui_thread(true); - RLZTracker::InitRlzDelayed(true, 20, true, true, false); + TestRLZTracker::InitRlzDelayed(true, 20, true, true, false); InvokeDelayedInit(); ExpectRlzPingSent(true); @@ -731,7 +732,7 @@ TEST_F(RlzLibTest, ObserveHandlesBadArgs) { TEST_F(RlzLibTest, ReactivationNonOrganicNonOrganic) { SetReactivationBrand("REAC"); - RLZTracker::InitRlzDelayed(true, 20, true, true, false); + TestRLZTracker::InitRlzDelayed(true, 20, true, true, false); InvokeDelayedInit(); ExpectRlzPingSent(true); @@ -742,7 +743,7 @@ TEST_F(RlzLibTest, ReactivationOrganicNonOrganic) { SetMainBrand("GGLS"); SetReactivationBrand("REAC"); - RLZTracker::InitRlzDelayed(true, 20, true, true, false); + TestRLZTracker::InitRlzDelayed(true, 20, true, true, false); InvokeDelayedInit(); ExpectRlzPingSent(false); @@ -753,7 +754,7 @@ TEST_F(RlzLibTest, ReactivationNonOrganicOrganic) { SetMainBrand("TEST"); SetReactivationBrand("GGLS"); - RLZTracker::InitRlzDelayed(true, 20, true, true, false); + TestRLZTracker::InitRlzDelayed(true, 20, true, true, false); InvokeDelayedInit(); ExpectRlzPingSent(true); @@ -764,7 +765,7 @@ TEST_F(RlzLibTest, ReactivationOrganicOrganic) { SetMainBrand("GGLS"); SetReactivationBrand("GGRS"); - RLZTracker::InitRlzDelayed(true, 20, true, true, false); + TestRLZTracker::InitRlzDelayed(true, 20, true, true, false); InvokeDelayedInit(); ExpectRlzPingSent(false); diff --git a/chrome/browser/ui/webui/chromeos/login/eula_screen_handler.cc b/chrome/browser/ui/webui/chromeos/login/eula_screen_handler.cc index d59997a..1f7a98f 100644 --- a/chrome/browser/ui/webui/chromeos/login/eula_screen_handler.cc +++ b/chrome/browser/ui/webui/chromeos/login/eula_screen_handler.cc @@ -60,16 +60,27 @@ void EulaScreenHandler::GetLocalizedStrings( l10n_util::GetStringUTF16(IDS_EULA_BACK_BUTTON)); localized_strings->SetString("acceptAgreement", l10n_util::GetStringUTF16(IDS_EULA_ACCEPT_AND_CONTINUE_BUTTON)); - localized_strings->SetString("eulaSystemSecuritySetting", - l10n_util::GetStringUTF16(IDS_EULA_SYSTEM_SECURITY_SETTING)); + localized_strings->SetString("eulaSystemInstallationSettings", + l10n_util::GetStringUTF16(IDS_EULA_SYSTEM_INSTALLATION_SETTINGS)); localized_strings->SetString("eulaTpmDesc", - l10n_util::GetStringUTF16(IDS_EULA_SYSTEM_SECURITY_SETTING_DESCRIPTION)); + l10n_util::GetStringUTF16(IDS_EULA_TPM_DESCRIPTION)); localized_strings->SetString("eulaTpmKeyDesc", - l10n_util::GetStringUTF16( - IDS_EULA_SYSTEM_SECURITY_SETTING_DESCRIPTION_KEY)); + l10n_util::GetStringUTF16(IDS_EULA_TPM_KEY_DESCRIPTION)); localized_strings->SetString("eulaTpmBusy", l10n_util::GetStringUTF16(IDS_EULA_TPM_BUSY)); - localized_strings->SetString("eulaTpmOkButton", +#if defined(ENABLE_RLZ) + localized_strings->SetString("eulaRlzDesc", + l10n_util::GetStringFUTF16(IDS_EULA_RLZ_DESCRIPTION, + l10n_util::GetStringUTF16(IDS_SHORT_PRODUCT_NAME), + l10n_util::GetStringUTF16(IDS_PRODUCT_NAME))); + localized_strings->SetString("eulaRlzEnable", + l10n_util::GetStringFUTF16(IDS_EULA_RLZ_ENABLE, + l10n_util::GetStringUTF16(IDS_SHORT_PRODUCT_OS_NAME))); + localized_strings->SetString("rlzEnabled", "enabled"); +#else + localized_strings->SetString("rlzEnabled", "disabled"); +#endif + localized_strings->SetString("eulaSystemInstallationSettingsOkButton", l10n_util::GetStringUTF16(IDS_OK)); } @@ -98,8 +109,8 @@ void EulaScreenHandler::RegisterMessages() { base::Bind(&EulaScreenHandler::HandleOnExit,base::Unretained(this))); web_ui()->RegisterMessageCallback("eulaOnLearnMore", base::Bind(&EulaScreenHandler::HandleOnLearnMore,base::Unretained(this))); - web_ui()->RegisterMessageCallback("eulaOnTpmPopupOpened", - base::Bind(&EulaScreenHandler::HandleOnTpmPopupOpened, + web_ui()->RegisterMessageCallback("eulaOnInstallationSettingsPopupOpened", + base::Bind(&EulaScreenHandler::HandleOnInstallationSettingsPopupOpened, base::Unretained(this))); } @@ -110,20 +121,24 @@ void EulaScreenHandler::OnPasswordFetched(const std::string& tpm_password) { } void EulaScreenHandler::HandleOnExit(const base::ListValue* args) { - DCHECK(args->GetSize() == 2); + DCHECK(args->GetSize() == 3); bool accepted = false; if (!args->GetBoolean(0, &accepted)) NOTREACHED(); - bool is_usage_stats_checked = false; - if (!args->GetBoolean(1, &is_usage_stats_checked)) + bool usage_stats_enabled = false; + if (!args->GetBoolean(1, &usage_stats_enabled)) + NOTREACHED(); + + bool rlz_enabled = false; + if (!args->GetBoolean(2, &rlz_enabled)) NOTREACHED(); if (!delegate_) return; - delegate_->OnExit(accepted, is_usage_stats_checked); + delegate_->OnExit(accepted, usage_stats_enabled, rlz_enabled); } void EulaScreenHandler::HandleOnLearnMore(const base::ListValue* args) { @@ -133,7 +148,8 @@ void EulaScreenHandler::HandleOnLearnMore(const base::ListValue* args) { help_app_->ShowHelpTopic(HelpAppLauncher::HELP_STATS_USAGE); } -void EulaScreenHandler::HandleOnTpmPopupOpened(const base::ListValue* args) { +void EulaScreenHandler::HandleOnInstallationSettingsPopupOpened( + const base::ListValue* args) { if (!delegate_) return; delegate_->InitiatePasswordFetch(); diff --git a/chrome/browser/ui/webui/chromeos/login/eula_screen_handler.h b/chrome/browser/ui/webui/chromeos/login/eula_screen_handler.h index ece1da3..ac05b03 100644 --- a/chrome/browser/ui/webui/chromeos/login/eula_screen_handler.h +++ b/chrome/browser/ui/webui/chromeos/login/eula_screen_handler.h @@ -49,7 +49,7 @@ class EulaScreenHandler : public EulaScreenActor, // JS messages handlers. void HandleOnExit(const base::ListValue* args); void HandleOnLearnMore(const base::ListValue* args); - void HandleOnTpmPopupOpened(const base::ListValue* args); + void HandleOnInstallationSettingsPopupOpened(const base::ListValue* args); Delegate* delegate_; diff --git a/chrome/chrome_browser.gypi b/chrome/chrome_browser.gypi index d83cf0e..1eb1469 100644 --- a/chrome/chrome_browser.gypi +++ b/chrome/chrome_browser.gypi @@ -669,6 +669,8 @@ 'browser/google/google_url_tracker_map_entry.h', 'browser/google/google_util.cc', 'browser/google/google_util.h', + 'browser/google/google_util_chromeos.cc', + 'browser/google/google_util_chromeos.h', 'browser/google_apis/auth_service.cc', 'browser/google_apis/auth_service.h', 'browser/google_apis/auth_service_observer.h', diff --git a/chrome/common/pref_names.cc b/chrome/common/pref_names.cc index 70992b7..84ed580 100644 --- a/chrome/common/pref_names.cc +++ b/chrome/common/pref_names.cc @@ -2163,4 +2163,12 @@ const char kNetworkProfileLastWarningTime[] = // by UMA_HISTOGRAM_ENUMERATION. const char kLastPolicyStatisticsUpdate[] = "policy.last_statistics_update"; +#if defined(OS_CHROMEOS) +// Indicates whether the RLZ tracking has been enabled by user. +const char kRLZEnabled[] = "rlz.enabled"; + +// The RLZ brand code, if enabled. +const char kRLZBrand[] = "rlz.brand"; +#endif + } // namespace prefs diff --git a/chrome/common/pref_names.h b/chrome/common/pref_names.h index 8f3552b..8ba272e 100644 --- a/chrome/common/pref_names.h +++ b/chrome/common/pref_names.h @@ -799,6 +799,11 @@ extern const char kNetworkProfileLastWarningTime[]; extern const char kLastPolicyStatisticsUpdate[]; +#if defined(OS_CHROMEOS) +extern const char kRLZBrand[]; +extern const char kRLZEnabled[]; +#endif + } // namespace prefs #endif // CHROME_COMMON_PREF_NAMES_H_ diff --git a/chrome/test/pyautolib/pyauto.py b/chrome/test/pyautolib/pyauto.py index c05562e..be8f3f2 100755 --- a/chrome/test/pyautolib/pyauto.py +++ b/chrome/test/pyautolib/pyauto.py @@ -4530,7 +4530,8 @@ class PyUITest(pyautolib.PyUITestBase, unittest.TestCase): cmd_dict = { 'command': 'AcceptOOBENetworkScreen' } return self._GetResultFromJSONRequest(cmd_dict, windex=None) - def AcceptOOBEEula(self, accepted, usage_stats_reporting=False): + def AcceptOOBEEula(self, accepted, usage_stats_reporting=False, + rlz_enabled=False): """Accepts OOBE EULA and advances to the next screen. Assumes that we're already at the OOBE EULA screen. @@ -4538,6 +4539,7 @@ class PyUITest(pyautolib.PyUITestBase, unittest.TestCase): Args: accepted: Boolean indicating whether the EULA should be accepted. usage_stats_reporting: Boolean indicating whether UMA should be enabled. + rlz_enabled: Boolean indicating whether RLZ should be enabled. Returns: A dictionary with the following keys: @@ -4549,7 +4551,8 @@ class PyUITest(pyautolib.PyUITestBase, unittest.TestCase): """ cmd_dict = { 'command': 'AcceptOOBEEula', 'accepted': accepted, - 'usage_stats_reporting': usage_stats_reporting } + 'usage_stats_reporting': usage_stats_reporting, + 'rlz_enabled': rlz_enabled } return self._GetResultFromJSONRequest(cmd_dict, windex=None) def CancelOOBEUpdate(self): diff --git a/rlz/lib/financial_ping.cc b/rlz/lib/financial_ping.cc index 9abbd80..1c4d59d 100644 --- a/rlz/lib/financial_ping.cc +++ b/rlz/lib/financial_ping.cc @@ -182,11 +182,6 @@ net::URLRequestContextGetter* g_context; bool FinancialPing::SetURLRequestContext( net::URLRequestContextGetter* context) { - ScopedRlzValueStoreLock lock; - RlzValueStore* store = lock.GetStore(); - if (!store) - return false; - g_context = context; return true; } |