Chromium Code Reviews| 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/ui/webui/options/chromeos/change_picture_options_handle r.h" | 5 #include "chrome/browser/ui/webui/options/chromeos/change_picture_options_handle r.h" |
| 6 | 6 |
| 7 #include "base/callback.h" | 7 #include "base/callback.h" |
| 8 #include "base/metrics/histogram.h" | |
| 8 #include "base/path_service.h" | 9 #include "base/path_service.h" |
| 9 #include "base/values.h" | 10 #include "base/values.h" |
| 10 #include "chrome/browser/chromeos/login/default_user_images.h" | 11 #include "chrome/browser/chromeos/login/default_user_images.h" |
| 11 #include "chrome/browser/chromeos/login/user_manager.h" | 12 #include "chrome/browser/chromeos/login/user_manager.h" |
| 12 #include "chrome/browser/chromeos/options/take_photo_dialog.h" | 13 #include "chrome/browser/chromeos/options/take_photo_dialog.h" |
| 13 #include "chrome/browser/ui/browser_list.h" | 14 #include "chrome/browser/ui/browser_list.h" |
| 14 #include "chrome/browser/ui/browser_window.h" | 15 #include "chrome/browser/ui/browser_window.h" |
| 15 #include "chrome/browser/ui/views/window.h" | 16 #include "chrome/browser/ui/views/window.h" |
| 16 #include "chrome/common/chrome_paths.h" | 17 #include "chrome/common/chrome_paths.h" |
| 17 #include "grit/generated_resources.h" | 18 #include "grit/generated_resources.h" |
| (...skipping 126 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... | |
| 144 if (!IsDefaultImageUrl(image_url, &user_image_index)) | 145 if (!IsDefaultImageUrl(image_url, &user_image_index)) |
| 145 return; | 146 return; |
| 146 | 147 |
| 147 const SkBitmap* image = ResourceBundle::GetSharedInstance().GetBitmapNamed( | 148 const SkBitmap* image = ResourceBundle::GetSharedInstance().GetBitmapNamed( |
| 148 kDefaultImageResources[user_image_index]); | 149 kDefaultImageResources[user_image_index]); |
| 149 UserManager* user_manager = UserManager::Get(); | 150 UserManager* user_manager = UserManager::Get(); |
| 150 user_manager->SetLoggedInUserImage(*image); | 151 user_manager->SetLoggedInUserImage(*image); |
| 151 user_manager->SaveUserImagePath( | 152 user_manager->SaveUserImagePath( |
| 152 user_manager->logged_in_user().email(), | 153 user_manager->logged_in_user().email(), |
| 153 GetDefaultImagePath(user_image_index)); | 154 GetDefaultImagePath(user_image_index)); |
| 155 UMA_HISTOGRAM_ENUMERATION("UserImage.ChangeChoice", | |
| 156 user_image_index, | |
| 157 kDefaultImagesCount + 2); | |
|
jar (doing other things)
2011/08/10 17:48:52
nit suggestion: Since you name and define (the siz
| |
| 154 } | 158 } |
| 155 | 159 |
| 156 void ChangePictureOptionsHandler::FileSelected(const FilePath& path, | 160 void ChangePictureOptionsHandler::FileSelected(const FilePath& path, |
| 157 int index, | 161 int index, |
| 158 void* params) { | 162 void* params) { |
| 159 UserManager::Get()->LoadLoggedInUserImage(path); | 163 UserManager::Get()->LoadLoggedInUserImage(path); |
| 164 UMA_HISTOGRAM_ENUMERATION("UserImage.ChangeChoice", | |
| 165 kDefaultImagesCount + 1, | |
| 166 kDefaultImagesCount + 2); | |
| 160 } | 167 } |
| 161 | 168 |
| 162 void ChangePictureOptionsHandler::OnPhotoAccepted(const SkBitmap& photo) { | 169 void ChangePictureOptionsHandler::OnPhotoAccepted(const SkBitmap& photo) { |
| 163 UserManager* user_manager = UserManager::Get(); | 170 UserManager* user_manager = UserManager::Get(); |
| 164 DCHECK(user_manager); | 171 DCHECK(user_manager); |
| 165 | 172 |
| 166 const UserManager::User& user = user_manager->logged_in_user(); | 173 const UserManager::User& user = user_manager->logged_in_user(); |
| 167 DCHECK(!user.email().empty()); | 174 DCHECK(!user.email().empty()); |
| 168 | 175 |
| 169 user_manager->SetLoggedInUserImage(photo); | 176 user_manager->SetLoggedInUserImage(photo); |
| 170 user_manager->SaveUserImage(user.email(), photo); | 177 user_manager->SaveUserImage(user.email(), photo); |
| 178 UMA_HISTOGRAM_ENUMERATION("UserImage.ChangeChoice", | |
| 179 kDefaultImagesCount, | |
| 180 kDefaultImagesCount + 2); | |
| 171 } | 181 } |
| 172 | 182 |
| 173 gfx::NativeWindow ChangePictureOptionsHandler::GetBrowserWindow() const { | 183 gfx::NativeWindow ChangePictureOptionsHandler::GetBrowserWindow() const { |
| 174 Browser* browser = BrowserList::FindBrowserWithProfile(web_ui_->GetProfile()); | 184 Browser* browser = BrowserList::FindBrowserWithProfile(web_ui_->GetProfile()); |
| 175 if (!browser) | 185 if (!browser) |
| 176 return NULL; | 186 return NULL; |
| 177 return browser->window()->GetNativeHandle(); | 187 return browser->window()->GetNativeHandle(); |
| 178 } | 188 } |
| 179 | 189 |
| 180 } // namespace chromeos | 190 } // namespace chromeos |
| OLD | NEW |