gecko/mobile/android/base/App.java.in
Brian Nicholson 2d98f0cf71 Bug 850487 - More code cleanup (@Overrides and unused imports). r=kats
--HG--
extra : rebase_source : 376574e0c41b91c16a6be335584a4a61768bb4a9
2013-03-13 13:20:57 -07:00

66 lines
2.0 KiB
Java

/* -*- Mode: Java; c-basic-offset: 4; tab-width: 20; indent-tabs-mode: nil; -*-
* This Source Code Form is subject to the terms of the Mozilla Public
* 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/. */
#filter substitution
package @ANDROID_PACKAGE_NAME@;
import android.view.MenuItem;
import org.mozilla.gecko.BrowserApp;
import org.mozilla.gecko.GeckoAppShell;
import org.mozilla.gecko.GeckoProfile;
import org.mozilla.gecko.R;
public class App extends BrowserApp {
@Override
public int getLayout() { return R.layout.gecko_app; }
@Override
public String getPackageName() {
return "@ANDROID_PACKAGE_NAME@";
}
@Override
public String getContentProcessName() {
return "@MOZ_CHILD_PROCESS_NAME@";
}
@Override
protected String getDefaultProfileName() {
String profile = GeckoProfile.findDefaultProfile(this);
return (profile != null ? profile : "default");
}
@Override
public String getDefaultUAString() {
String deviceType = "Mobile";
if (GeckoAppShell.isTablet())
deviceType = "Tablet";
return "Mozilla/5.0 (Android; " + deviceType + "; rv:@MOZ_APP_VERSION@) Gecko/@MOZ_APP_VERSION@ Firefox/@MOZ_APP_VERSION@";
}
@Override
public String getUAStringForHost(String host) {
// With our standard UA String, we get a 200 response code and
// client-side redirect from t.co. This bot-like UA gives us a
// 301 response code
if ("t.co".equals(host))
return "Redirector/@MOZ_APP_VERSION@ (Android; rv:@MOZ_APP_VERSION@)";
return getDefaultUAString();
}
@Override
public boolean onOptionsItemSelected(MenuItem item) {
#ifdef MOZ_PROFILING
if (item.getItemId() == R.id.toggle_profiling) {
GeckoAppShell.sendEventToGecko(GeckoEvent.createBroadcastEvent("ToggleProfiling", null));
return true;
}
#endif
return super.onOptionsItemSelected(item);
}
}