Exemplo n.º 1
0
  private static String addCustomProfileArg(String args) {
    String profileArg = "";
    String guestArg = "";
    if (GeckoAppShell.getGeckoInterface() != null) {
      final GeckoProfile profile = GeckoAppShell.getGeckoInterface().getProfile();

      if (profile.inGuestMode()) {
        try {
          profileArg = " -profile " + profile.getDir().getCanonicalPath();
        } catch (final IOException ioe) {
          Log.e(LOGTAG, "error getting guest profile path", ioe);
        }

        if (args == null || !args.contains(BrowserApp.GUEST_BROWSING_ARG)) {
          guestArg = " " + BrowserApp.GUEST_BROWSING_ARG;
        }
      } else if (!GeckoProfile.sIsUsingCustomProfile) {
        // If nothing was passed in the intent, make sure the default profile exists and
        // force Gecko to use the default profile for this activity
        profileArg = " -P " + profile.forceCreate().getName();
      }
    }

    return (args != null ? args : "") + profileArg + guestArg;
  }
Exemplo n.º 2
0
 private static Intent getIntentForAction(final Context context, final String action) {
   final Intent intent = new Intent(action, /* uri */ null, context, GeckoService.class);
   final GeckoProfile profile = GeckoThread.getActiveProfile();
   if (profile != null) {
     setIntentProfile(intent, profile.getName(), profile.getDir().getAbsolutePath());
   }
   return intent;
 }
Exemplo n.º 3
0
  private int handleIntent(final Intent intent, final int startId) {
    if (DEBUG) {
      Log.d(LOGTAG, "Handling " + intent.getAction());
    }

    final String profileName = intent.getStringExtra(INTENT_PROFILE_NAME);
    final String profileDir = intent.getStringExtra(INTENT_PROFILE_DIR);

    if (profileName == null || profileDir == null) {
      throw new IllegalArgumentException("Intent must specify profile.");
    }

    if (!GeckoThread.initWithProfile(
        profileName != null ? profileName : "", new File(profileDir))) {
      Log.w(LOGTAG, "Ignoring due to profile mismatch: " + profileName + " [" + profileDir + ']');

      final GeckoProfile profile = GeckoThread.getActiveProfile();
      if (profile != null) {
        Log.w(
            LOGTAG,
            "Current profile is "
                + profile.getName()
                + " ["
                + profile.getDir().getAbsolutePath()
                + ']');
      }
      stopSelf(startId);
      return Service.START_NOT_STICKY;
    }

    GeckoThread.launch();

    switch (intent.getAction()) {
      case INTENT_ACTION_UPDATE_ADDONS:
        // Run the add-on update service. Because the service is automatically invoked
        // when loading Gecko, we don't have to do anything else here.
        break;

      case INTENT_ACTION_CREATE_SERVICES:
        final String category = intent.getStringExtra(INTENT_SERVICE_CATEGORY);

        if (category == null) {
          break;
        }
        GeckoThread.createServices(category);
        break;

      default:
        Log.w(LOGTAG, "Unknown request: " + intent);
    }

    stopSelf(startId);
    return Service.START_NOT_STICKY;
  }
Exemplo n.º 4
0
 private static void fillIntentWithProfileInfo(final Context context, final Intent intent) {
   // There is a race here, but GeckoProfile returns the default profile
   // when Gecko is not explicitly running for a different profile.  In a
   // multi-profile world, this will need to be updated (possibly to
   // broadcast settings for all profiles).  See Bug 882182.
   GeckoProfile profile = GeckoProfile.get(context);
   if (profile != null) {
     intent
         .putExtra("profileName", profile.getName())
         .putExtra("profilePath", profile.getDir().getAbsolutePath());
   }
 }
Exemplo n.º 5
0
 private static File getPingFile() {
   if (GeckoAppShell.getContext() == null) {
     return null;
   }
   GeckoProfile profile = GeckoAppShell.getGeckoInterface().getProfile();
   if (profile == null) {
     return null;
   }
   File profDir = profile.getDir();
   if (profDir == null) {
     return null;
   }
   File pingDir = new File(profDir, "saved-telemetry-pings");
   pingDir.mkdirs();
   if (!(pingDir.exists() && pingDir.isDirectory())) {
     return null;
   }
   return new File(pingDir, UUID.randomUUID().toString());
 }