Chromium Code Reviews
chromiumcodereview-hr@appspot.gserviceaccount.com (chromiumcodereview-hr) | Please choose your nickname with Settings | Help | Chromium Project | Gerrit Changes | Sign out
(708)

Unified Diff: chrome/browser/android/data_usage/data_use_ui_tab_model_factory.cc

Issue 2505343002: Restrict sending GWS ID only to signed in users (Closed)
Patch Set: Rebased Created 3 years, 11 months ago
Use n/p to move between diff chunks; N/P to move between comments. Draft comments are only viewable by you.
Jump to:
View side-by-side diff with in-line comments
Download patch
« no previous file with comments | « no previous file | chrome/browser/android/data_usage/data_use_ui_tab_model_unittest.cc » ('j') | no next file with comments »
Expand Comments ('e') | Collapse Comments ('c') | Show Comments Hide Comments ('s')
Index: chrome/browser/android/data_usage/data_use_ui_tab_model_factory.cc
diff --git a/chrome/browser/android/data_usage/data_use_ui_tab_model_factory.cc b/chrome/browser/android/data_usage/data_use_ui_tab_model_factory.cc
index 4c678d158d7402bdc41c8a6a1b5808a5680dce5b..b3b252db497a0d379f7eb6d3a04e26db976eed8b 100644
--- a/chrome/browser/android/data_usage/data_use_ui_tab_model_factory.cc
+++ b/chrome/browser/android/data_usage/data_use_ui_tab_model_factory.cc
@@ -12,7 +12,9 @@
#include "chrome/browser/browser_process.h"
#include "chrome/browser/io_thread.h"
#include "chrome/browser/profiles/profile.h"
+#include "chrome/browser/signin/signin_manager_factory.h"
#include "components/keyed_service/content/browser_context_dependency_manager.h"
+#include "components/signin/core/browser/signin_manager.h"
#include "content/public/browser/browser_thread.h"
namespace chrome {
@@ -35,6 +37,19 @@ DataUseTabModel* GetDataUseTabModelOnIOThread(IOThread* io_thread) {
return io_thread->globals()->external_data_use_observer->GetDataUseTabModel();
}
+void SetRegisterGoogleVariationIDOnIOThread(IOThread* io_thread,
+ bool register_google_variation_id) {
+ DCHECK_CURRENTLY_ON(content::BrowserThread::IO);
+
+ // Avoid null pointer referencing during browser shutdown.
+ if (io_thread && !io_thread->globals() &&
+ io_thread->globals()->external_data_use_observer) {
+ io_thread->globals()
+ ->external_data_use_observer->SetRegisterGoogleVariationID(
+ register_google_variation_id);
+ }
+}
+
} // namespace
// static
@@ -64,10 +79,12 @@ DataUseUITabModelFactory::~DataUseUITabModelFactory() {}
KeyedService* DataUseUITabModelFactory::BuildServiceInstanceFor(
content::BrowserContext* context) const {
DataUseUITabModel* data_use_ui_tab_model = new DataUseUITabModel();
+ Profile* profile = Profile::FromBrowserContext(context)->GetOriginalProfile();
+ const SigninManager* signin_manager =
+ SigninManagerFactory::GetForProfileIfExists(profile);
// DataUseUITabModel should not be created for incognito profile.
- DCHECK_EQ(Profile::FromBrowserContext(context)->GetOriginalProfile(),
- Profile::FromBrowserContext(context));
+ DCHECK_EQ(profile, Profile::FromBrowserContext(context));
// Pass the DataUseTabModel pointer to DataUseUITabModel.
content::BrowserThread::PostTaskAndReplyWithResult(
@@ -76,6 +93,12 @@ KeyedService* DataUseUITabModelFactory::BuildServiceInstanceFor(
base::Bind(&chrome::android::DataUseUITabModel::SetDataUseTabModel,
data_use_ui_tab_model->GetWeakPtr()));
+ content::BrowserThread::PostTask(
+ content::BrowserThread::IO, FROM_HERE,
+ base::Bind(&SetRegisterGoogleVariationIDOnIOThread,
+ g_browser_process->io_thread(),
+ signin_manager && signin_manager->IsAuthenticated()));
+
return data_use_ui_tab_model;
}
« no previous file with comments | « no previous file | chrome/browser/android/data_usage/data_use_ui_tab_model_unittest.cc » ('j') | no next file with comments »

Powered by Google App Engine
This is Rietveld 408576698