| OLD | NEW |
| 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/browser/ui/webui/options2/chromeos/change_picture_options_handl
er2.h" | 5 #include "chrome/browser/ui/webui/options2/chromeos/change_picture_options_handl
er2.h" |
| 6 | 6 |
| 7 #include "base/bind.h" | 7 #include "base/bind.h" |
| 8 #include "base/bind_helpers.h" | 8 #include "base/bind_helpers.h" |
| 9 #include "base/command_line.h" | 9 #include "base/command_line.h" |
| 10 #include "base/metrics/histogram.h" | 10 #include "base/metrics/histogram.h" |
| 11 #include "base/path_service.h" | 11 #include "base/path_service.h" |
| 12 #include "base/string_util.h" | 12 #include "base/string_util.h" |
| 13 #include "base/utf_string_conversions.h" | 13 #include "base/utf_string_conversions.h" |
| 14 #include "base/values.h" | 14 #include "base/values.h" |
| 15 #include "chrome/browser/chromeos/login/camera_detector.h" | 15 #include "chrome/browser/chromeos/login/camera_detector.h" |
| 16 #include "chrome/browser/chromeos/login/default_user_images.h" | 16 #include "chrome/browser/chromeos/login/default_user_images.h" |
| 17 #include "chrome/browser/chromeos/login/user_image.h" | 17 #include "chrome/browser/chromeos/login/user_image.h" |
| 18 #include "chrome/browser/chromeos/login/user_manager.h" | 18 #include "chrome/browser/chromeos/login/user_manager.h" |
| 19 #include "chrome/browser/chromeos/options/take_photo_dialog.h" | 19 #include "chrome/browser/chromeos/options/take_photo_dialog.h" |
| 20 #include "chrome/browser/profiles/profile.h" | 20 #include "chrome/browser/profiles/profile.h" |
| 21 #include "chrome/browser/ui/browser_finder.h" | 21 #include "chrome/browser/ui/browser_finder.h" |
| 22 #include "chrome/browser/ui/browser_window.h" | 22 #include "chrome/browser/ui/browser_window.h" |
| 23 #include "chrome/browser/ui/chrome_select_file_policy.h" | |
| 24 #include "chrome/browser/ui/webui/web_ui_util.h" | 23 #include "chrome/browser/ui/webui/web_ui_util.h" |
| 25 #include "chrome/common/chrome_notification_types.h" | 24 #include "chrome/common/chrome_notification_types.h" |
| 26 #include "chrome/common/chrome_paths.h" | 25 #include "chrome/common/chrome_paths.h" |
| 27 #include "chrome/common/chrome_switches.h" | 26 #include "chrome/common/chrome_switches.h" |
| 28 #include "chrome/common/url_constants.h" | 27 #include "chrome/common/url_constants.h" |
| 29 #include "content/public/browser/notification_service.h" | 28 #include "content/public/browser/notification_service.h" |
| 30 #include "content/public/browser/web_ui.h" | 29 #include "content/public/browser/web_ui.h" |
| 31 #include "content/public/common/url_constants.h" | 30 #include "content/public/common/url_constants.h" |
| 32 #include "googleurl/src/gurl.h" | 31 #include "googleurl/src/gurl.h" |
| 33 #include "grit/generated_resources.h" | 32 #include "grit/generated_resources.h" |
| (...skipping 99 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 133 ListValue image_urls; | 132 ListValue image_urls; |
| 134 for (int i = 0; i < kDefaultImagesCount; ++i) { | 133 for (int i = 0; i < kDefaultImagesCount; ++i) { |
| 135 image_urls.Append(new StringValue(GetDefaultImageUrl(i))); | 134 image_urls.Append(new StringValue(GetDefaultImageUrl(i))); |
| 136 } | 135 } |
| 137 web_ui()->CallJavascriptFunction("ChangePictureOptions.setDefaultImages", | 136 web_ui()->CallJavascriptFunction("ChangePictureOptions.setDefaultImages", |
| 138 image_urls); | 137 image_urls); |
| 139 } | 138 } |
| 140 | 139 |
| 141 void ChangePictureOptionsHandler::HandleChooseFile(const ListValue* args) { | 140 void ChangePictureOptionsHandler::HandleChooseFile(const ListValue* args) { |
| 142 DCHECK(args && args->empty()); | 141 DCHECK(args && args->empty()); |
| 143 select_file_dialog_ = SelectFileDialog::Create( | 142 if (!select_file_dialog_.get()) |
| 144 this, new ChromeSelectFilePolicy(web_ui()->GetWebContents())); | 143 select_file_dialog_ = SelectFileDialog::Create(this); |
| 145 | 144 |
| 146 FilePath downloads_path; | 145 FilePath downloads_path; |
| 147 if (!PathService::Get(chrome::DIR_DEFAULT_DOWNLOADS, &downloads_path)) { | 146 if (!PathService::Get(chrome::DIR_DEFAULT_DOWNLOADS, &downloads_path)) { |
| 148 NOTREACHED(); | 147 NOTREACHED(); |
| 149 return; | 148 return; |
| 150 } | 149 } |
| 151 | 150 |
| 152 // Static so we initialize it only once. | 151 // Static so we initialize it only once. |
| 153 CR_DEFINE_STATIC_LOCAL(SelectFileDialog::FileTypeInfo, file_type_info, | 152 CR_DEFINE_STATIC_LOCAL(SelectFileDialog::FileTypeInfo, file_type_info, |
| 154 (GetUserImageFileTypeInfo())); | 153 (GetUserImageFileTypeInfo())); |
| 155 | 154 |
| 156 select_file_dialog_->SelectFile( | 155 select_file_dialog_->SelectFile( |
| 157 SelectFileDialog::SELECT_OPEN_FILE, | 156 SelectFileDialog::SELECT_OPEN_FILE, |
| 158 l10n_util::GetStringUTF16(IDS_DOWNLOAD_TITLE), | 157 l10n_util::GetStringUTF16(IDS_DOWNLOAD_TITLE), |
| 159 downloads_path, | 158 downloads_path, |
| 160 &file_type_info, | 159 &file_type_info, |
| 161 0, | 160 0, |
| 162 FILE_PATH_LITERAL(""), | 161 FILE_PATH_LITERAL(""), |
| 162 web_ui()->GetWebContents(), |
| 163 GetBrowserWindow(), | 163 GetBrowserWindow(), |
| 164 NULL); | 164 NULL); |
| 165 } | 165 } |
| 166 | 166 |
| 167 void ChangePictureOptionsHandler::HandleTakePhoto(const ListValue* args) { | 167 void ChangePictureOptionsHandler::HandleTakePhoto(const ListValue* args) { |
| 168 DCHECK(args && args->empty()); | 168 DCHECK(args && args->empty()); |
| 169 views::Widget* window = views::Widget::CreateWindowWithParent( | 169 views::Widget* window = views::Widget::CreateWindowWithParent( |
| 170 new TakePhotoDialog(this), GetBrowserWindow()); | 170 new TakePhotoDialog(this), GetBrowserWindow()); |
| 171 window->SetAlwaysOnTop(true); | 171 window->SetAlwaysOnTop(true); |
| 172 window->Show(); | 172 window->Show(); |
| (...skipping 240 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 413 OnPhotoAccepted(user_photo_); | 413 OnPhotoAccepted(user_photo_); |
| 414 } | 414 } |
| 415 | 415 |
| 416 void ChangePictureOptionsHandler::OnDecodeImageFailed( | 416 void ChangePictureOptionsHandler::OnDecodeImageFailed( |
| 417 const ImageDecoder* decoder) { | 417 const ImageDecoder* decoder) { |
| 418 NOTREACHED() << "Failed to decode PNG image from WebUI"; | 418 NOTREACHED() << "Failed to decode PNG image from WebUI"; |
| 419 } | 419 } |
| 420 | 420 |
| 421 } // namespace options2 | 421 } // namespace options2 |
| 422 } // namespace chromeos | 422 } // namespace chromeos |
| OLD | NEW |