| 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/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 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 42 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 127 | 112 |
| 128 default_images_view_->Init(); | 113 default_images_view_->Init(); |
| 129 take_photo_view_->Init(); | 114 take_photo_view_->Init(); |
| 130 | 115 |
| 131 UserManager* user_manager = UserManager::Get(); | 116 UserManager* user_manager = UserManager::Get(); |
| 132 const std::string& logged_in_user = user_manager->logged_in_user().email(); | 117 const std::string& logged_in_user = user_manager->logged_in_user().email(); |
| 133 int image_index = user_manager->GetUserDefaultImageIndex(logged_in_user); | 118 int image_index = user_manager->GetUserDefaultImageIndex(logged_in_user); |
| 134 | 119 |
| 135 default_images_view_->SetDefaultImageIndex(image_index); | 120 default_images_view_->SetDefaultImageIndex(image_index); |
| 136 | 121 |
| 137 TriggerPolicyFetch(); | 122 // Notify the policy subsystem that the system is idle enough now for a |
| 123 // policy fetch. (The policy fetch will happen after some delay, see |
| 124 // implementation.) |
| 125 g_browser_process->browser_policy_connector()->ScheduleServiceInitialization( |
| 126 kPolicyServiceInitializationDelayMilliseconds); |
| 138 } | 127 } |
| 139 | 128 |
| 140 void UserImageView::InitLayout() { | 129 void UserImageView::InitLayout() { |
| 141 views::GridLayout* layout = new views::GridLayout(this); | 130 views::GridLayout* layout = new views::GridLayout(this); |
| 142 layout->SetInsets(GetInsets()); | 131 layout->SetInsets(GetInsets()); |
| 143 SetLayoutManager(layout); | 132 SetLayoutManager(layout); |
| 144 | 133 |
| 145 // The title, left-top aligned. | 134 // The title, left-top aligned. |
| 146 views::ColumnSet* column_set = layout->AddColumnSet(kTitleRow); | 135 views::ColumnSet* column_set = layout->AddColumnSet(kTitleRow); |
| 147 column_set->AddPaddingColumn(0, kHorizontalMargin); | 136 column_set->AddPaddingColumn(0, kHorizontalMargin); |
| (...skipping 146 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 294 return; | 283 return; |
| 295 delegate_->StopCamera(); | 284 delegate_->StopCamera(); |
| 296 ok_button_->SetEnabled(true); | 285 ok_button_->SetEnabled(true); |
| 297 ok_button_->RequestFocus(); | 286 ok_button_->RequestFocus(); |
| 298 take_photo_view_->SetImage( | 287 take_photo_view_->SetImage( |
| 299 ResourceBundle::GetSharedInstance().GetBitmapNamed( | 288 ResourceBundle::GetSharedInstance().GetBitmapNamed( |
| 300 kDefaultImageResources[image_index])); | 289 kDefaultImageResources[image_index])); |
| 301 } | 290 } |
| 302 | 291 |
| 303 } // namespace chromeos | 292 } // namespace chromeos |
| OLD | NEW |