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

Side by Side Diff: chrome/browser/ui/webui/options2/chromeos/change_picture_options_handler2.cc

Issue 10667026: Start consolidating cross-port file selection code into ui/base/dialogs. (Closed) Base URL: svn://svn.chromium.org/chrome/trunk/src
Patch Set: Attempt to fix win Created 8 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
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/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"
23 #include "chrome/browser/ui/webui/web_ui_util.h" 24 #include "chrome/browser/ui/webui/web_ui_util.h"
24 #include "chrome/common/chrome_notification_types.h" 25 #include "chrome/common/chrome_notification_types.h"
25 #include "chrome/common/chrome_paths.h" 26 #include "chrome/common/chrome_paths.h"
26 #include "chrome/common/chrome_switches.h" 27 #include "chrome/common/chrome_switches.h"
27 #include "chrome/common/url_constants.h" 28 #include "chrome/common/url_constants.h"
28 #include "content/public/browser/notification_service.h" 29 #include "content/public/browser/notification_service.h"
29 #include "content/public/browser/web_ui.h" 30 #include "content/public/browser/web_ui.h"
30 #include "content/public/common/url_constants.h" 31 #include "content/public/common/url_constants.h"
31 #include "googleurl/src/gurl.h" 32 #include "googleurl/src/gurl.h"
32 #include "grit/generated_resources.h" 33 #include "grit/generated_resources.h"
(...skipping 99 matching lines...) Expand 10 before | Expand all | Expand 10 after
132 ListValue image_urls; 133 ListValue image_urls;
133 for (int i = 0; i < kDefaultImagesCount; ++i) { 134 for (int i = 0; i < kDefaultImagesCount; ++i) {
134 image_urls.Append(new StringValue(GetDefaultImageUrl(i))); 135 image_urls.Append(new StringValue(GetDefaultImageUrl(i)));
135 } 136 }
136 web_ui()->CallJavascriptFunction("ChangePictureOptions.setDefaultImages", 137 web_ui()->CallJavascriptFunction("ChangePictureOptions.setDefaultImages",
137 image_urls); 138 image_urls);
138 } 139 }
139 140
140 void ChangePictureOptionsHandler::HandleChooseFile(const ListValue* args) { 141 void ChangePictureOptionsHandler::HandleChooseFile(const ListValue* args) {
141 DCHECK(args && args->empty()); 142 DCHECK(args && args->empty());
142 if (!select_file_dialog_.get()) 143 select_file_dialog_ = SelectFileDialog::Create(
143 select_file_dialog_ = SelectFileDialog::Create(this); 144 this, new ChromeSelectFilePolicy(web_ui()->GetWebContents()));
144 145
145 FilePath downloads_path; 146 FilePath downloads_path;
146 if (!PathService::Get(chrome::DIR_DEFAULT_DOWNLOADS, &downloads_path)) { 147 if (!PathService::Get(chrome::DIR_DEFAULT_DOWNLOADS, &downloads_path)) {
147 NOTREACHED(); 148 NOTREACHED();
148 return; 149 return;
149 } 150 }
150 151
151 // Static so we initialize it only once. 152 // Static so we initialize it only once.
152 CR_DEFINE_STATIC_LOCAL(SelectFileDialog::FileTypeInfo, file_type_info, 153 CR_DEFINE_STATIC_LOCAL(SelectFileDialog::FileTypeInfo, file_type_info,
153 (GetUserImageFileTypeInfo())); 154 (GetUserImageFileTypeInfo()));
154 155
155 select_file_dialog_->SelectFile( 156 select_file_dialog_->SelectFile(
156 SelectFileDialog::SELECT_OPEN_FILE, 157 SelectFileDialog::SELECT_OPEN_FILE,
157 l10n_util::GetStringUTF16(IDS_DOWNLOAD_TITLE), 158 l10n_util::GetStringUTF16(IDS_DOWNLOAD_TITLE),
158 downloads_path, 159 downloads_path,
159 &file_type_info, 160 &file_type_info,
160 0, 161 0,
161 FILE_PATH_LITERAL(""), 162 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
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
OLDNEW

Powered by Google App Engine
This is Rietveld 408576698