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

Side by Side Diff: chrome/browser/chromeos/login/user_image_view.cc

Issue 7147015: Move user cloud policy to BrowserProcess (was 6979011) (Closed) Base URL: svn://svn.chromium.org/chrome/trunk/src
Patch Set: fix unit_test include breakage Created 9 years, 5 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 unified diff | Download patch | Annotate | Revision Log
OLDNEW
1 // Copyright (c) 2011 The Chromium Authors. All rights reserved. 1 // Copyright (c) 2011 The Chromium Authors. All rights reserved.
2 // Use of this source code is governed by a BSD-style license that can be 2 // Use of this source code is governed by a BSD-style license that can be
3 // found in the LICENSE file. 3 // found in the LICENSE file.
4 4
5 #include "chrome/browser/chromeos/login/user_image_view.h" 5 #include "chrome/browser/chromeos/login/user_image_view.h"
6 6
7 #include "base/utf_string_conversions.h" 7 #include "base/utf_string_conversions.h"
8 #include "chrome/browser/browser_process.h" 8 #include "chrome/browser/browser_process.h"
9 #include "chrome/browser/chromeos/login/default_images_view.h" 9 #include "chrome/browser/chromeos/login/default_images_view.h"
10 #include "chrome/browser/chromeos/login/default_user_images.h" 10 #include "chrome/browser/chromeos/login/default_user_images.h"
11 #include "chrome/browser/chromeos/login/helper.h" 11 #include "chrome/browser/chromeos/login/helper.h"
12 #include "chrome/browser/chromeos/login/rounded_rect_painter.h" 12 #include "chrome/browser/chromeos/login/rounded_rect_painter.h"
13 #include "chrome/browser/chromeos/login/user_manager.h" 13 #include "chrome/browser/chromeos/login/user_manager.h"
14 #include "chrome/browser/policy/profile_policy_connector.h" 14 #include "chrome/browser/policy/browser_policy_connector.h"
15 #include "chrome/browser/policy/profile_policy_connector_factory.h"
16 #include "chrome/browser/profiles/profile_manager.h"
17 #include "grit/generated_resources.h" 15 #include "grit/generated_resources.h"
18 #include "grit/theme_resources.h" 16 #include "grit/theme_resources.h"
19 #include "ui/base/l10n/l10n_util.h" 17 #include "ui/base/l10n/l10n_util.h"
20 #include "ui/base/resource/resource_bundle.h" 18 #include "ui/base/resource/resource_bundle.h"
21 #include "ui/gfx/canvas.h" 19 #include "ui/gfx/canvas.h"
22 #include "views/background.h" 20 #include "views/background.h"
23 #include "views/controls/button/text_button.h" 21 #include "views/controls/button/text_button.h"
24 #include "views/controls/label.h" 22 #include "views/controls/label.h"
25 #include "views/layout/grid_layout.h" 23 #include "views/layout/grid_layout.h"
26 24
(...skipping 25 matching lines...) Expand all
52 kSplitterRow, // Place for the splitter. 50 kSplitterRow, // Place for the splitter.
53 kButtonsRow, // Column set for OK button. 51 kButtonsRow, // Column set for OK button.
54 }; 52 };
55 53
56 views::View* CreateSplitter(const SkColor& color) { 54 views::View* CreateSplitter(const SkColor& color) {
57 views::View* splitter = new views::View(); 55 views::View* splitter = new views::View();
58 splitter->set_background(views::Background::CreateSolidBackground(color)); 56 splitter->set_background(views::Background::CreateSolidBackground(color));
59 return splitter; 57 return splitter;
60 } 58 }
61 59
62 void TriggerPolicyFetch() {
63 // Notify all the profiles that the system is idle enough now for a policy
64 // fetch. (The policy fetch will happen after some delay, see implementation.)
65 ProfileManager* profile_manager = g_browser_process->profile_manager();
66 std::vector<Profile*> profiles = profile_manager->GetLoadedProfiles();
67 std::vector<Profile*>::iterator it;
68 for (it = profiles.begin(); it != profiles.end(); ++it) {
69 policy::ProfilePolicyConnectorFactory::GetForProfile(*it)->
70 ScheduleServiceInitialization(
71 kPolicyServiceInitializationDelayMilliseconds);
72 }
73 }
74
75 } // namespace 60 } // namespace
76 61
77 namespace chromeos { 62 namespace chromeos {
78 63
79 UserImageView::UserImageView(Delegate* delegate) 64 UserImageView::UserImageView(Delegate* delegate)
80 : title_label_(NULL), 65 : title_label_(NULL),
81 default_images_view_(NULL), 66 default_images_view_(NULL),
82 take_photo_view_(NULL), 67 take_photo_view_(NULL),
83 splitter_(NULL), 68 splitter_(NULL),
84 ok_button_(NULL), 69 ok_button_(NULL),
(...skipping 43 matching lines...) Expand 10 before | Expand all | Expand 10 after
128 113
129 default_images_view_->Init(); 114 default_images_view_->Init();
130 take_photo_view_->Init(); 115 take_photo_view_->Init();
131 116
132 UserManager* user_manager = UserManager::Get(); 117 UserManager* user_manager = UserManager::Get();
133 const std::string& logged_in_user = user_manager->logged_in_user().email(); 118 const std::string& logged_in_user = user_manager->logged_in_user().email();
134 int image_index = user_manager->GetUserDefaultImageIndex(logged_in_user); 119 int image_index = user_manager->GetUserDefaultImageIndex(logged_in_user);
135 120
136 default_images_view_->SetDefaultImageIndex(image_index); 121 default_images_view_->SetDefaultImageIndex(image_index);
137 122
138 TriggerPolicyFetch(); 123 // Notify the policy subsystem that the system is idle enough now for a
124 // policy fetch. (The policy fetch will happen after some delay, see
125 // implementation.)
126 g_browser_process->browser_policy_connector()->ScheduleServiceInitialization(
127 kPolicyServiceInitializationDelayMilliseconds);
139 } 128 }
140 129
141 void UserImageView::InitLayout() { 130 void UserImageView::InitLayout() {
142 views::GridLayout* layout = new views::GridLayout(this); 131 views::GridLayout* layout = new views::GridLayout(this);
143 layout->SetInsets(GetInsets()); 132 layout->SetInsets(GetInsets());
144 SetLayoutManager(layout); 133 SetLayoutManager(layout);
145 134
146 // The title, left-top aligned. 135 // The title, left-top aligned.
147 views::ColumnSet* column_set = layout->AddColumnSet(kTitleRow); 136 views::ColumnSet* column_set = layout->AddColumnSet(kTitleRow);
148 column_set->AddPaddingColumn(0, kHorizontalMargin); 137 column_set->AddPaddingColumn(0, kHorizontalMargin);
(...skipping 146 matching lines...) Expand 10 before | Expand all | Expand 10 after
295 return; 284 return;
296 delegate_->StopCamera(); 285 delegate_->StopCamera();
297 ok_button_->SetEnabled(true); 286 ok_button_->SetEnabled(true);
298 ok_button_->RequestFocus(); 287 ok_button_->RequestFocus();
299 take_photo_view_->SetImage( 288 take_photo_view_->SetImage(
300 ResourceBundle::GetSharedInstance().GetBitmapNamed( 289 ResourceBundle::GetSharedInstance().GetBitmapNamed(
301 kDefaultImageResources[image_index])); 290 kDefaultImageResources[image_index]));
302 } 291 }
303 292
304 } // namespace chromeos 293 } // namespace chromeos
OLDNEW

Powered by Google App Engine
This is Rietveld 408576698