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

Side by Side Diff: chrome/browser/ui/webui/options/personal_options_handler.cc

Issue 8539043: Refactor ProfileInfoCache (Closed) Base URL: svn://svn.chromium.org/chrome/trunk/src
Patch Set: Created 9 years, 1 month 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/ui/webui/options/personal_options_handler.h" 5 #include "chrome/browser/ui/webui/options/personal_options_handler.h"
6 6
7 #include <string> 7 #include <string>
8 8
9 #include "base/basictypes.h" 9 #include "base/basictypes.h"
10 #include "base/bind.h" 10 #include "base/bind.h"
11 #include "base/command_line.h" 11 #include "base/command_line.h"
12 #include "base/path_service.h" 12 #include "base/path_service.h"
13 #include "base/stl_util.h" 13 #include "base/stl_util.h"
14 #include "base/string_number_conversions.h" 14 #include "base/string_number_conversions.h"
15 #include "base/utf_string_conversions.h" 15 #include "base/utf_string_conversions.h"
16 #include "base/value_conversions.h" 16 #include "base/value_conversions.h"
17 #include "base/values.h" 17 #include "base/values.h"
18 #include "build/build_config.h" 18 #include "build/build_config.h"
19 #include "chrome/browser/browser_process.h" 19 #include "chrome/browser/browser_process.h"
20 #include "chrome/browser/google/google_util.h" 20 #include "chrome/browser/google/google_util.h"
21 #include "chrome/browser/profiles/profile.h" 21 #include "chrome/browser/profiles/profile.h"
22 #include "chrome/browser/profiles/profile_info_util.h"
22 #include "chrome/browser/profiles/profile_info_cache.h" 23 #include "chrome/browser/profiles/profile_info_cache.h"
23 #include "chrome/browser/profiles/profile_manager.h" 24 #include "chrome/browser/profiles/profile_manager.h"
24 #include "chrome/browser/sync/profile_sync_service.h" 25 #include "chrome/browser/sync/profile_sync_service.h"
25 #include "chrome/browser/sync/sync_setup_flow.h" 26 #include "chrome/browser/sync/sync_setup_flow.h"
26 #include "chrome/browser/sync/sync_ui_util.h" 27 #include "chrome/browser/sync/sync_ui_util.h"
27 #include "chrome/browser/themes/theme_service.h" 28 #include "chrome/browser/themes/theme_service.h"
28 #include "chrome/browser/themes/theme_service_factory.h" 29 #include "chrome/browser/themes/theme_service_factory.h"
29 #include "chrome/common/chrome_notification_types.h" 30 #include "chrome/common/chrome_notification_types.h"
30 #include "chrome/common/chrome_paths.h" 31 #include "chrome/common/chrome_paths.h"
31 #include "chrome/common/chrome_switches.h" 32 #include "chrome/common/chrome_switches.h"
(...skipping 365 matching lines...) Expand 10 before | Expand all | Expand 10 after
397 } 398 }
398 } 399 }
399 #endif 400 #endif
400 401
401 void PersonalOptionsHandler::SendProfilesInfo() { 402 void PersonalOptionsHandler::SendProfilesInfo() {
402 ProfileInfoCache& cache = 403 ProfileInfoCache& cache =
403 g_browser_process->profile_manager()->GetProfileInfoCache(); 404 g_browser_process->profile_manager()->GetProfileInfoCache();
404 ListValue profile_info_list; 405 ListValue profile_info_list;
405 FilePath current_profile_path = 406 FilePath current_profile_path =
406 web_ui_->tab_contents()->browser_context()->GetPath(); 407 web_ui_->tab_contents()->browser_context()->GetPath();
407 for (size_t i = 0, e = cache.GetNumberOfProfiles(); i < e; ++i) { 408
408 DictionaryValue* profile_value = new DictionaryValue(); 409 const std::vector<ProfileInfoEntry> entries(cache.GetProfilesSortedByName());
409 size_t icon_index = cache.GetAvatarIconIndexOfProfileAtIndex(i); 410 for (std::vector<ProfileInfoEntry>::const_iterator it = entries.begin();
410 FilePath profile_path = cache.GetPathOfProfileAtIndex(i); 411 it != entries.end(); ++it) {
411 profile_value->SetString("name", cache.GetNameOfProfileAtIndex(i)); 412 DictionaryValue* value = new DictionaryValue();
412 profile_value->SetString("iconURL", 413 value->SetString("name", it->name());
413 cache.GetDefaultAvatarIconUrl(icon_index)); 414 value->SetString("iconURL",
414 profile_value->Set("filePath", base::CreateFilePathValue(profile_path)); 415 profiles::GetDefaultAvatarIconUrl(it->icon_index()));
415 profile_value->SetBoolean("isCurrentProfile", 416 value->Set("filePath", base::CreateFilePathValue(it->path()));
416 profile_path == current_profile_path); 417 value->SetBoolean("isCurrentProfile", it->path() == current_profile_path);
417 profile_info_list.Append(profile_value); 418 profile_info_list.Append(value);
418 } 419 }
419 420
420 web_ui_->CallJavascriptFunction("PersonalOptions.setProfilesInfo", 421 web_ui_->CallJavascriptFunction("PersonalOptions.setProfilesInfo",
421 profile_info_list); 422 profile_info_list);
422 } 423 }
423 424
424 void PersonalOptionsHandler::CreateProfile(const ListValue* args) { 425 void PersonalOptionsHandler::CreateProfile(const ListValue* args) {
425 ProfileManager::CreateMultiProfileAsync(); 426 ProfileManager::CreateMultiProfileAsync();
426 } 427 }
OLDNEW
« no previous file with comments | « chrome/browser/ui/webui/options/manage_profile_handler.cc ('k') | chrome/browser/ui/webui/sync_setup_handler.cc » ('j') | no next file with comments »

Powered by Google App Engine
This is Rietveld 408576698