Hello nicolasroard, jripley,
I'd like you to do a code review. Please execute
g4 diff -c 9449903
or point your web browser to
http://mondrian/9449903
to review the following code:
Change 9449903 by andr...@andreip-gearslinux on 2008/12/17 17:31:09 *pending*
Gracefully support the case where the Java classes for
FilePicker API are not present on the Android device.
PRESUBMIT=passed
R=nicolasroard,jripley
[email protected]
DELTA=23 (20 added, 0 deleted, 3 changed)
OCL=9449903
Affected files ...
...
//depot/googleclient/gears/opensource/gears/desktop/file_dialog_android.cc#1
edit
... //depot/googleclient/gears/opensource/gears/desktop/file_dialog_android.h#1
edit
23 delta lines: 20 added, 0 deleted, 3 changed
Also consider running:
g4 lint -c 9449903
which verifies that the changelist doesn't introduce new style violations.
If you can't do the review, please let me know as soon as possible. During
your review, please ensure that all new code has corresponding unit tests and
that existing unit tests are updated appropriately. Visit
http://www/eng/code_review.html for more information.
This is a semiautomated message from "g4 mail". Complaints or suggestions?
Mail [email protected].
Change 9449903 by andr...@andreip-gearslinux on 2008/12/17 17:31:09 *pending*
Gracefully support the case where the Java classes for
FilePicker API are not present on the Android device.
Affected files ...
...
//depot/googleclient/gears/opensource/gears/desktop/file_dialog_android.cc#1
edit
... //depot/googleclient/gears/opensource/gears/desktop/file_dialog_android.h#1
edit
====
//depot/googleclient/gears/opensource/gears/desktop/file_dialog_android.cc#1 -
/home/andreip/Gears/googleclient/gears/opensource/gears/desktop/file_dialog_android.cc
====
# action=edit type=text
--- googleclient/gears/opensource/gears/desktop/file_dialog_android.cc
2008-12-17 17:31:37.000000000 +0000
+++ googleclient/gears/opensource/gears/desktop/file_dialog_android.cc
2008-12-17 17:29:10.000000000 +0000
@@ -160,7 +160,14 @@
data.release());
}
-FileDialogAndroid::FileDialogAndroid() {
+FileDialogAndroid::FileDialogAndroid() : supported_(false) {
+ JavaClass java_dialog_class;
+ if (!java_dialog_class.FindClass(kNativeDialogClass)) {
+ LOG(("Couldn't load the NativeDialog class!\n"));
+ return;
+ }
+
+ supported_ = true;
// We register the native method callback
static bool isRegistered;
if (isRegistered == false) {
@@ -188,6 +195,11 @@
bool FileDialogAndroid::BeginSelection(NativeWindowPtr parent,
const FileDialog::Options& options,
std::string16* error) {
+ if (!supported_) {
+ *error = STRING16(L"File API not supported.");
+ return false;
+ }
+
if (!SetOptions(options, error))
return false;
if (!Display(error))
@@ -208,6 +220,8 @@
bool FileDialogAndroid::SetOptions(const FileDialog::Options& options,
std::string16* error) {
+ if (!supported_) return false;
+
StringList filter = options.filter;
Json::Value json_options;
Json::Value array;
@@ -235,6 +249,8 @@
}
jobject FileDialogAndroid::GetContext() {
+ if (!supported_) return NULL;
+
JavaLocalFrame frame;
jobject context = NULL;
jobject java_webview = NULL;
@@ -248,13 +264,13 @@
// get the JavaClass for WebView
if (!java_webview_class.FindClass(kWebviewClass)) {
LOG(("Couldn't load the WebView class\n"));
- return false;
+ return NULL;
}
if (!java_webview_class.GetMultipleMethodIDs(webview_methods,
NELEM(webview_methods))) {
LOG(("Couldn't get WebView methods\n"));
- return false;
+ return NULL;
}
// call getContext()
@@ -265,6 +281,8 @@
}
bool FileDialogAndroid::Display(std::string16* error) {
+ if (!supported_) return false;
+
JavaLocalFrame frame;
jobject context = GetContext();
====
//depot/googleclient/gears/opensource/gears/desktop/file_dialog_android.h#1 -
/home/andreip/Gears/googleclient/gears/opensource/gears/desktop/file_dialog_android.h
====
# action=edit type=text
--- googleclient/gears/opensource/gears/desktop/file_dialog_android.h
2008-12-17 17:31:37.000000000 +0000
+++ googleclient/gears/opensource/gears/desktop/file_dialog_android.h
2008-12-17 17:14:11.000000000 +0000
@@ -69,6 +69,8 @@
// options string (json-formatted) sent to the java side.
std::string options_;
+ // Weather this API is supported (i.e. Java counterpart class is present).
+ bool supported_;
DISALLOW_EVIL_CONSTRUCTORS(FileDialogAndroid);
};