OLD | NEW |
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/native_button.h" | 21 #include "views/controls/button/native_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 Loading... |
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 30 matching lines...) Expand all Loading... |
115 | 100 |
116 default_images_view_->Init(); | 101 default_images_view_->Init(); |
117 take_photo_view_->Init(); | 102 take_photo_view_->Init(); |
118 | 103 |
119 UserManager* user_manager = UserManager::Get(); | 104 UserManager* user_manager = UserManager::Get(); |
120 const std::string& logged_in_user = user_manager->logged_in_user().email(); | 105 const std::string& logged_in_user = user_manager->logged_in_user().email(); |
121 int image_index = user_manager->GetUserDefaultImageIndex(logged_in_user); | 106 int image_index = user_manager->GetUserDefaultImageIndex(logged_in_user); |
122 | 107 |
123 default_images_view_->SetDefaultImageIndex(image_index); | 108 default_images_view_->SetDefaultImageIndex(image_index); |
124 | 109 |
125 TriggerPolicyFetch(); | 110 // Notify the policy subsystem that the system is idle enough now for a |
| 111 // policy fetch. (The policy fetch will happen after some delay, see |
| 112 // implementation.) |
| 113 g_browser_process->browser_policy_connector()->ScheduleServiceInitialization( |
| 114 kPolicyServiceInitializationDelayMilliseconds); |
126 } | 115 } |
127 | 116 |
128 void UserImageView::InitLayout() { | 117 void UserImageView::InitLayout() { |
129 views::GridLayout* layout = new views::GridLayout(this); | 118 views::GridLayout* layout = new views::GridLayout(this); |
130 layout->SetInsets(GetInsets()); | 119 layout->SetInsets(GetInsets()); |
131 SetLayoutManager(layout); | 120 SetLayoutManager(layout); |
132 | 121 |
133 // The title, left-top aligned. | 122 // The title, left-top aligned. |
134 views::ColumnSet* column_set = layout->AddColumnSet(kTitleRow); | 123 views::ColumnSet* column_set = layout->AddColumnSet(kTitleRow); |
135 column_set->AddPaddingColumn(0, kHorizontalMargin); | 124 column_set->AddPaddingColumn(0, kHorizontalMargin); |
(...skipping 119 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
255 return; | 244 return; |
256 delegate_->StopCamera(); | 245 delegate_->StopCamera(); |
257 ok_button_->SetEnabled(true); | 246 ok_button_->SetEnabled(true); |
258 ok_button_->RequestFocus(); | 247 ok_button_->RequestFocus(); |
259 take_photo_view_->SetImage( | 248 take_photo_view_->SetImage( |
260 ResourceBundle::GetSharedInstance().GetBitmapNamed( | 249 ResourceBundle::GetSharedInstance().GetBitmapNamed( |
261 kDefaultImageResources[image_index])); | 250 kDefaultImageResources[image_index])); |
262 } | 251 } |
263 | 252 |
264 } // namespace chromeos | 253 } // namespace chromeos |
OLD | NEW |