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

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: os guards 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 #if defined(OS_WIN)
267 268 FilePath path(base::SysUTF8ToWide(path_string));
269 #elif defined(OS_CHROMEOS) || (TOOLKIT_VIEWS)
evanm 2011/01/13 00:58:54 I think you meant defined(TOOLKIT_VIEWS) on the
tfarina 2011/01/13 02:07:07 Oh, yeah, got distracted. Using #else now. PTAL!
270 FilePath path(
271 base::SysWideToNativeMB(base::SysUTF8ToWide(path_string)));
272 #endif
268 listener_->FileSelected(path, kSaveCompletePageIndex, 273 listener_->FileSelected(path, kSaveCompletePageIndex,
269 delegate->params_); 274 delegate->params_);
270 notification_fired = true; 275 notification_fired = true;
271 } 276 }
272 } else if (delegate->type_ == SELECT_OPEN_MULTI_FILE) { 277 } else if (delegate->type_ == SELECT_OPEN_MULTI_FILE) {
273 ListValue* paths_value = NULL; 278 ListValue* paths_value = NULL;
274 if (dict->HasKey(kKeyNamePath) && 279 if (dict->HasKey(kKeyNamePath) &&
275 dict->GetList(kKeyNamePath, &paths_value) && 280 dict->GetList(kKeyNamePath, &paths_value) &&
276 paths_value) { 281 paths_value) {
277 std::vector<FilePath> paths; 282 std::vector<FilePath> paths;
278 paths.reserve(paths_value->GetSize()); 283 paths.reserve(paths_value->GetSize());
279 for (size_t i = 0; i < paths_value->GetSize(); ++i) { 284 for (size_t i = 0; i < paths_value->GetSize(); ++i) {
280 std::string path_string; 285 std::string path_string;
281 if (paths_value->GetString(i, &path_string) && 286 if (paths_value->GetString(i, &path_string) &&
282 !path_string.empty()) { 287 !path_string.empty()) {
283 paths.push_back(FilePath::FromWStringHack( 288 #if defined(OS_WIN)
284 UTF8ToWide(path_string))); 289 FilePath path(base::SysUTF8ToWide(path_string));
290 #elif defined(OS_CHROMEOS) || (TOOLKIT_VIEWS)
291 FilePath path(
292 base::SysWideToNativeMB(base::SysUTF8ToWide(path_string)));
293 #endif
294 paths.push_back(path);
285 } 295 }
286 } 296 }
287 297
288 listener_->MultiFilesSelected(paths, delegate->params_); 298 listener_->MultiFilesSelected(paths, delegate->params_);
289 notification_fired = true; 299 notification_fired = true;
290 } 300 }
291 } else { 301 } else {
292 NOTREACHED(); 302 NOTREACHED();
293 } 303 }
294 } 304 }
(...skipping 183 matching lines...) Expand 10 before | Expand all | Expand 10 after
478 // TODO(xiyuan): Change this when the infrastructure is improved. 488 // TODO(xiyuan): Change this when the infrastructure is improved.
479 HtmlDialogUIDelegate** delegate = HtmlDialogUI::GetPropertyAccessor(). 489 HtmlDialogUIDelegate** delegate = HtmlDialogUI::GetPropertyAccessor().
480 GetProperty(dom_ui_->tab_contents()->property_bag()); 490 GetProperty(dom_ui_->tab_contents()->property_bag());
481 HtmlDialogView* containing_view = static_cast<HtmlDialogView*>(*delegate); 491 HtmlDialogView* containing_view = static_cast<HtmlDialogView*>(*delegate);
482 DCHECK(containing_view); 492 DCHECK(containing_view);
483 493
484 containing_view->GetWindow()->UpdateWindowTitle(); 494 containing_view->GetWindow()->UpdateWindowTitle();
485 containing_view->GetWindow()->GetNonClientView()->SchedulePaint(); 495 containing_view->GetWindow()->GetNonClientView()->SchedulePaint();
486 } 496 }
487 } 497 }
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