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

Side by Side Diff: chrome/test/base/testing_profile_manager.cc

Issue 845373002: Change default code flag to NewAvatarMenu. (Closed) Base URL: https://chromium.googlesource.com/chromium/src.git@master
Patch Set: sky@ comments; shess@ nit Created 5 years, 9 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
OLDNEW
1 // Copyright (c) 2012 The Chromium Authors. All rights reserved. 1 // Copyright (c) 2012 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/test/base/testing_profile_manager.h" 5 #include "chrome/test/base/testing_profile_manager.h"
6 6
7 #include "base/files/file_util.h"
7 #include "base/memory/ref_counted.h" 8 #include "base/memory/ref_counted.h"
8 #include "base/strings/utf_string_conversions.h" 9 #include "base/strings/utf_string_conversions.h"
9 #include "chrome/browser/prefs/pref_service_syncable.h" 10 #include "chrome/browser/prefs/pref_service_syncable.h"
11 #include "chrome/browser/profiles/profile_avatar_downloader.h"
12 #include "chrome/browser/profiles/profile_avatar_icon_util.h"
10 #include "chrome/browser/profiles/profile_info_cache.h" 13 #include "chrome/browser/profiles/profile_info_cache.h"
11 #include "chrome/browser/profiles/profile_manager.h" 14 #include "chrome/browser/profiles/profile_manager.h"
12 #include "chrome/common/chrome_constants.h" 15 #include "chrome/common/chrome_constants.h"
13 #include "chrome/test/base/testing_browser_process.h" 16 #include "chrome/test/base/testing_browser_process.h"
14 #include "testing/gtest/include/gtest/gtest.h" 17 #include "testing/gtest/include/gtest/gtest.h"
15 18
16 #if defined(OS_CHROMEOS) 19 #if defined(OS_CHROMEOS)
17 #include "chrome/browser/chromeos/profiles/profile_helper.h" 20 #include "chrome/browser/chromeos/profiles/profile_helper.h"
18 #endif 21 #endif
19 22
(...skipping 70 matching lines...) Expand 10 before | Expand all | Expand 10 after
90 93
91 TestingProfile* profile = builder.Build().release(); 94 TestingProfile* profile = builder.Build().release();
92 profile->set_profile_name(profile_name); 95 profile->set_profile_name(profile_name);
93 profile_manager_->AddProfile(profile); // Takes ownership. 96 profile_manager_->AddProfile(profile); // Takes ownership.
94 97
95 // Update the user metadata. 98 // Update the user metadata.
96 ProfileInfoCache& cache = profile_manager_->GetProfileInfoCache(); 99 ProfileInfoCache& cache = profile_manager_->GetProfileInfoCache();
97 size_t index = cache.GetIndexOfProfileWithPath(profile_path); 100 size_t index = cache.GetIndexOfProfileWithPath(profile_path);
98 cache.SetAvatarIconOfProfileAtIndex(index, avatar_id); 101 cache.SetAvatarIconOfProfileAtIndex(index, avatar_id);
99 cache.SetSupervisedUserIdOfProfileAtIndex(index, supervised_user_id); 102 cache.SetSupervisedUserIdOfProfileAtIndex(index, supervised_user_id);
103
104 // Cache a "high res" icon so we don't try to fetch one over the network.
105 ProfileAvatarDownloader avatar_downloader(
noms (inactive) 2015/03/09 19:26:17 nit: same question as before. Doesn't this run on
Mike Lerman 2015/03/10 15:58:59 Same answer as before. The ProfileAvatarDownloader
106 cache.GetAvatarIconIndexOfProfileAtIndex(index), profile_path, &cache);
107
108 // Put a real bitmap into "bitmap". 2x2 bitmap of green 32 bit pixels.
109 SkBitmap bitmap;
110 bitmap.allocN32Pixels(2, 2);
111 bitmap.eraseColor(SK_ColorGREEN);
112 avatar_downloader.OnFetchComplete(
113 GURL("http://www.google.com/avatar.png"), &bitmap);
114
100 // SetNameOfProfileAtIndex may reshuffle the list of profiles, so we do it 115 // SetNameOfProfileAtIndex may reshuffle the list of profiles, so we do it
101 // last. 116 // last.
102 cache.SetNameOfProfileAtIndex(index, user_name); 117 cache.SetNameOfProfileAtIndex(index, user_name);
103 118
104 testing_profiles_.insert(std::make_pair(profile_name, profile)); 119 testing_profiles_.insert(std::make_pair(profile_name, profile));
105 120
106 return profile; 121 return profile;
107 } 122 }
108 123
109 TestingProfile* TestingProfileManager::CreateTestingProfile( 124 TestingProfile* TestingProfileManager::CreateTestingProfile(
(...skipping 125 matching lines...) Expand 10 before | Expand all | Expand 10 after
235 << "ProfileManager already exists"; 250 << "ProfileManager already exists";
236 251
237 // Set up the directory for profiles. 252 // Set up the directory for profiles.
238 ASSERT_TRUE(profiles_dir_.CreateUniqueTempDir()); 253 ASSERT_TRUE(profiles_dir_.CreateUniqueTempDir());
239 254
240 profile_manager_ = new testing::ProfileManager(profiles_dir_.path()); 255 profile_manager_ = new testing::ProfileManager(profiles_dir_.path());
241 browser_process_->SetProfileManager(profile_manager_); // Takes ownership. 256 browser_process_->SetProfileManager(profile_manager_); // Takes ownership.
242 257
243 called_set_up_ = true; 258 called_set_up_ = true;
244 } 259 }
OLDNEW

Powered by Google App Engine
This is Rietveld 408576698