Bug 1060678 - Notify Gecko when browser history is cleared from HistoryPanel. r=margaret, a=lmandel
authorChenxia Liu <liuche@mozilla.com>
Tue, 02 Sep 2014 15:24:17 -0700
changeset 216667 957e1ef7f769
parent 216666 09d840603713
child 216668 f9e4f36ba116
push id3868
push userryanvm@gmail.com
push date2014-09-08 17:05 +0000
treeherdermozilla-beta@f9e4f36ba116 [default view] [failures only]
perfherder[talos] [build metrics] [platform microbench] (compared to previous push)
reviewersmargaret, lmandel
bugs1060678
milestone33.0
Bug 1060678 - Notify Gecko when browser history is cleared from HistoryPanel. r=margaret, a=lmandel
mobile/android/base/home/HistoryPanel.java
--- a/mobile/android/base/home/HistoryPanel.java
+++ b/mobile/android/base/home/HistoryPanel.java
@@ -3,16 +3,20 @@
  * License, v. 2.0. If a copy of the MPL was not distributed with this
  * file, You can obtain one at http://mozilla.org/MPL/2.0/. */
 
 package org.mozilla.gecko.home;
 
 import java.util.Date;
 import java.util.EnumSet;
 
+import org.json.JSONException;
+import org.json.JSONObject;
+import org.mozilla.gecko.GeckoAppShell;
+import org.mozilla.gecko.GeckoEvent;
 import org.mozilla.gecko.R;
 import org.mozilla.gecko.Telemetry;
 import org.mozilla.gecko.TelemetryContract;
 import org.mozilla.gecko.db.BrowserContract.Combined;
 import org.mozilla.gecko.db.BrowserDB;
 import org.mozilla.gecko.db.BrowserDB.URLColumns;
 import org.mozilla.gecko.home.HomePager.OnUrlOpenListener;
 import org.mozilla.gecko.util.ThreadUtils;
@@ -21,16 +25,17 @@ import android.app.Activity;
 import android.app.AlertDialog;
 import android.content.ContentResolver;
 import android.content.Context;
 import android.content.DialogInterface;
 import android.database.Cursor;
 import android.os.Bundle;
 import android.support.v4.app.LoaderManager.LoaderCallbacks;
 import android.support.v4.content.Loader;
+import android.util.Log;
 import android.util.SparseArray;
 import android.view.LayoutInflater;
 import android.view.View;
 import android.view.ViewGroup;
 import android.view.ViewStub;
 import android.widget.AdapterView;
 import android.widget.ImageView;
 import android.widget.TextView;
@@ -140,23 +145,26 @@ public class HistoryPanel extends HomeFr
                         dialog.dismiss();
                     }
                 });
 
                 dialogBuilder.setPositiveButton(R.string.button_ok, new AlertDialog.OnClickListener() {
                     @Override
                     public void onClick(final DialogInterface dialog, final int which) {
                         dialog.dismiss();
-                        ThreadUtils.postToBackgroundThread(new Runnable() {
-                            @Override
-                            public void run() {
-                                final ContentResolver cr = context.getContentResolver();
-                                BrowserDB.clearHistory(cr);
-                            }
-                        });
+
+                        // Send message to Java to clear history.
+                        final JSONObject json = new JSONObject();
+                        try {
+                            json.put("history", true);
+                        } catch (JSONException e) {
+                            Log.e(LOGTAG, "JSON error", e);
+                        }
+
+                        GeckoAppShell.sendEventToGecko(GeckoEvent.createBroadcastEvent("Sanitize:ClearData", json.toString()));
 
                         Telemetry.sendUIEvent(TelemetryContract.Event.SANITIZE, TelemetryContract.Method.BUTTON, "history");
                     }
                 });
 
                 dialogBuilder.show();
             }
         });