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_controller.h" | 5 #include "chrome/browser/chromeos/login/user_controller.h" |
6 | 6 |
7 #include <algorithm> | 7 #include <algorithm> |
8 #include <vector> | 8 #include <vector> |
9 | 9 |
10 #include "base/utf_string_conversions.h" | 10 #include "base/utf_string_conversions.h" |
11 #include "chrome/browser/chromeos/cros_settings.h" | |
11 #include "chrome/browser/chromeos/login/existing_user_view.h" | 12 #include "chrome/browser/chromeos/login/existing_user_view.h" |
12 #include "chrome/browser/chromeos/login/guest_user_view.h" | 13 #include "chrome/browser/chromeos/login/guest_user_view.h" |
13 #include "chrome/browser/chromeos/login/helper.h" | 14 #include "chrome/browser/chromeos/login/helper.h" |
14 #include "chrome/browser/chromeos/login/rounded_rect_painter.h" | 15 #include "chrome/browser/chromeos/login/rounded_rect_painter.h" |
15 #include "chrome/browser/chromeos/login/user_view.h" | 16 #include "chrome/browser/chromeos/login/user_view.h" |
16 #include "chrome/browser/chromeos/login/username_view.h" | 17 #include "chrome/browser/chromeos/login/username_view.h" |
17 #include "chrome/browser/chromeos/login/wizard_accessibility_helper.h" | 18 #include "chrome/browser/chromeos/login/wizard_accessibility_helper.h" |
18 #include "chrome/browser/chromeos/login/wizard_controller.h" | 19 #include "chrome/browser/chromeos/login/wizard_controller.h" |
19 #include "chrome/browser/chromeos/user_cros_settings_provider.h" | |
20 #include "grit/generated_resources.h" | 20 #include "grit/generated_resources.h" |
21 #include "grit/theme_resources.h" | 21 #include "grit/theme_resources.h" |
22 #include "third_party/cros_system_api/window_manager/chromeos_wm_ipc_enums.h" | 22 #include "third_party/cros_system_api/window_manager/chromeos_wm_ipc_enums.h" |
23 #include "ui/base/l10n/l10n_util.h" | 23 #include "ui/base/l10n/l10n_util.h" |
24 #include "ui/base/resource/resource_bundle.h" | 24 #include "ui/base/resource/resource_bundle.h" |
25 #include "ui/gfx/canvas.h" | 25 #include "ui/gfx/canvas.h" |
26 #include "views/background.h" | 26 #include "views/background.h" |
27 #include "views/controls/label.h" | 27 #include "views/controls/label.h" |
28 #include "views/controls/throbber.h" | 28 #include "views/controls/throbber.h" |
29 #include "views/focus/focus_manager.h" | 29 #include "views/focus/focus_manager.h" |
(...skipping 18 matching lines...) Expand all Loading... | |
48 #endif | 48 #endif |
49 | 49 |
50 // Vertical interval between the image and the textfield. | 50 // Vertical interval between the image and the textfield. |
51 const int kVerticalIntervalSize = 10; | 51 const int kVerticalIntervalSize = 10; |
52 | 52 |
53 void CloseWindow(views::Widget* window) { | 53 void CloseWindow(views::Widget* window) { |
54 if (window) | 54 if (window) |
55 window->CloseNow(); | 55 window->CloseNow(); |
56 } | 56 } |
57 | 57 |
58 // Helper function to initialize the is_owner_ const field of UserController. | |
59 bool VerifyOwnership(const std::string& email) { | |
60 // Empty owner string means that owner hasn't been cached yet, not that owner | |
61 // has an empty email. | |
62 // TODO(pastarmovj): Consider switching to TrustedGet here. | |
63 std::string owner; | |
64 return CrosSettings::Get()->GetString(kDeviceOwner, &owner) && | |
65 (email == owner); | |
66 } | |
67 | |
58 } // namespace | 68 } // namespace |
59 | 69 |
60 // WidgetDelegate implementation for the Widget used for the controls. | 70 // WidgetDelegate implementation for the Widget used for the controls. |
61 class UserController::ControlsWidgetDelegate : public views::WidgetDelegate { | 71 class UserController::ControlsWidgetDelegate : public views::WidgetDelegate { |
62 public: | 72 public: |
63 ControlsWidgetDelegate(UserController* controller, | 73 ControlsWidgetDelegate(UserController* controller, |
64 views::View* view) | 74 views::View* view) |
65 : controller_(controller), | 75 : controller_(controller), |
66 view_(view) { | 76 view_(view) { |
67 } | 77 } |
(...skipping 50 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... | |
118 user_input_(NULL), | 128 user_input_(NULL), |
119 throbber_host_(NULL) { | 129 throbber_host_(NULL) { |
120 } | 130 } |
121 | 131 |
122 UserController::UserController(Delegate* delegate, | 132 UserController::UserController(Delegate* delegate, |
123 const UserManager::User& user) | 133 const UserManager::User& user) |
124 : user_index_(-1), | 134 : user_index_(-1), |
125 is_user_selected_(false), | 135 is_user_selected_(false), |
126 is_new_user_(false), | 136 is_new_user_(false), |
127 is_guest_(false), | 137 is_guest_(false), |
128 // Empty 'cached_owner()' means that owner hasn't been cached yet, not | 138 is_owner_(VerifyOwnership(user.email())), |
Mattias Nissler (ping if slow)
2011/09/21 11:12:59
same comment as before regarding the inaccuracy of
pastarmovj
2011/09/23 15:19:32
I already have a todo to consider switching this t
| |
129 // that owner has an empty email. | |
130 is_owner_(user.email() == UserCrosSettingsProvider::cached_owner()), | |
131 show_name_tooltip_(false), | 139 show_name_tooltip_(false), |
132 user_(user), | 140 user_(user), |
133 delegate_(delegate), | 141 delegate_(delegate), |
134 controls_widget_(NULL), | 142 controls_widget_(NULL), |
135 image_widget_(NULL), | 143 image_widget_(NULL), |
136 border_window_(NULL), | 144 border_window_(NULL), |
137 label_widget_(NULL), | 145 label_widget_(NULL), |
138 unselected_label_widget_(NULL), | 146 unselected_label_widget_(NULL), |
139 user_view_(NULL), | 147 user_view_(NULL), |
140 label_view_(NULL), | 148 label_view_(NULL), |
(...skipping 381 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... | |
522 string16 UserController::GetNameTooltip() const { | 530 string16 UserController::GetNameTooltip() const { |
523 if (is_new_user_) | 531 if (is_new_user_) |
524 return l10n_util::GetStringUTF16(IDS_ADD_USER); | 532 return l10n_util::GetStringUTF16(IDS_ADD_USER); |
525 else if (is_guest_) | 533 else if (is_guest_) |
526 return l10n_util::GetStringUTF16(IDS_GO_INCOGNITO_BUTTON); | 534 return l10n_util::GetStringUTF16(IDS_GO_INCOGNITO_BUTTON); |
527 else | 535 else |
528 return UTF8ToUTF16(user_.GetNameTooltip()); | 536 return UTF8ToUTF16(user_.GetNameTooltip()); |
529 } | 537 } |
530 | 538 |
531 } // namespace chromeos | 539 } // namespace chromeos |
OLD | NEW |