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

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

Issue 2877002: Show tooltips only for users with identical display names.... (Closed) Base URL: svn://chrome-svn/chrome/trunk/src/
Patch Set: '' Created 10 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
« no previous file with comments | « no previous file | chrome/browser/chromeos/login/user_controller.cc » ('j') | no next file with comments »
Toggle Intra-line Diffs ('i') | Expand Comments ('e') | Collapse Comments ('c') | Show Comments Hide Comments ('s')
OLDNEW
1 // Copyright (c) 2010 The Chromium Authors. All rights reserved. 1 // Copyright (c) 2010 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/existing_user_controller.h" 5 #include "chrome/browser/chromeos/login/existing_user_controller.h"
6 6
7 #include <algorithm> 7 #include <algorithm>
8 #include <functional> 8 #include <functional>
9 #include <set> 9 #include <map>
10 10
11 #include "app/l10n_util.h" 11 #include "app/l10n_util.h"
12 #include "app/resource_bundle.h" 12 #include "app/resource_bundle.h"
13 #include "base/message_loop.h" 13 #include "base/message_loop.h"
14 #include "base/stl_util-inl.h" 14 #include "base/stl_util-inl.h"
15 #include "base/utf_string_conversions.h" 15 #include "base/utf_string_conversions.h"
16 #include "chrome/browser/browser_process.h" 16 #include "chrome/browser/browser_process.h"
17 #include "chrome/browser/chrome_thread.h" 17 #include "chrome/browser/chrome_thread.h"
18 #include "chrome/browser/chromeos/cros/cros_library.h" 18 #include "chrome/browser/chromeos/cros/cros_library.h"
19 #include "chrome/browser/chromeos/cros/login_library.h" 19 #include "chrome/browser/chromeos/cros/login_library.h"
(...skipping 31 matching lines...) Expand 10 before | Expand all | Expand 10 after
51 const char kCaptchaTokenParam[] = "CaptchaToken="; 51 const char kCaptchaTokenParam[] = "CaptchaToken=";
52 const char kParamSuffix[] = "\n"; 52 const char kParamSuffix[] = "\n";
53 53
54 // URL prefix for CAPTCHA image. 54 // URL prefix for CAPTCHA image.
55 const char kCaptchaUrlPrefix[] = "http://www.google.com/accounts/"; 55 const char kCaptchaUrlPrefix[] = "http://www.google.com/accounts/";
56 56
57 // Checks if display names are unique. If there are duplicates, enables 57 // Checks if display names are unique. If there are duplicates, enables
58 // tooltips with full emails to let users distinguish their accounts. 58 // tooltips with full emails to let users distinguish their accounts.
59 // Otherwise, disables the tooltips. 59 // Otherwise, disables the tooltips.
60 void EnableTooltipsIfNeeded(const std::vector<UserController*>& controllers) { 60 void EnableTooltipsIfNeeded(const std::vector<UserController*>& controllers) {
61 bool show_name_tooltips = false; 61 std::map<std::string, int> visible_display_names;
62 std::set<std::string> visible_display_names; 62 for (size_t i = 0; i + 1 < controllers.size(); ++i) {
63 for (size_t i = 0; i < controllers.size(); ++i) {
64 const std::string& display_name = 63 const std::string& display_name =
65 controllers[i]->user().GetDisplayName(); 64 controllers[i]->user().GetDisplayName();
66 if (visible_display_names.count(display_name) > 0) { 65 ++visible_display_names[display_name];
67 show_name_tooltips = true;
68 break;
69 }
70 visible_display_names.insert(display_name);
71 } 66 }
72 for (size_t i = 0; i < controllers.size(); ++i) 67 for (size_t i = 0; i + 1 < controllers.size(); ++i) {
73 if (!controllers[i]->is_guest()) 68 const std::string& display_name =
74 controllers[i]->EnableNameTooltip(show_name_tooltips); 69 controllers[i]->user().GetDisplayName();
70 bool show_tooltip = visible_display_names[display_name] > 1;
71 controllers[i]->EnableNameTooltip(show_tooltip);
72 }
75 } 73 }
76 74
77 } // namespace 75 } // namespace
78 76
79 ExistingUserController::ExistingUserController( 77 ExistingUserController::ExistingUserController(
80 const std::vector<UserManager::User>& users, 78 const std::vector<UserManager::User>& users,
81 const gfx::Rect& background_bounds) 79 const gfx::Rect& background_bounds)
82 : background_bounds_(background_bounds), 80 : background_bounds_(background_bounds),
83 background_window_(NULL), 81 background_window_(NULL),
84 background_view_(NULL), 82 background_view_(NULL),
(...skipping 253 matching lines...) Expand 10 before | Expand all | Expand 10 after
338 void ExistingUserController::OnOffTheRecordLoginSuccess() { 336 void ExistingUserController::OnOffTheRecordLoginSuccess() {
339 AppendStartUrlToCmdline(); 337 AppendStartUrlToCmdline();
340 LoginUtils::Get()->CompleteOffTheRecordLogin(); 338 LoginUtils::Get()->CompleteOffTheRecordLogin();
341 } 339 }
342 340
343 void ExistingUserController::OnCaptchaEntered(const std::string& captcha) { 341 void ExistingUserController::OnCaptchaEntered(const std::string& captcha) {
344 login_captcha_ = captcha; 342 login_captcha_ = captcha;
345 } 343 }
346 344
347 } // namespace chromeos 345 } // namespace chromeos
OLDNEW
« no previous file with comments | « no previous file | chrome/browser/chromeos/login/user_controller.cc » ('j') | no next file with comments »

Powered by Google App Engine
This is Rietveld 408576698