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

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: tony review 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 | « no previous file | no next file » | 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"
11 #include "base/scoped_ptr.h" 11 #include "base/scoped_ptr.h"
12 #include "base/string_util.h" 12 #include "base/string_util.h"
13 #include "base/sys_string_conversions.h"
13 #include "base/utf_string_conversions.h" 14 #include "base/utf_string_conversions.h"
14 #include "base/values.h" 15 #include "base/values.h"
15 #include "chrome/browser/browser_list.h" 16 #include "chrome/browser/browser_list.h"
16 #include "chrome/browser/browser_thread.h" 17 #include "chrome/browser/browser_thread.h"
17 #include "chrome/browser/dom_ui/html_dialog_ui.h" 18 #include "chrome/browser/dom_ui/html_dialog_ui.h"
18 #include "chrome/browser/profiles/profile_manager.h" 19 #include "chrome/browser/profiles/profile_manager.h"
19 #include "chrome/browser/shell_dialogs.h" 20 #include "chrome/browser/shell_dialogs.h"
20 #include "chrome/browser/tab_contents/tab_contents.h" 21 #include "chrome/browser/tab_contents/tab_contents.h"
21 #include "chrome/browser/ui/browser.h" 22 #include "chrome/browser/ui/browser.h"
22 #include "chrome/browser/ui/views/browser_dialogs.h" 23 #include "chrome/browser/ui/views/browser_dialogs.h"
(...skipping 233 matching lines...) Expand 10 before | Expand all | Expand 10 after
256 // Bad json value returned. 257 // Bad json value returned.
257 NOTREACHED(); 258 NOTREACHED();
258 } else { 259 } else {
259 const DictionaryValue* dict = static_cast<DictionaryValue*>(value.get()); 260 const DictionaryValue* dict = static_cast<DictionaryValue*>(value.get());
260 if (delegate->type_ == SELECT_OPEN_FILE || 261 if (delegate->type_ == SELECT_OPEN_FILE ||
261 delegate->type_ == SELECT_SAVEAS_FILE || 262 delegate->type_ == SELECT_SAVEAS_FILE ||
262 delegate->type_ == SELECT_FOLDER) { 263 delegate->type_ == SELECT_FOLDER) {
263 std::string path_string; 264 std::string path_string;
264 if (dict->HasKey(kKeyNamePath) && 265 if (dict->HasKey(kKeyNamePath) &&
265 dict->GetString(kKeyNamePath, &path_string)) { 266 dict->GetString(kKeyNamePath, &path_string)) {
266 FilePath path = FilePath::FromWStringHack(UTF8ToWide(path_string)); 267 FilePath path(
267 268 base::SysWideToNativeMB(base::SysUTF8ToWide(path_string)));
tony 2011/01/13 00:18:17 This won't work on Windows, will it?. FilePath on
evanm 2011/01/13 00:19:23 Yeah, we sorta need a FilePath::FromWStringNotAHac
268 listener_->FileSelected(path, kSaveCompletePageIndex, 269 listener_->FileSelected(path, kSaveCompletePageIndex,
269 delegate->params_); 270 delegate->params_);
270 notification_fired = true; 271 notification_fired = true;
271 } 272 }
272 } else if (delegate->type_ == SELECT_OPEN_MULTI_FILE) { 273 } else if (delegate->type_ == SELECT_OPEN_MULTI_FILE) {
273 ListValue* paths_value = NULL; 274 ListValue* paths_value = NULL;
274 if (dict->HasKey(kKeyNamePath) && 275 if (dict->HasKey(kKeyNamePath) &&
275 dict->GetList(kKeyNamePath, &paths_value) && 276 dict->GetList(kKeyNamePath, &paths_value) &&
276 paths_value) { 277 paths_value) {
277 std::vector<FilePath> paths; 278 std::vector<FilePath> paths;
278 paths.reserve(paths_value->GetSize()); 279 paths.reserve(paths_value->GetSize());
279 for (size_t i = 0; i < paths_value->GetSize(); ++i) { 280 for (size_t i = 0; i < paths_value->GetSize(); ++i) {
280 std::string path_string; 281 std::string path_string;
281 if (paths_value->GetString(i, &path_string) && 282 if (paths_value->GetString(i, &path_string) &&
282 !path_string.empty()) { 283 !path_string.empty()) {
283 paths.push_back(FilePath::FromWStringHack( 284 FilePath path(
284 UTF8ToWide(path_string))); 285 base::SysWideToNativeMB(base::SysUTF8ToWide(path_string)));
286 paths.push_back(path);
285 } 287 }
286 } 288 }
287 289
288 listener_->MultiFilesSelected(paths, delegate->params_); 290 listener_->MultiFilesSelected(paths, delegate->params_);
289 notification_fired = true; 291 notification_fired = true;
290 } 292 }
291 } else { 293 } else {
292 NOTREACHED(); 294 NOTREACHED();
293 } 295 }
294 } 296 }
(...skipping 183 matching lines...) Expand 10 before | Expand all | Expand 10 after
478 // TODO(xiyuan): Change this when the infrastructure is improved. 480 // TODO(xiyuan): Change this when the infrastructure is improved.
479 HtmlDialogUIDelegate** delegate = HtmlDialogUI::GetPropertyAccessor(). 481 HtmlDialogUIDelegate** delegate = HtmlDialogUI::GetPropertyAccessor().
480 GetProperty(dom_ui_->tab_contents()->property_bag()); 482 GetProperty(dom_ui_->tab_contents()->property_bag());
481 HtmlDialogView* containing_view = static_cast<HtmlDialogView*>(*delegate); 483 HtmlDialogView* containing_view = static_cast<HtmlDialogView*>(*delegate);
482 DCHECK(containing_view); 484 DCHECK(containing_view);
483 485
484 containing_view->GetWindow()->UpdateWindowTitle(); 486 containing_view->GetWindow()->UpdateWindowTitle();
485 containing_view->GetWindow()->GetNonClientView()->SchedulePaint(); 487 containing_view->GetWindow()->GetNonClientView()->SchedulePaint();
486 } 488 }
487 } 489 }
OLDNEW
« no previous file with comments | « no previous file | no next file » | no next file with comments »

Powered by Google App Engine
This is Rietveld 408576698