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

Side by Side Diff: ui/shell_dialogs/select_file_dialog_android.cc

Issue 15704005: ui/shell_dialogs: Use base::string16 now that string16 was moved into base namespace. (Closed) Base URL: svn://svn.chromium.org/chrome/trunk/src
Patch Set: Created 7 years, 6 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 "select_file_dialog_android.h" 5 #include "select_file_dialog_android.h"
6 6
7 #include "base/android/jni_android.h" 7 #include "base/android/jni_android.h"
8 #include "base/android/jni_array.h" 8 #include "base/android/jni_array.h"
9 #include "base/android/jni_string.h" 9 #include "base/android/jni_string.h"
10 #include "base/android/scoped_java_ref.h" 10 #include "base/android/scoped_java_ref.h"
11 #include "base/logging.h" 11 #include "base/logging.h"
12 #include "base/string_util.h" 12 #include "base/string_util.h"
13 #include "base/strings/string_split.h" 13 #include "base/strings/string_split.h"
14 #include "base/utf_string_conversions.h" 14 #include "base/utf_string_conversions.h"
15 #include "jni/SelectFileDialog_jni.h" 15 #include "jni/SelectFileDialog_jni.h"
16 #include "ui/android/window_android.h" 16 #include "ui/android/window_android.h"
17 17
18 namespace ui { 18 namespace ui {
19 19
20 // static 20 // static
21 SelectFileDialogImpl* SelectFileDialogImpl::Create(Listener* listener, 21 SelectFileDialogImpl* SelectFileDialogImpl::Create(Listener* listener,
22 ui::SelectFilePolicy* policy) { 22 SelectFilePolicy* policy) {
23 return new SelectFileDialogImpl(listener, policy); 23 return new SelectFileDialogImpl(listener, policy);
24 } 24 }
25 25
26 void SelectFileDialogImpl::OnFileSelected(JNIEnv* env, 26 void SelectFileDialogImpl::OnFileSelected(JNIEnv* env,
27 jobject java_object, 27 jobject java_object,
28 jstring filepath) { 28 jstring filepath) {
29 if (listener_) { 29 if (listener_) {
30 std::string path = base::android::ConvertJavaStringToUTF8(env, filepath); 30 std::string path = base::android::ConvertJavaStringToUTF8(env, filepath);
31 listener_->FileSelected(base::FilePath(path), 0, NULL); 31 listener_->FileSelected(base::FilePath(path), 0, NULL);
32 } 32 }
(...skipping 12 matching lines...) Expand all
45 45
46 bool SelectFileDialogImpl::IsRunning(gfx::NativeWindow) const { 46 bool SelectFileDialogImpl::IsRunning(gfx::NativeWindow) const {
47 return is_running_; 47 return is_running_;
48 } 48 }
49 49
50 void SelectFileDialogImpl::ListenerDestroyed() { 50 void SelectFileDialogImpl::ListenerDestroyed() {
51 listener_ = NULL; 51 listener_ = NULL;
52 } 52 }
53 53
54 void SelectFileDialogImpl::SelectFileImpl( 54 void SelectFileDialogImpl::SelectFileImpl(
55 ui::SelectFileDialog::Type type, 55 SelectFileDialog::Type type,
56 const string16& title, 56 const base::string16& title,
57 const base::FilePath& default_path, 57 const base::FilePath& default_path,
58 const SelectFileDialog::FileTypeInfo* file_types, 58 const SelectFileDialog::FileTypeInfo* file_types,
59 int file_type_index, 59 int file_type_index,
60 const std::string& default_extension, 60 const std::string& default_extension,
61 gfx::NativeWindow owning_window, 61 gfx::NativeWindow owning_window,
62 void* params) { 62 void* params) {
63 JNIEnv* env = base::android::AttachCurrentThread(); 63 JNIEnv* env = base::android::AttachCurrentThread();
64 64
65 ScopedJavaLocalRef<jstring> capture_value; 65 ScopedJavaLocalRef<jstring> capture_value;
66 std::vector<string16> accept_types; 66 std::vector<base::string16> accept_types;
67 if (params) { 67 if (params) {
68 accept_types = *(reinterpret_cast<std::vector<string16>*>(params)); 68 accept_types = *(reinterpret_cast<std::vector<base::string16>*>(params));
69 69
70 // The last string in params is expected to be the string 70 // The last string in params is expected to be the string
71 // with capture value. 71 // with capture value.
72 capture_value = base::android::ConvertUTF16ToJavaString(env, 72 capture_value = base::android::ConvertUTF16ToJavaString(env,
73 StringToLowerASCII(accept_types.back())); 73 StringToLowerASCII(accept_types.back()));
74 base::android::CheckException(env); 74 base::android::CheckException(env);
75 accept_types.pop_back(); 75 accept_types.pop_back();
76 } else { 76 } else {
77 capture_value = base::android::ConvertUTF8ToJavaString(env, "filesystem"); 77 capture_value = base::android::ConvertUTF8ToJavaString(env, "filesystem");
78 } 78 }
(...skipping 10 matching lines...) Expand all
89 } 89 }
90 90
91 bool SelectFileDialogImpl::RegisterSelectFileDialog(JNIEnv* env) { 91 bool SelectFileDialogImpl::RegisterSelectFileDialog(JNIEnv* env) {
92 return RegisterNativesImpl(env); 92 return RegisterNativesImpl(env);
93 } 93 }
94 94
95 SelectFileDialogImpl::~SelectFileDialogImpl() { 95 SelectFileDialogImpl::~SelectFileDialogImpl() {
96 } 96 }
97 97
98 SelectFileDialogImpl::SelectFileDialogImpl(Listener* listener, 98 SelectFileDialogImpl::SelectFileDialogImpl(Listener* listener,
99 ui::SelectFilePolicy* policy) 99 SelectFilePolicy* policy)
100 : ui::SelectFileDialog(listener, policy), 100 : SelectFileDialog(listener, policy), is_running_(false) {
101 is_running_(false) {
102 JNIEnv* env = base::android::AttachCurrentThread(); 101 JNIEnv* env = base::android::AttachCurrentThread();
103 java_object_.Reset( 102 java_object_.Reset(
104 Java_SelectFileDialog_create(env, reinterpret_cast<jint>(this))); 103 Java_SelectFileDialog_create(env, reinterpret_cast<jint>(this)));
105 } 104 }
106 105
107 bool SelectFileDialogImpl::HasMultipleFileTypeChoicesImpl() { 106 bool SelectFileDialogImpl::HasMultipleFileTypeChoicesImpl() {
108 NOTIMPLEMENTED(); 107 NOTIMPLEMENTED();
109 return false; 108 return false;
110 } 109 }
111 110
112 SelectFileDialog* CreateAndroidSelectFileDialog( 111 SelectFileDialog* CreateAndroidSelectFileDialog(
113 SelectFileDialog::Listener* listener, 112 SelectFileDialog::Listener* listener,
114 SelectFilePolicy* policy) { 113 SelectFilePolicy* policy) {
115 return SelectFileDialogImpl::Create(listener, policy); 114 return SelectFileDialogImpl::Create(listener, policy);
116 } 115 }
117 116
118 } // namespace ui 117 } // namespace ui
OLDNEW
« no previous file with comments | « ui/shell_dialogs/select_file_dialog_android.h ('k') | ui/shell_dialogs/select_file_dialog_mac.mm » ('j') | no next file with comments »

Powered by Google App Engine
This is Rietveld 408576698