toolkit/xre/nsAndroidStartup.cpp

Sat, 03 Jan 2015 20:18:00 +0100

author
Michael Schloh von Bennewitz <michael@schloh.com>
date
Sat, 03 Jan 2015 20:18:00 +0100
branch
TOR_BUG_3246
changeset 7
129ffea94266
permissions
-rw-r--r--

Conditionally enable double key logic according to:
private browsing mode or privacy.thirdparty.isolate preference and
implement in GetCookieStringCommon and FindCookie where it counts...
With some reservations of how to convince FindCookie users to test
condition and pass a nullptr when disabling double key logic.

     1 /* -*- Mode: C++; tab-width: 4; indent-tabs-mode: nil; c-basic-offset: 4 -*-
     2  * This Source Code Form is subject to the terms of the Mozilla Public
     3  * License, v. 2.0. If a copy of the MPL was not distributed with this
     4  * file, You can obtain one at http://mozilla.org/MPL/2.0/. */
     6 #include <android/log.h>
     8 #include <jni.h>
    10 #include <stdlib.h>
    11 #include <string.h>
    12 #include <pthread.h>
    14 #include "nsTArray.h"
    15 #include "nsString.h"
    16 #include "nsIFile.h"
    17 #include "nsAppRunner.h"
    18 #include "AndroidBridge.h"
    19 #include "APKOpen.h"
    20 #include "nsExceptionHandler.h"
    22 #define LOG(args...) __android_log_print(ANDROID_LOG_INFO, MOZ_APP_NAME, args)
    24 // We need to put Gecko on a even more separate thread, because
    25 // otherwise this JNI method never returns; this leads to problems
    26 // with local references overrunning the local refs table, among
    27 // other things, since GC can't ever run on them.
    29 // Note that we don't have xpcom initialized yet, so we can't use the
    30 // thread manager for this.  Instead, we use pthreads directly.
    32 struct AutoAttachJavaThread {
    33     AutoAttachJavaThread() {
    34         attached = mozilla_AndroidBridge_SetMainThread(pthread_self());
    35     }
    36     ~AutoAttachJavaThread() {
    37         mozilla_AndroidBridge_SetMainThread(-1);
    38         attached = false;
    39     }
    41     bool attached;
    42 };
    44 extern "C" NS_EXPORT void
    45 GeckoStart(void *data, const nsXREAppData *appData)
    46 {
    47 #ifdef MOZ_CRASHREPORTER
    48     const struct mapping_info *info = getLibraryMapping();
    49     while (info->name) {
    50       CrashReporter::AddLibraryMapping(info->name, info->base,
    51                                        info->len, info->offset);
    52       info++;
    53     }
    54 #endif
    56     AutoAttachJavaThread attacher;
    57     if (!attacher.attached)
    58         return;
    60     if (!data) {
    61         LOG("Failed to get arguments for GeckoStart\n");
    62         return;
    63     }
    65     nsTArray<char *> targs;
    66     char *arg = strtok(static_cast<char *>(data), " ");
    67     while (arg) {
    68         targs.AppendElement(arg);
    69         arg = strtok(nullptr, " ");
    70     }
    71     targs.AppendElement(static_cast<char *>(nullptr));
    73     int result = XRE_main(targs.Length() - 1, targs.Elements(), appData, 0);
    75     if (result)
    76         LOG("XRE_main returned %d", result);
    78     mozilla::widget::android::GeckoAppShell::NotifyXreExit();
    80     free(targs[0]);
    81     nsMemory::Free(data);
    82     return;
    83 }

mercurial