Make locale safe paths

getTarget was using SimpleDateFormat with the default
locale to create paths. In some locales this resulted
in characters that are not safe to use on all file
systems. Explicitly use Locale.US to be locale safe.

Change-Id: Id0d994231fa82d5695e7b0fdbae32333b9e77a6e
Pass webview's useragent when downloading via context menu

Currently null is passed as useragent to the Download Manager when
downloading via Browser context menu (causes the Download
Provider to use an empty useragent HTTP header).
This commit simply passes the webview's useragent instead.

This applies to the usecase when choosing save image/link
via the context menu (long press).

Change-Id: Ie9cc5e81630d0dcefe4708980146cc5ed867e4ad
Pause WebView timer when Browser is paused

If the Browser is paused while loading a page it
shall finish loading the page before the WebView
timer is paused.

The WebView timer shall be paused in onProgressChanged
when the progress has reached 100 not from onPageFinished
since onPageFinished is called when the main frame is loaded
and at that time subframe and other resources might haven't
been finished loaded i.e. the page is still in load, which the
result in WebView timers are not paused.

With this patch the Browser won't consume system resources
if it's minimized while doing a page load.

Change-Id: Id971dbcedfbedb5b0e56cba4076cd724d590ac85
No search pane while tapping search button after backing to "windows" view from "saved page" view.

When NavScreen is showing, the active tab should be detached normally,
but tab is reattached after backing to NavScreen from other activity.
Do the detach again.

Change-Id: I1b30791285a0ff08c69924d74a0f1660212995f2
Author: Weiwei Ji <weiweix.ji@intel.com>
Signed-off-by: Xiaokang Qin <xiaokang.qin@intel.com>
Signed-off-by: Bruce Beare <bruce.j.beare@intel.com>
Signed-off-by: Jack Ren <jack.ren@intel.com>
Author-tracking-BZ: 28528
Reset to default did not reset cached settings

Some settings such as the current search engine to use was cached
in the BrowserSetting object and not always read from shared
preferences. When settings were reset to default these cached values
were not reset causing the old (possibly non-default) value to still
be used.

Change-Id: I805a339a6238c96dc73cbda47981053bd4f6eace
Added catch of SQLiteException when updating screenshot

Error found when running Monkey test. User probably tries
to add a bookmark and directly after deleting it. The method
updateScreenshot is running an AsyncTask and gets an Exception
from the database when the bookmark does not exist. The deletion
of the bookmark runs in another thread.

Change-Id: I63bb954419f60fb5106c1a6597692b6bac925714
BrowserSettings required a Controller sometimes

BrowserSettings can be used without a browser Controller, e.g.
when accessed from system settings. But some null checks for
this case were missing, these have now been added.

Change-Id: I57762898d34ef3018569e0de1499be2922dabded
Don't replace file extension when mime-type is incorrect

When downloading content from a server that claims content to be
text/plain or application/octet-stream a guess is made of the proper
mime-type from a possible "file-extension" in the URL. When creating
the filename of the downloaded content any file extension that does
not match the mime-type is replaced with one derived from the
mime-type (.txt for text/plain, none for application/octet-stream).

However the guessed mime-type is not used in the filename
creation, so content with a proper file extension but a text/plain
mime-type will have its file extension replaced with .txt derived
from the incorrect mime-type.

This fix will use the guessed mime-type when creating the filename
to avoid replacing a correct file extension.

Change-Id: I5df642e94948914708af99a4d902b253ac8a48dd
NPE in WallpaperHandler

In WallpaperHandler, BitmapFactory.decodeStream() is used to create
a Bitmap that is then set by WallpaperManager as a wallpaper.
This method has null as return value when something fails as
decoding, resulting in a nullpointer exception in WallpaperManager.
Adding nullcheck on the Bitmap before setting it as wallpaper to
avoid the NPE.

Change-Id: Ib1a0f9331898162b21094c3ebe80bc21d66f8bd7
Fix the issue the SQL request built by QuickSearchBox is not handled properly by Sqlite3.

SELECT history._id AS _id, history.url AS url,
	CASE WHEN bookmarks.title IS NOT NULL THEN bookmarks.title ELSE
history.title END AS title,
	CASE WHEN bookmarks.url IS NOT NULL THEN "2130837532" ELSE
"2130837548" END,
	history.date AS date FROM history
	LEFT OUTER JOIN bookmarks ON history.url = bookmarks.url
	WHERE (url LIKE ?) AND (deleted=0 AND folder=0) ORDER BY
history.date DESC

has to be replaced with:
SELECT history._id AS _id, history.url AS url,
	CASE WHEN bookmarks.title IS NOT NULL THEN bookmarks.title ELSE
history.title END AS title,
	CASE WHEN bookmarks.url IS NOT NULL THEN "2130837532" ELSE
"2130837548" END,
	history.date AS date FROM history
	LEFT OUTER JOIN bookmarks ON history.url = bookmarks.url
	WHERE (bookmarks.url LIKE ?) AND (deleted=0 AND folder=0) ORDER BY
history.date DESC

Change-Id: Ib9fc03c2e102cca83c09168f75f2911a191af5ae
Author: Jean-Christophe PINCE <jean-christophe.pince@intel.com>
Signed-off-by: Xiaokang Qin <xiaokang.qin@intel.com>
Signed-off-by: Bruce Beare <bruce.j.beare@intel.com>
Signed-off-by: Jack Ren <jack.ren@intel.com>
Author-tracking-BZ: 43188