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

Side by Side Diff: chrome/browser/ui/views/select_file_dialog.cc

Issue 6193003: Get rid of FromWStringHack in select_file_dialog.cc (Closed) Base URL: svn://svn.chromium.org/chrome/trunk/src
Patch Set: Created 9 years, 11 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
« no previous file with comments | « base/values.cc ('k') | ipc/ipc_message_utils.cc » ('j') | no next file with comments »
Toggle Intra-line Diffs ('i') | Expand Comments ('e') | Collapse Comments ('c') | Show Comments Hide Comments ('s')
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/shell_dialogs.h" 5 #include "chrome/browser/shell_dialogs.h"
6 6
7 #include "app/l10n_util.h" 7 #include "app/l10n_util.h"
8 #include "base/callback.h" 8 #include "base/callback.h"
9 #include "base/file_path.h" 9 #include "base/file_path.h"
10 #include "base/json/json_reader.h" 10 #include "base/json/json_reader.h"
(...skipping 242 matching lines...) Expand 10 before | Expand all | Expand 10 after
253 if (!json.empty()) { 253 if (!json.empty()) {
254 scoped_ptr<Value> value(base::JSONReader::Read(json, false)); 254 scoped_ptr<Value> value(base::JSONReader::Read(json, false));
255 if (!value.get() || !value->IsType(Value::TYPE_DICTIONARY)) { 255 if (!value.get() || !value->IsType(Value::TYPE_DICTIONARY)) {
256 // Bad json value returned. 256 // Bad json value returned.
257 NOTREACHED(); 257 NOTREACHED();
258 } else { 258 } else {
259 const DictionaryValue* dict = static_cast<DictionaryValue*>(value.get()); 259 const DictionaryValue* dict = static_cast<DictionaryValue*>(value.get());
260 if (delegate->type_ == SELECT_OPEN_FILE || 260 if (delegate->type_ == SELECT_OPEN_FILE ||
261 delegate->type_ == SELECT_SAVEAS_FILE || 261 delegate->type_ == SELECT_SAVEAS_FILE ||
262 delegate->type_ == SELECT_FOLDER) { 262 delegate->type_ == SELECT_FOLDER) {
263 std::string path_string; 263 FilePath path;
264 if (dict->HasKey(kKeyNamePath) && 264 if (dict->HasKey(kKeyNamePath) &&
265 dict->GetString(kKeyNamePath, &path_string)) { 265 dict->GetFilePath(kKeyNamePath, &path)) {
266 FilePath path = FilePath::FromWStringHack(UTF8ToWide(path_string));
tfarina 2011/01/12 01:30:21 Evan, thinking on it again, can't I just do: FileP
267
268 listener_->FileSelected(path, kSaveCompletePageIndex, 266 listener_->FileSelected(path, kSaveCompletePageIndex,
269 delegate->params_); 267 delegate->params_);
270 notification_fired = true; 268 notification_fired = true;
271 } 269 }
272 } else if (delegate->type_ == SELECT_OPEN_MULTI_FILE) { 270 } else if (delegate->type_ == SELECT_OPEN_MULTI_FILE) {
273 ListValue* paths_value = NULL; 271 ListValue* paths_value = NULL;
274 if (dict->HasKey(kKeyNamePath) && 272 if (dict->HasKey(kKeyNamePath) &&
275 dict->GetList(kKeyNamePath, &paths_value) && 273 dict->GetList(kKeyNamePath, &paths_value) &&
276 paths_value) { 274 paths_value) {
277 std::vector<FilePath> paths; 275 std::vector<FilePath> paths;
278 paths.reserve(paths_value->GetSize()); 276 paths.reserve(paths_value->GetSize());
279 for (size_t i = 0; i < paths_value->GetSize(); ++i) { 277 for (size_t i = 0; i < paths_value->GetSize(); ++i) {
280 std::string path_string; 278 FilePath path;
281 if (paths_value->GetString(i, &path_string) && 279 if (paths_value->GetFilePath(i, &path) && !path.empty()) {
282 !path_string.empty()) { 280 paths.push_back(path);
283 paths.push_back(FilePath::FromWStringHack(
284 UTF8ToWide(path_string)));
285 } 281 }
286 } 282 }
287 283
288 listener_->MultiFilesSelected(paths, delegate->params_); 284 listener_->MultiFilesSelected(paths, delegate->params_);
289 notification_fired = true; 285 notification_fired = true;
290 } 286 }
291 } else { 287 } else {
292 NOTREACHED(); 288 NOTREACHED();
293 } 289 }
294 } 290 }
(...skipping 183 matching lines...) Expand 10 before | Expand all | Expand 10 after
478 // TODO(xiyuan): Change this when the infrastructure is improved. 474 // TODO(xiyuan): Change this when the infrastructure is improved.
479 HtmlDialogUIDelegate** delegate = HtmlDialogUI::GetPropertyAccessor(). 475 HtmlDialogUIDelegate** delegate = HtmlDialogUI::GetPropertyAccessor().
480 GetProperty(dom_ui_->tab_contents()->property_bag()); 476 GetProperty(dom_ui_->tab_contents()->property_bag());
481 HtmlDialogView* containing_view = static_cast<HtmlDialogView*>(*delegate); 477 HtmlDialogView* containing_view = static_cast<HtmlDialogView*>(*delegate);
482 DCHECK(containing_view); 478 DCHECK(containing_view);
483 479
484 containing_view->GetWindow()->UpdateWindowTitle(); 480 containing_view->GetWindow()->UpdateWindowTitle();
485 containing_view->GetWindow()->GetNonClientView()->SchedulePaint(); 481 containing_view->GetWindow()->GetNonClientView()->SchedulePaint();
486 } 482 }
487 } 483 }
OLDNEW
« no previous file with comments | « base/values.cc ('k') | ipc/ipc_message_utils.cc » ('j') | no next file with comments »

Powered by Google App Engine
This is Rietveld 408576698