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

Unified Diff: chrome/browser/themes/theme_service.cc

Issue 22677002: Notify ThemeService via callback when supervised user is ready. (Closed) Base URL: svn://svn.chromium.org/chrome/trunk/src
Patch Set: Rebase to ToT and address nits. Created 7 years, 4 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 | « chrome/browser/themes/theme_service.h ('k') | chrome/browser/themes/theme_service_unittest.cc » ('j') | no next file with comments »
Expand Comments ('e') | Collapse Comments ('c') | Show Comments Hide Comments ('s')
Index: chrome/browser/themes/theme_service.cc
diff --git a/chrome/browser/themes/theme_service.cc b/chrome/browser/themes/theme_service.cc
index fc5c4304a5e31b23549be5169539dc9a01e359e7..fdb02441bd95d939b16997e1ef599ae63302035f 100644
--- a/chrome/browser/themes/theme_service.cc
+++ b/chrome/browser/themes/theme_service.cc
@@ -13,6 +13,8 @@
#include "chrome/browser/chrome_notification_types.h"
#include "chrome/browser/extensions/extension_service.h"
#include "chrome/browser/extensions/extension_system.h"
+#include "chrome/browser/managed_mode/managed_user_service.h"
+#include "chrome/browser/managed_mode/managed_user_service_factory.h"
#include "chrome/browser/managed_mode/managed_user_theme.h"
#include "chrome/browser/profiles/profile.h"
#include "chrome/browser/themes/browser_theme_pack.h"
@@ -77,7 +79,8 @@ ThemeService::ThemeService()
: ready_(false),
rb_(ResourceBundle::GetSharedInstance()),
profile_(NULL),
- number_of_infobars_(0) {
+ number_of_infobars_(0),
+ weak_ptr_factory_(this) {
}
ThemeService::~ThemeService() {
@@ -88,6 +91,9 @@ void ThemeService::Init(Profile* profile) {
DCHECK(CalledOnValidThread());
profile_ = profile;
+ ManagedUserServiceFactory::GetForProfile(profile)->AddInitCallback(base::Bind(
+ &ThemeService::OnManagedUserInitialized, weak_ptr_factory_.GetWeakPtr()));
+
LoadThemePrefs();
if (!ready_) {
@@ -460,6 +466,20 @@ void ThemeService::SetManagedUserTheme() {
SetCustomDefaultTheme(new ManagedUserTheme);
}
+void ThemeService::OnManagedUserInitialized() {
+ // Currently when creating a supervised user, the ThemeService is initialized
+ // before the boolean flag indicating the profile belongs to a supervised
+ // user gets set. In order to get the custom managed user theme, we get a
+ // callback when ManagedUserService is initialized, which happens some time
+ // after the boolean flag has been set in
+ // ProfileManager::InitProfileUserPrefs() and after the
+ // NOTIFICATION_EXTENSIONS_READY notification is sent.
+ if (theme_supplier_.get() || !IsManagedUser())
+ return;
+
+ SetManagedUserTheme();
+}
+
void ThemeService::OnInfobarDisplayed() {
number_of_infobars_++;
}
« no previous file with comments | « chrome/browser/themes/theme_service.h ('k') | chrome/browser/themes/theme_service_unittest.cc » ('j') | no next file with comments »

Powered by Google App Engine
This is Rietveld 408576698