• R/O
  • SSH
  • HTTPS

nicoro: Commit


Commit MetaInfo

Revisão570 (tree)
Hora2013-01-14 16:11:22
Autorshisei123

Mensagem de Log

セキュリティ上の問題によりaddJavascriptInterfaceを削除
PC版QプレイヤーでHTML内メニューが出ていなかった問題を修正

Mudança Sumário

Diff

--- trunk/NicoRo/src/jp/sourceforge/nicoro/WebBrowserFragment.java (revision 569)
+++ trunk/NicoRo/src/jp/sourceforge/nicoro/WebBrowserFragment.java (revision 570)
@@ -51,6 +51,8 @@
5151 import android.view.ViewGroup;
5252 import android.webkit.CookieManager;
5353 import android.webkit.CookieSyncManager;
54+import android.webkit.JsPromptResult;
55+import android.webkit.JsResult;
5456 import android.webkit.WebBackForwardList;
5557 import android.webkit.WebChromeClient;
5658 import android.webkit.WebSettings;
@@ -67,6 +69,7 @@
6769 import java.io.UnsupportedEncodingException;
6870 import java.net.MalformedURLException;
6971 import java.net.URL;
72+import java.net.URLDecoder;
7073 import java.net.URLEncoder;
7174 import java.text.DecimalFormat;
7275 import java.util.ArrayList;
@@ -146,6 +149,52 @@
146149
147150 private static final String TAG_VIDEO_CACHE_SERVICE = "WebBrowserFragment";
148151
152+ /** window.alert/prompt でJavaScript側から送る特殊コマンドのプリフィックス */
153+ private static final String JS_CMD_PRE = "nicorojs_";
154+ private static final int JS_CMD_PRE_LEN = JS_CMD_PRE.length();
155+
156+ // window.alert系
157+ private static final String JS_CMD_LOG = "log:";
158+ private static final int JS_CMD_LOG_LEN = JS_CMD_LOG.length();
159+ private static final String JS_CMD_LOG_LINES = "logLines:";
160+ private static final int JS_CMD_LOG_LINES_LEN = JS_CMD_LOG_LINES.length();
161+ private static final String JS_CMD_GET_RSS = "getRss:";
162+ private static final int JS_CMD_GET_RSS_LEN = JS_CMD_GET_RSS.length();
163+ private static final String JS_CMD_START_PLAY = "startPlay:";
164+ private static final String JS_CMD_START_PLAY_MID = "startPlayMid:";
165+ private static final String JS_CMD_START_PLAY_LOW = "startPlayLow:";
166+ private static final String JS_CMD_START_CACHE = "startCache:";
167+ private static final String JS_CMD_START_CACHE_MID = "startCacheMid:";
168+ private static final String JS_CMD_START_CACHE_LOW = "startCacheLow:";
169+ private static final String JS_CMD_RELATED_VIDEO = "relatedVideo:";
170+ private static final String JS_CMD_STOP_CACHE = "stopCache:";
171+ private static final String JS_CMD_DELETE_CACHE = "deleteCache:";
172+ private static final String JS_CMD_ADD_MYLIST = "addMylist:";
173+ private static final String JS_CMD_START_JIKKYO = "startJikkyo:";
174+ private static final String JS_CMD_START_LIVE = "startLive:";
175+ private static final String JS_CMD_GO_BACK = "goBack:";
176+ private static final String JS_CMD_GET_STREAM_DESCRIPTION = "getStreamDescription:";
177+ private static final int JS_CMD_GET_STREAM_DESCRIPTION_LEN = JS_CMD_GET_STREAM_DESCRIPTION.length();
178+ private static final String JS_CMD_GET_OFFSET_FLVPLAYER_CONTAINER = "getOffsetFlvplayerContainer:";
179+ private static final int JS_CMD_GET_OFFSET_FLVPLAYER_CONTAINER_LEN = JS_CMD_GET_OFFSET_FLVPLAYER_CONTAINER.length();
180+ private static final String JS_CMD_START_READ_VIDEO = "startReadVideo:";
181+ private static final int JS_CMD_START_READ_VIDEO_LEN = JS_CMD_START_READ_VIDEO.length();
182+ private static final String JS_CMD_READ_VIDEO = "readVideo:";
183+ private static final int JS_CMD_READ_VIDEO_LEN = JS_CMD_READ_VIDEO.length();
184+ private static final String JS_CMD_END_READ_VIDEO = "endReadVideo:";
185+ private static final String JS_CMD_READ_WATCH_API_DATA_CONTAINER = "readWatchAPIDataContainer:";
186+ private static final int JS_CMD_READ_WATCH_API_DATA_CONTAINER_LEN = JS_CMD_READ_WATCH_API_DATA_CONTAINER.length();
187+ private static final String JS_CMD_FAIL_READ_VIDEO = "failReadVideo:";
188+ private static final int JS_CMD_FAIL_READ_VIDEO_LEN = JS_CMD_FAIL_READ_VIDEO.length();
189+
190+ // window.prompt系
191+ private static final String JS_CMD_GET_FLVPLAYER_CONTAINER_HTML = "getFlvplayerContainerHtml:";
192+ private static final int JS_CMD_GET_FLVPLAYER_CONTAINER_HTML_LEN = JS_CMD_GET_FLVPLAYER_CONTAINER_HTML.length();
193+ private static final String JS_CMD_GET_NICOPLAYER_CONTAINER_INNER_HTML = "getNicoplayerContainerInnerHtml:";
194+ private static final int JS_CMD_GET_NICOPLAYER_CONTAINER_INNER_HTML_LEN = JS_CMD_GET_NICOPLAYER_CONTAINER_INNER_HTML.length();
195+ private static final String JS_CMD_GET_PLAYER_BOX_HTML = "getPlayerboxHtml:";
196+ private static final int JS_CMD_GET_PLAYER_BOX_HTML_LEN = JS_CMD_GET_PLAYER_BOX_HTML.length();
197+
149198 private class NicoroWebChromeClient extends WebChromeClient {
150199 @Override
151200 public void onProgressChanged(WebView view, int newProgress) {
@@ -268,6 +317,30 @@
268317 }
269318 // onChangePage(view, view.getUrl());
270319 }
320+
321+ @Override
322+ public boolean onJsAlert(WebView view, String url, String message, JsResult result) {
323+ if (mJsObj.onJsAlertCommand(message)) {
324+ result.confirm();
325+ return true;
326+ } else {
327+ return super.onJsAlert(view, url, message, result);
328+ }
329+ }
330+
331+ @Override
332+ public boolean onJsPrompt(WebView view, String url, String message, String defaultValue,
333+ JsPromptResult result) {
334+ String resultString = mJsObj.onJsPromptCommand(message);
335+ if (resultString != null) {
336+ result.confirm(resultString);
337+ return true;
338+ } else {
339+ return super.onJsPrompt(view, url, message, defaultValue, result);
340+ }
341+ }
342+
343+
271344 }
272345 private class NicoroWebViewClient extends WebViewClient {
273346 @Override
@@ -366,7 +439,8 @@
366439 mWasJsCalled = true;
367440
368441 if (DEBUG_LOGD) {
369- view.loadUrl("javascript:nicoro.logLines(document.documentElement.outerHTML)");
442+ view.loadUrl("javascript:{ var log = 'nicorojs_logLines:' + document.documentElement.outerHTML;"
443+ + "window.alert(log);}");
370444 }
371445 }
372446
@@ -1453,7 +1527,7 @@
14531527 initializeWebSettings(webView.getSettings());
14541528 webView.setWebChromeClient(new NicoroWebChromeClient());
14551529 webView.setWebViewClient(new NicoroWebViewClient());
1456- webView.addJavascriptInterface(mJsObj, "nicoro");
1530+ // addJavascriptInterfaceはAndroid 4.2以前ではセキュリティ上の問題があるため使わない
14571531
14581532 registerForContextMenu(webView);
14591533 }
@@ -3356,8 +3430,151 @@
33563430 private String mVideoUrl;
33573431 private EnableMenuJudge mEnableMenuJudgeFlvplayerContainer = new EnableMenuJudge();
33583432
3359- @SuppressWarnings("unused")
3360- public void getRss(String url, String title) {
3433+ /**
3434+ * window.alert を使ってJavaScript側から呼ばれるコールバックコマンド
3435+ * @param message window.alertの引数
3436+ * @return コマンドとして消費したらtrue
3437+ */
3438+ public boolean onJsAlertCommand(String message) {
3439+ if (message.startsWith(JS_CMD_PRE)) {
3440+ try {
3441+ int index = JS_CMD_PRE_LEN;
3442+ if (DEBUG_LOGD && message.startsWith(JS_CMD_LOG, index)) {
3443+ index += JS_CMD_LOG_LEN;
3444+ Log.d(LOG_TAG, message.substring(index));
3445+ } else if (DEBUG_LOGD && message.startsWith(JS_CMD_LOG_LINES, index)) {
3446+ index += JS_CMD_LOG_LINES_LEN;
3447+ Log.dLines(LOG_TAG, message.substring(index));
3448+ } else if (message.startsWith(JS_CMD_GET_RSS, index)) {
3449+ index += JS_CMD_GET_RSS_LEN;
3450+ String[] params = message.substring(index).split(" ");
3451+ if (params.length >= 2) {
3452+ String urlRss = URLDecoder.decode(
3453+ params[0], "UTF-8");
3454+ String titleRss = URLDecoder.decode(
3455+ params[1], "UTF-8");
3456+ getRss(urlRss, titleRss);
3457+ }
3458+ } else if (message.startsWith(JS_CMD_START_PLAY, index)) {
3459+ mHandler.obtainMessage(MSG_ID_ACTION_START_PLAY,
3460+ ECO_TYPE_HIGH, 0)
3461+ .sendToTarget();
3462+ } else if (message.startsWith(JS_CMD_START_PLAY_MID, index)) {
3463+ mHandler.obtainMessage(MSG_ID_ACTION_START_PLAY,
3464+ ECO_TYPE_MID, 0)
3465+ .sendToTarget();
3466+ } else if (message.startsWith(JS_CMD_START_PLAY_LOW, index)) {
3467+ mHandler.obtainMessage(MSG_ID_ACTION_START_PLAY,
3468+ ECO_TYPE_LOW, 0)
3469+ .sendToTarget();
3470+ } else if (message.startsWith(JS_CMD_START_CACHE, index)) {
3471+ mHandler.obtainMessage(MSG_ID_ACTION_START_CACHE,
3472+ ECO_TYPE_HIGH, 0)
3473+ .sendToTarget();
3474+ } else if (message.startsWith(JS_CMD_START_CACHE_MID, index)) {
3475+ mHandler.obtainMessage(MSG_ID_ACTION_START_CACHE,
3476+ ECO_TYPE_MID, 0)
3477+ .sendToTarget();
3478+ } else if (message.startsWith(JS_CMD_START_CACHE_LOW, index)) {
3479+ mHandler.obtainMessage(MSG_ID_ACTION_START_CACHE,
3480+ ECO_TYPE_LOW, 0)
3481+ .sendToTarget();
3482+ } else if (message.startsWith(JS_CMD_RELATED_VIDEO, index)) {
3483+ mHandler.sendEmptyMessage(MSG_ID_ACTION_RELATED_VIDEO);
3484+ } else if (message.startsWith(JS_CMD_STOP_CACHE, index)) {
3485+ mHandler.sendEmptyMessage(MSG_ID_ACTION_STOP_CACHE);
3486+ } else if (message.startsWith(JS_CMD_DELETE_CACHE, index)) {
3487+ mHandler.sendEmptyMessage(MSG_ID_ACTION_DELETE_CACHE);
3488+ } else if (message.startsWith(JS_CMD_ADD_MYLIST, index)) {
3489+ mHandler.sendEmptyMessage(MSG_ID_ACTION_ADD_MYLIST);
3490+ } else if (message.startsWith(JS_CMD_START_JIKKYO, index)) {
3491+ mHandler.sendEmptyMessage(MSG_ID_ACTION_START_JIKKYO);
3492+ } else if (message.startsWith(JS_CMD_START_LIVE, index)) {
3493+ mHandler.sendEmptyMessage(MSG_ID_ACTION_START_LIVE);
3494+ } else if (message.startsWith(JS_CMD_GO_BACK, index)) {
3495+ mHandler.sendEmptyMessage(MSG_ID_GO_BACK_WEBVIEW);
3496+ } else if (message.startsWith(JS_CMD_GET_STREAM_DESCRIPTION, index)) {
3497+ index += JS_CMD_GET_STREAM_DESCRIPTION_LEN;
3498+ getStreamDescription(message.substring(index));
3499+ } else if (message.startsWith(JS_CMD_GET_OFFSET_FLVPLAYER_CONTAINER, index)) {
3500+ index += JS_CMD_GET_OFFSET_FLVPLAYER_CONTAINER_LEN;
3501+ String[] params = message.substring(index).split(" ");
3502+ if (params.length >= 4) {
3503+ int offsetLeft = Integer.parseInt(params[0]);
3504+ int offsetTop = Integer.parseInt(params[1]);
3505+ int offsetWidth = Integer.parseInt(params[2]);
3506+ int offsetHeight = Integer.parseInt(params[3]);
3507+ getOffsetFlvplayerContainer(offsetLeft, offsetTop,
3508+ offsetWidth, offsetHeight);
3509+ }
3510+ } else if (message.startsWith(JS_CMD_START_READ_VIDEO, index)) {
3511+ index += JS_CMD_START_READ_VIDEO_LEN;
3512+ startReadVideo(message.substring(index));
3513+ } else if (message.startsWith(JS_CMD_READ_VIDEO, index)) {
3514+ index += JS_CMD_READ_VIDEO_LEN;
3515+ String[] params = message.substring(index).split(" ");
3516+ if (params.length >= 2) {
3517+ String prop = URLDecoder.decode(
3518+ params[0], "UTF-8");
3519+ String value = URLDecoder.decode(
3520+ params[1], "UTF-8");
3521+ readVideo(prop, value);
3522+ }
3523+ } else if (message.startsWith(JS_CMD_END_READ_VIDEO, index)) {
3524+ endReadVideo();
3525+ } else if (message.startsWith(JS_CMD_READ_WATCH_API_DATA_CONTAINER, index)) {
3526+ index += JS_CMD_READ_WATCH_API_DATA_CONTAINER_LEN;
3527+ String[] params = message.substring(index).split(" ");
3528+ if (params.length >= 2) {
3529+ String urlForLog = URLDecoder.decode(
3530+ params[0], "UTF-8");
3531+ String watchAPIDataContainer = URLDecoder.decode(
3532+ params[1], "UTF-8");
3533+ readWatchAPIDataContainer(urlForLog, watchAPIDataContainer);
3534+ }
3535+ } else if (message.startsWith(JS_CMD_FAIL_READ_VIDEO, index)) {
3536+ index += JS_CMD_FAIL_READ_VIDEO_LEN;
3537+ failReadVideo(message.substring(index));
3538+ }
3539+ } catch (UnsupportedEncodingException e) {
3540+ Log.e(LOG_TAG, e.toString(), e);
3541+ } catch (NumberFormatException e) {
3542+ Log.e(LOG_TAG, e.toString(), e);
3543+ }
3544+
3545+ return true;
3546+ } else {
3547+ return false;
3548+ }
3549+ }
3550+
3551+ /**
3552+ * window.prompt を使ってJavaScript側から呼ばれるコールバックコマンド
3553+ * @param message window.promptの引数
3554+ * @return コマンドとして消費した場合は結果として返すString。そうれでなければnull
3555+ */
3556+ public String onJsPromptCommand(String message) {
3557+ String resultString = null;
3558+ if (message.startsWith(JS_CMD_PRE)) {
3559+ int index = JS_CMD_PRE_LEN;
3560+ if (message.startsWith(JS_CMD_GET_FLVPLAYER_CONTAINER_HTML, index)) {
3561+ index += JS_CMD_GET_FLVPLAYER_CONTAINER_HTML_LEN;
3562+ String urlCurrent = message.substring(index);
3563+ resultString = mJsObj.getFlvplayerContainerHtml(urlCurrent);
3564+ } else if (message.startsWith(JS_CMD_GET_NICOPLAYER_CONTAINER_INNER_HTML, index)) {
3565+ index += JS_CMD_GET_NICOPLAYER_CONTAINER_INNER_HTML_LEN;
3566+ String urlCurrent = message.substring(index);
3567+ resultString = mJsObj.getNicoplayerContainerInnerHtml(urlCurrent);
3568+ } else if (message.startsWith(JS_CMD_GET_PLAYER_BOX_HTML, index)) {
3569+ index += JS_CMD_GET_PLAYER_BOX_HTML_LEN;
3570+ String urlCurrent = message.substring(index);
3571+ resultString = mJsObj.getPlayerboxHtml(urlCurrent);
3572+ }
3573+ }
3574+ return resultString;
3575+ }
3576+
3577+ private void getRss(String url, String title) {
33613578 urlRss = url;
33623579 titleRss = title;
33633580 if (DEBUG_LOGD) {
@@ -3367,8 +3584,7 @@
33673584 mHandler.sendEmptyMessage(MSG_ID_UPDATE_OPTIONS_MENU);
33683585 }
33693586
3370- @SuppressWarnings("unused")
3371- public String getFlvplayerContainerHtml(String url) {
3587+ private String getFlvplayerContainerHtml(String url) {
33723588 StringBuilder builder = new StringBuilder();
33733589 builder.append("<div style=\"").append(DIV_STYLE).append("\">");
33743590 getFlvplayerContainerMain(builder, url);
@@ -3377,113 +3593,54 @@
33773593 return builder.toString();
33783594 }
33793595
3380- @SuppressWarnings("unused")
3381- public String getNicoplayerContainerInnerHtml(String url) {
3596+ private String getNicoplayerContainerInnerHtml(String url) {
33823597 StringBuilder builder = new StringBuilder();
33833598 builder.append("<div style=\"").append(DIV_STYLE).append("\">");
33843599 getFlvplayerContainerMain(builder, url);
33853600
3386- WatchVideo wv = mVideo;
3387- if (wv == null) {
3388- wv = mLiveVideo;
3389- }
3601+// WatchVideo wv = mVideo;
3602+// if (wv == null) {
3603+// wv = mLiveVideo;
3604+// }
3605+//
3606+// if (wv != null) {
3607+// Resources res = mContext.getResources();
3608+// String description = wv.description();
3609+// if (description != null) {
3610+// builder.append("<br /><p><strong style=\"")
3611+// .append(STRONG_STYLE).append("\">")
3612+// .append(res.getString(R.string.video_description))
3613+// .append(":</strong><br />")
3614+// .append(description).append("</p>");
3615+// }
3616+// ArrayList<WatchVideo.TagList> tagList = wv.getTagList();
3617+// if (tagList != null) {
3618+// builder.append("<br /><p><strong style=\"")
3619+// .append(STRONG_STYLE).append("\">")
3620+// .append(res.getString(R.string.tag)).append(":</strong><br />");
3621+// for (WatchVideo.TagList tag : tagList) {
3622+// if (!TextUtils.isEmpty(tag.tag)) {
3623+// builder.append("<a href=\"/tag/")
3624+// .append(tag.tag).append("\">")
3625+// .append(tag.tag).append("</a>");
3626+// if (tag.dic) {
3627+// builder.append("<a href=\"").append(URL_DIC_A)
3628+// .append(tag.tag).append("\"><img src=\"")
3629+// .append(URL_ICON_DIC_ON).append("\" alt=\"大百科\" /></a>");
3630+// }
3631+// builder.append("&nbsp;&nbsp;");
3632+// }
3633+// }
3634+// builder.append("</p>");
3635+// }
3636+// }
33903637
3391- if (wv != null) {
3392- Resources res = mContext.getResources();
3393- String description = wv.description();
3394- if (description != null) {
3395- builder.append("<br /><p><strong style=\"")
3396- .append(STRONG_STYLE).append("\">")
3397- .append(res.getString(R.string.video_description))
3398- .append(":</strong><br />")
3399- .append(description).append("</p>");
3400- }
3401- ArrayList<WatchVideo.TagList> tagList = wv.getTagList();
3402- if (tagList != null) {
3403- builder.append("<br /><p><strong style=\"")
3404- .append(STRONG_STYLE).append("\">")
3405- .append(res.getString(R.string.tag)).append(":</strong><br />");
3406- for (WatchVideo.TagList tag : tagList) {
3407- if (!TextUtils.isEmpty(tag.tag)) {
3408- builder.append("<a href=\"/tag/")
3409- .append(tag.tag).append("\">")
3410- .append(tag.tag).append("</a>");
3411- if (tag.dic) {
3412- builder.append("<a href=\"").append(URL_DIC_A)
3413- .append(tag.tag).append("\"><img src=\"")
3414- .append(URL_ICON_DIC_ON).append("\" alt=\"大百科\" /></a>");
3415- }
3416- builder.append("&nbsp;&nbsp;");
3417- }
3418- }
3419- builder.append("</p>");
3420- }
3421- }
3422-
34233638 builder.append("</div>");
34243639
34253640 return builder.toString();
34263641 }
34273642
3428- @SuppressWarnings("unused")
3429- public void startPlay() {
3430- mHandler.obtainMessage(MSG_ID_ACTION_START_PLAY,
3431- ECO_TYPE_HIGH, 0)
3432- .sendToTarget();
3433- }
3434- @SuppressWarnings("unused")
3435- public void startPlayMid() {
3436- mHandler.obtainMessage(MSG_ID_ACTION_START_PLAY,
3437- ECO_TYPE_MID, 0)
3438- .sendToTarget();
3439- }
3440- @SuppressWarnings("unused")
3441- public void startPlayLow() {
3442- mHandler.obtainMessage(MSG_ID_ACTION_START_PLAY,
3443- ECO_TYPE_LOW, 0)
3444- .sendToTarget();
3445- }
3446- @SuppressWarnings("unused")
3447- public void startCache() {
3448- mHandler.obtainMessage(MSG_ID_ACTION_START_CACHE,
3449- ECO_TYPE_HIGH, 0)
3450- .sendToTarget();
3451- }
3452- @SuppressWarnings("unused")
3453- public void startCacheMid() {
3454- mHandler.obtainMessage(MSG_ID_ACTION_START_CACHE,
3455- ECO_TYPE_MID, 0)
3456- .sendToTarget();
3457- }
3458- @SuppressWarnings("unused")
3459- public void startCacheLow() {
3460- mHandler.obtainMessage(MSG_ID_ACTION_START_CACHE,
3461- ECO_TYPE_LOW, 0)
3462- .sendToTarget();
3463- }
3464- @SuppressWarnings("unused")
3465- public void relatedVideo() {
3466- mHandler.obtainMessage(MSG_ID_ACTION_RELATED_VIDEO)
3467- .sendToTarget();
3468- }
3469- @SuppressWarnings("unused")
3470- public void stopCache() {
3471- mHandler.obtainMessage(MSG_ID_ACTION_STOP_CACHE)
3472- .sendToTarget();
3473- }
3474- @SuppressWarnings("unused")
3475- public void deleteCache() {
3476- mHandler.obtainMessage(MSG_ID_ACTION_DELETE_CACHE)
3477- .sendToTarget();
3478- }
3479- @SuppressWarnings("unused")
3480- public void addMylist() {
3481- mHandler.obtainMessage(MSG_ID_ACTION_ADD_MYLIST)
3482- .sendToTarget();
3483- }
3484-
3485- @SuppressWarnings("unused")
3486- public String getPlayerboxHtml(String url) {
3643+ private String getPlayerboxHtml(String url) {
34873644 String newJikkyoNumber = null;
34883645
34893646 StringBuilder builder = new StringBuilder();
@@ -3497,7 +3654,8 @@
34973654 if (mCookieUserSession != null && url != null) {
34983655 newJikkyoNumber = getJikkyoNumberFromUrl(url);
34993656 if (newJikkyoNumber != null) {
3500- appendLiButton(builder, "nicoro.startJikkyo()",
3657+ appendLiButton(builder,
3658+ "window.alert('" + JS_CMD_PRE + JS_CMD_START_JIKKYO + "')",
35013659 res.getString(R.string.action_item_jikkyo));
35023660 }
35033661 }
@@ -3509,23 +3667,7 @@
35093667 return builder.toString();
35103668 }
35113669
3512- @SuppressWarnings("unused")
3513- public void startJikkyo() {
3514- mHandler.sendEmptyMessage(MSG_ID_ACTION_START_JIKKYO);
3515- }
3516-
3517- @SuppressWarnings("unused")
3518- public void startLive() {
3519- mHandler.sendEmptyMessage(MSG_ID_ACTION_START_LIVE);
3520- }
3521-
3522- @SuppressWarnings("unused")
3523- public void goBack() {
3524- mHandler.sendEmptyMessage(MSG_ID_GO_BACK_WEBVIEW);
3525- }
3526-
3527- @SuppressWarnings("unused")
3528- public void getStreamDescription(String strDes) {
3670+ private void getStreamDescription(String strDes) {
35293671 if (DEBUG_LOGD) {
35303672 Log.d(LOG_TAG, Log.buf().append("stream_description=")
35313673 .append(strDes).toString());
@@ -3533,22 +3675,7 @@
35333675 streamDescription = strDes;
35343676 }
35353677
3536- @SuppressWarnings("unused")
3537- public void log(String text) {
3538- if (DEBUG_LOGD) {
3539- Log.d(LOG_TAG, text);
3540- }
3541- }
3542-
3543- @SuppressWarnings("unused")
3544- public void logLines(String text) {
3545- if (DEBUG_LOGD) {
3546- Log.dLines(LOG_TAG, text);
3547- }
3548- }
3549-
3550- @SuppressWarnings("unused")
3551- public void getOffsetFlvplayerContainer(int offsetLeft, int offsetTop,
3678+ private void getOffsetFlvplayerContainer(int offsetLeft, int offsetTop,
35523679 int offsetWidth, int offsetHeight) {
35533680 if (DEBUG_LOGD) {
35543681 Log.d(LOG_TAG, Log.buf().append("getOffsetFlvplayerContainer: ")
@@ -3564,8 +3691,7 @@
35643691 .sendToTarget();
35653692 }
35663693
3567- @SuppressWarnings("unused")
3568- public void startReadVideo(String url) {
3694+ private void startReadVideo(String url) {
35693695 mVideoMap.clear();
35703696 mVideoUrl = url;
35713697 if (DEBUG_LOGD) {
@@ -3574,8 +3700,7 @@
35743700 }
35753701 }
35763702
3577- @SuppressWarnings("unused")
3578- public void readVideo(String prop, String value) {
3703+ private void readVideo(String prop, String value) {
35793704 if (DEBUG_LOGD) {
35803705 Log.d(LOG_TAG, Log.buf().append("Video.").append(prop)
35813706 .append('=').append(value).toString());
@@ -3583,15 +3708,13 @@
35833708 mVideoMap.put(prop, value);
35843709 }
35853710
3586- @SuppressWarnings("unused")
3587- public void endReadVideo() {
3711+ private void endReadVideo() {
35883712 WatchVideo watchVideo = WatchVideo.createFromVideoMap(mVideoMap);
35893713 watchVideo.setUrl(mVideoUrl);
35903714 updateVideo(watchVideo);
35913715 }
35923716
3593- @SuppressWarnings("unused")
3594- public void readWatchAPIDataContainer(String url,
3717+ private void readWatchAPIDataContainer(String url,
35953718 String watchAPIDataContainer) {
35963719 try {
35973720 JSONObject json = new JSONObject(watchAPIDataContainer);
@@ -3615,8 +3738,7 @@
36153738 }
36163739 }
36173740
3618- @SuppressWarnings("unused")
3619- public void failReadVideo(String url) {
3741+ private void failReadVideo(String url) {
36203742 if (url != null) {
36213743 // XXX Videoが含まれていない場合はURLから仮生成
36223744 // (spの生放送、ページ情報一部破損?等)
@@ -3680,47 +3802,58 @@
36803802 // flvまたはmp4動画
36813803 playStringId = R.string.action_item_play_normal;
36823804 }
3683- appendLiButton(builder, "nicoro.startPlay()",
3805+ appendLiButton(builder,
3806+ "window.alert('" + JS_CMD_PRE + JS_CMD_START_PLAY + "')",
36843807 res.getString(playStringId));
36853808 }
36863809 if (judge.enablePlayMid) {
3687- appendLiButton(builder, "nicoro.startPlayMid()",
3810+ appendLiButton(builder,
3811+ "window.alert('" + JS_CMD_PRE + JS_CMD_START_PLAY_MID + "')",
36883812 res.getString(R.string.action_item_play_normal_mid));
36893813 }
36903814 if (judge.enablePlayLow) {
3691- appendLiButton(builder, "nicoro.startPlayLow()",
3815+ appendLiButton(builder,
3816+ "window.alert('" + JS_CMD_PRE + JS_CMD_START_PLAY_LOW + "')",
36923817 res.getString(R.string.action_item_play_normal_low));
36933818 }
36943819 if (judge.enableCacheNormal) {
3695- appendLiButton(builder, "nicoro.startCache()",
3820+ appendLiButton(builder,
3821+ "window.alert('" + JS_CMD_PRE + JS_CMD_START_CACHE + "')",
36963822 res.getString(R.string.action_item_cache));
36973823 }
36983824 if (judge.enableCacheMid) {
3699- appendLiButton(builder, "nicoro.startCacheMid()",
3825+ appendLiButton(builder,
3826+ "window.alert('" + JS_CMD_PRE + JS_CMD_START_CACHE_MID + "')",
37003827 res.getString(R.string.action_item_cache_mid));
37013828 }
37023829 if (judge.enableCacheLow) {
3703- appendLiButton(builder, "nicoro.startCacheLow()",
3830+ appendLiButton(builder,
3831+ "window.alert('" + JS_CMD_PRE + JS_CMD_START_CACHE_LOW + "')",
37043832 res.getString(R.string.action_item_cache_low));
37053833 }
37063834 if (judge.enableRelatedVideo) {
3707- appendLiButton(builder, "nicoro.relatedVideo()",
3835+ appendLiButton(builder,
3836+ "window.alert('" + JS_CMD_PRE + JS_CMD_RELATED_VIDEO + "')",
37083837 res.getString(R.string.action_item_related_video));
37093838 }
37103839 if (judge.enableStopCache) {
3711- appendLiButton(builder, "nicoro.stopCache()",
3840+ appendLiButton(builder,
3841+ "window.alert('" + JS_CMD_PRE + JS_CMD_STOP_CACHE + "')",
37123842 res.getString(R.string.action_item_stop_cache_one));
37133843 }
37143844 if (judge.enableDeleteCache) {
3715- appendLiButton(builder, "nicoro.deleteCache()",
3845+ appendLiButton(builder,
3846+ "window.alert('" + JS_CMD_PRE + JS_CMD_DELETE_CACHE + "')",
37163847 res.getString(R.string.action_item_delete_cache_one));
37173848 }
37183849 if (judge.enableAddMylist) {
3719- appendLiButton(builder, "nicoro.addMylist()",
3850+ appendLiButton(builder,
3851+ "window.alert('" + JS_CMD_PRE + JS_CMD_ADD_MYLIST + "')",
37203852 res.getString(R.string.action_item_add_mylist));
37213853 }
37223854 if (judge.enableLive) {
3723- appendLiButton(builder, "nicoro.startLive()",
3855+ appendLiButton(builder,
3856+ "window.alert('" + JS_CMD_PRE + JS_CMD_START_LIVE + "')",
37243857 res.getString(R.string.action_item_live));
37253858 }
37263859
@@ -3729,7 +3862,7 @@
37293862 return builder;
37303863 }
37313864
3732- private void updateVideo(WatchVideo v) {
3865+ void updateVideo(WatchVideo v) {
37333866 video = v;
37343867 mHandler.sendEmptyMessage(MSG_ID_ON_UPDATE_VIDEO);
37353868 }
--- trunk/NicoRo/src/jp/sourceforge/nicoro/Util.java (revision 569)
+++ trunk/NicoRo/src/jp/sourceforge/nicoro/Util.java (revision 570)
@@ -667,11 +667,7 @@
667667 } catch (IOException e) {
668668 Log.e(LOG_TAG, e.toString(), e);
669669 } finally {
670- try {
671- reader.close();
672- } catch (IOException e) {
673- Log.d(LOG_TAG, e.toString(), e);
674- }
670+ FileUtil.closeIgnoreException(reader);
675671 }
676672 return builder;
677673 }
--- trunk/NicoRo/res/raw/replace_mylist_add.js (revision 569)
+++ trunk/NicoRo/res/raw/replace_mylist_add.js (revision 570)
@@ -1,10 +1,11 @@
11 var box_success = document.getElementById('box_success');
22 if (box_success != null) {
33 var p = box_success.getElementsByTagName('p');
4- p[0].innerHTML = '<button onclick="nicoro.goBack(); return false;" style="font-size: 2em;">戻る</button>';
4+ p[0].innerHTML = '<button onclick="window.alert(' + "'" + 'nicorojs_goBack:' + "'" + '); return false;" style="font-size: 2em;">戻る</button>';
55 for (var i = 1; i < p.length; ++i) {
66 p[i].innerHTML = '';
77 }
88 } else {
9- nicoro.log('box_success not found');
9+ var log = 'nicorojs_log:' + 'box_success not found';
10+ window.alert(log);
1011 }
--- trunk/NicoRo/res/raw/find_rss.js (revision 569)
+++ trunk/NicoRo/res/raw/find_rss.js (revision 570)
@@ -1,6 +1,8 @@
11 var links = document.getElementsByTagName('link');
22 for (i = 0; i < links.length; ++i) {
33 if (links[i].getAttribute('type') == 'application/rss+xml') {
4- nicoro.getRss(links[i].getAttribute('href'), links[i].getAttribute('title'));
4+ var getRss = 'nicorojs_getRss:' + encodeURI(links[i].getAttribute('href'))
5+ + ' ' + encodeURI(links[i].getAttribute('title'));
6+ window.alert(getRss);
57 }
68 }
\ No newline at end of file
--- trunk/NicoRo/res/raw/get_offset_flvplayer_container.js (revision 569)
+++ trunk/NicoRo/res/raw/get_offset_flvplayer_container.js (revision 570)
@@ -1,22 +1,25 @@
11 var flvplayer_container = document.getElementById('flvplayer_container');
22 if (flvplayer_container != null) {
3- nicoro.getOffsetFlvplayerContainer(
4- flvplayer_container.offsetLeft,
5- flvplayer_container.offsetTop,
6- flvplayer_container.offsetWidth,
7- flvplayer_container.offsetHeight);
3+ var getOffsetFlvplayerContainer = 'nicorojs_getOffsetFlvplayerContainer:'
4+ + flvplayer_container.offsetLeft
5+ + ' ' + flvplayer_container.offsetTop
6+ + ' ' + flvplayer_container.offsetWidth
7+ + ' ' + flvplayer_container.offsetHeight;
8+ window.alert(getOffsetFlvplayerContainer);
89 } else {
9- nicoro.log('flvplayer_container not found');
10+ var log = 'nicorojs_log:' + 'flvplayer_container not found';
11+ window.alert(log);
1012 }
1113
1214 var playerContainer = document.getElementById('playerContainer');
1315 if (playerContainer != null) {
14- nicoro.getOffsetFlvplayerContainer(
15- playerContainer.offsetLeft,
16- playerContainer.offsetTop,
17- playerContainer.offsetWidth,
18- playerContainer.offsetHeight);
16+ var getOffsetFlvplayerContainer = 'nicorojs_getOffsetFlvplayerContainer:'
17+ + playerContainer.offsetLeft
18+ + ' ' + playerContainer.offsetTop
19+ + ' ' + playerContainer.offsetWidth
20+ + ' ' + playerContainer.offsetHeight;
21+ window.alert(getOffsetFlvplayerContainer);
1922 } else {
20- nicoro.log('nicoplayerContainerInner not found');
23+ var log = 'nicorojs_log:' + 'nicoplayerContainerInner not found';
24+ window.alert(log);
2125 }
22-
--- trunk/NicoRo/res/raw/get_stream_description.js (revision 569)
+++ trunk/NicoRo/res/raw/get_stream_description.js (revision 570)
@@ -1,6 +1,8 @@
11 var stream_description = document.getElementById('stream_description');
22 if (stream_description != null) {
3- nicoro.getStreamDescription(stream_description.innerText);
3+ var getStreamDescription = 'nicorojs_getStreamDescription:' + stream_description.innerText;
4+ window.alert(getStreamDescription);
45 } else {
5- nicoro.log('stream_description not found');
6+ var log = 'nicorojs_log:' + 'stream_description not found';
7+ window.alert(log);
68 }
--- trunk/NicoRo/res/raw/replace_playerbox.js (revision 569)
+++ trunk/NicoRo/res/raw/replace_playerbox.js (revision 570)
@@ -1,7 +1,9 @@
11 var playerbox = document.getElementById('playerbox');
22 if (playerbox != null) {
3- playerbox.innerHTML = nicoro.getPlayerboxHtml(document.URL);
3+ var getPlayerboxHtml = 'nicorojs_getPlayerboxHtml:' + document.URL;
4+ playerbox.innerHTML = window.prompt(getPlayerboxHtml);
45 playerbox.style.height = 'auto';
56 } else {
6- nicoro.log('playerbox not found');
7+ var log = 'nicorojs_log:' + 'playerbox not found';
8+ window.alert(log);
79 }
--- trunk/NicoRo/res/raw/read_video.js (revision 569)
+++ trunk/NicoRo/res/raw/read_video.js (revision 570)
@@ -1,15 +1,24 @@
11 if (typeof Video == 'undefined') {
2- nicoro.log('Video not found');
2+ var log = 'nicorojs_log:' + 'Video not found';
3+ window.alert(log);
34 var watchAPIDataContainer = document.getElementById('watchAPIDataContainer');
45 if (watchAPIDataContainer == null) {
5- nicoro.log('watchAPIDataContainer not found');
6+ log = 'nicorojs_log:' + 'watchAPIDataContainer not found';
7+ window.alert(log);
68 } else {
7- nicoro.readWatchAPIDataContainer(document.URL, watchAPIDataContainer.innerText);
9+ var readWatchAPIDataContainer = 'nicorojs_readWatchAPIDataContainer:'
10+ + encodeURI(document.URL)
11+ + ' ' + encodeURI(watchAPIDataContainer.innerText);
12+ window.alert(readWatchAPIDataContainer);
813 }
914 } else {
10- nicoro.startReadVideo(document.URL);
15+ var startReadVideo = 'nicorojs_startReadVideo:' + document.URL;
16+ window.alert(startReadVideo);
1117 for (var prop in Video) {
12- nicoro.readVideo(prop, Video[prop]);
18+ var readVideo = 'nicorojs_readVideo:' + encodeURI(prop)
19+ + ' ' + encodeURI(Video[prop]);
20+ window.alert(readVideo);
1321 }
14- nicoro.endReadVideo();
22+ var endReadVideo = 'nicorojs_endReadVideo:';
23+ window.alert(endReadVideo);
1524 }
\ No newline at end of file
--- trunk/NicoRo/res/raw/replace_flvplayer_container.js (revision 569)
+++ trunk/NicoRo/res/raw/replace_flvplayer_container.js (revision 570)
@@ -6,34 +6,56 @@
66 }
77 if (playerElem != null) {
88 var elem = document.createElement('div');
9- elem.innerHTML = nicoro.getFlvplayerContainerHtml(document.URL);
9+ var getFlvplayerContainerHtml = 'nicorojs_getFlvplayerContainerHtml:' + document.URL;
10+ elem.innerHTML = window.prompt(getFlvplayerContainerHtml);
1011 elem.id = 'nicoro_player';
1112 playerElem.parentNode.insertBefore(elem, playerElem);
1213 } else {
13- nicoro.log('flvplayer_container and nico-player not found');
14+ var log = 'nicorojs_log:' + 'flvplayer_container and nico-player not found';
15+ window.alert(log);
1416 }
1517 } else {
16- nicoroPlayer.innerHTML = nicoro.getFlvplayerContainerHtml(document.URL);
18+ var getFlvplayerContainerHtml = 'nicorojs_getFlvplayerContainerHtml:' + document.URL;
19+ nicoroPlayer.innerHTML = window.prompt(getFlvplayerContainerHtml);
1720 }
1821
19-var nicoplayerContainerInner = document.getElementById('nicoplayerContainerInner');
20-if (nicoplayerContainerInner != null) {
21- nicoplayerContainerInner.innerHTML = nicoro.getNicoplayerContainerInnerHtml(document.URL);
22- nicoplayerContainerInner.style.height = 'auto';
23- nicoplayerContainerInner.style.paddingTop = '40px';
22+var nicoroPlayerQ = document.getElementById('nicoro_player_q');
23+if (nicoroPlayerQ == null) {
24+ var nicoplayerContainerInner = document.getElementById('nicoplayerContainerInner');
25+ if (nicoplayerContainerInner != null) {
26+ var elem = document.createElement('div');
27+ var getNicoplayerContainerInnerHtml = 'nicorojs_getNicoplayerContainerInnerHtml:' + document.URL;
28+ elem.innerHTML = window.prompt(getNicoplayerContainerInnerHtml);
29+ elem.id = 'nicoro_player_q';
30+ nicoplayerContainerInner.parentNode.insertBefore(elem, nicoplayerContainerInner);
31+ nicoplayerContainerInner.style.display = 'none';
32+ var videoInformationWrapper = document.getElementById('videoInformationWrapper');
33+ if (videoInformationWrapper != null) {
34+ videoInformationWrapper.style.display = 'none';
35+ } else {
36+ var log = 'nicorojs_log:' + 'videoInformationWrapper not found';
37+ window.alert(log);
38+ }
2439
25- var playerContainer = document.getElementById('playerContainer');
26- if (playerContainer != null) {
27- playerContainer.style.height = 'auto';
40+ var playerContainer = document.getElementById('playerContainer');
41+ if (playerContainer != null) {
42+ playerContainer.style.height = 'auto';
43+ } else {
44+ var log = 'nicorojs_log:' + 'playerContainer not found';
45+ window.alert(log);
46+ }
47+ var nicoplayerContainer = document.getElementById('nicoplayerContainer');
48+ if (nicoplayerContainer != null) {
49+ nicoplayerContainer.style.height = 'auto';
50+ } else {
51+ var log = 'nicorojs_log:' + 'nicoplayerContainer not found';
52+ window.alert(log);
53+ }
2854 } else {
29- nicoro.log('playerContainer not found');
55+ var log = 'nicorojs_log:' + 'nicoplayerContainerInner not found';
56+ window.alert(log);
3057 }
31- var nicoplayerContainer = document.getElementById('nicoplayerContainer');
32- if (nicoplayerContainer != null) {
33- nicoplayerContainer.style.height = 'auto';
34- } else {
35- nicoro.log('nicoplayerContainer not found');
36- }
3758 } else {
38- nicoro.log('nicoplayerContainerInner not found');
59+ var getNicoplayerContainerInnerHtml = 'nicorojs_getNicoplayerContainerInnerHtml:' + document.URL;
60+ nicoroPlayerQ.innerHTML = window.prompt(getNicoplayerContainerInnerHtml);
3961 }
--- trunk/NicoRo/res/raw/read_video_on_page_finished.js (revision 569)
+++ trunk/NicoRo/res/raw/read_video_on_page_finished.js (revision 570)
@@ -1,16 +1,26 @@
11 if (typeof Video == 'undefined') {
2- nicoro.log('Video not found');
2+ var log = 'nicorojs_log:' + 'Video not found';
3+ window.alert(log);
34 var watchAPIDataContainer = document.getElementById('watchAPIDataContainer');
45 if (watchAPIDataContainer == null) {
5- nicoro.log('watchAPIDataContainer not found');
6- nicoro.failReadVideo(document.URL);
6+ log = 'nicorojs_log:' + 'watchAPIDataContainer not found';
7+ window.alert(log);
8+ var failReadVideo = 'nicorojs_failReadVideo:' + document.URL;
9+ window.alert(failReadVideo);
710 } else {
8- nicoro.readWatchAPIDataContainer(document.URL, watchAPIDataContainer.innerText);
11+ var readWatchAPIDataContainer = 'nicorojs_readWatchAPIDataContainer:'
12+ + encodeURI(document.URL)
13+ + ' ' + encodeURI(watchAPIDataContainer.innerText);
14+ window.alert(readWatchAPIDataContainer);
915 }
1016 } else {
11- nicoro.startReadVideo(document.URL);
17+ var startReadVideo = 'nicorojs_startReadVideo:' + document.URL;
18+ window.alert(startReadVideo);
1219 for (var prop in Video) {
13- nicoro.readVideo(prop, Video[prop]);
20+ var readVideo = 'nicorojs_readVideo:' + encodeURI(prop)
21+ + ' ' + encodeURI(Video[prop]);
22+ window.alert(readVideo);
1423 }
15- nicoro.endReadVideo();
24+ var endReadVideo = 'nicorojs_endReadVideo:';
25+ window.alert(endReadVideo);
1626 }
\ No newline at end of file
Show on old repository browser