Pin Chrome's shortcut to the Win10 Start menu on install and OS upgrade.
[chromium-blink-merge.git] / content / app / android / library_loader_hooks.cc
blobb801eb8bd688684d071d2257899f9e762cafeedf
1 // Copyright (c) 2012 The Chromium Authors. All rights reserved.
2 // Use of this source code is governed by a BSD-style license that can be
3 // found in the LICENSE file.
5 #include "content/app/android/library_loader_hooks.h"
7 #include "base/android/base_jni_registrar.h"
8 #include "base/android/command_line_android.h"
9 #include "base/android/jni_android.h"
10 #include "base/android/jni_registrar.h"
11 #include "base/android/jni_string.h"
12 #include "base/base_switches.h"
13 #include "base/command_line.h"
14 #include "base/files/file_path.h"
15 #include "base/logging.h"
16 #include "base/strings/string_util.h"
17 #include "base/trace_event/trace_event.h"
18 #include "base/tracked_objects.h"
19 #include "components/tracing/startup_tracing.h"
20 #include "content/app/android/app_jni_registrar.h"
21 #include "content/browser/android/browser_jni_registrar.h"
22 #include "content/common/android/common_jni_registrar.h"
23 #include "content/common/content_constants_internal.h"
24 #include "content/public/common/content_switches.h"
25 #include "content/public/common/result_codes.h"
26 #include "device/bluetooth/android/bluetooth_jni_registrar.h"
27 #include "device/vibration/android/vibration_jni_registrar.h"
28 #include "media/base/android/media_jni_registrar.h"
29 #include "media/midi/midi_jni_registrar.h"
30 #include "net/android/net_jni_registrar.h"
31 #include "ui/android/ui_android_jni_registrar.h"
32 #include "ui/base/android/ui_base_jni_registrar.h"
33 #include "ui/gfx/android/gfx_jni_registrar.h"
34 #include "ui/gl/android/gl_jni_registrar.h"
35 #include "ui/shell_dialogs/android/shell_dialogs_jni_registrar.h"
37 namespace content {
39 bool EnsureJniRegistered(JNIEnv* env) {
40 static bool g_jni_init_done = false;
42 if (!g_jni_init_done) {
43 if (!base::android::RegisterJni(env))
44 return false;
46 if (!gfx::android::RegisterJni(env))
47 return false;
49 if (!net::android::RegisterJni(env))
50 return false;
52 if (!ui::android::RegisterJni(env))
53 return false;
55 if (!ui::gl::android::RegisterJni(env))
56 return false;
58 if (!ui::shell_dialogs::RegisterJni(env))
59 return false;
61 if (!content::android::RegisterCommonJni(env))
62 return false;
64 if (!content::android::RegisterBrowserJni(env))
65 return false;
67 if (!content::android::RegisterAppJni(env))
68 return false;
70 if (!device::android::RegisterBluetoothJni(env))
71 return false;
73 if (!device::android::RegisterVibrationJni(env))
74 return false;
76 if (!media::RegisterJni(env))
77 return false;
79 if (!media::midi::RegisterJni(env))
80 return false;
82 if (!ui::RegisterUIAndroidJni(env))
83 return false;
85 g_jni_init_done = true;
88 return true;
91 bool LibraryLoaded(JNIEnv* env, jclass clazz) {
92 base::CommandLine* command_line = base::CommandLine::ForCurrentProcess();
94 if (command_line->HasSwitch(switches::kTraceStartup)) {
95 base::trace_event::TraceConfig trace_config(
96 command_line->GetSwitchValueASCII(switches::kTraceStartup), "");
97 base::trace_event::TraceLog::GetInstance()->SetEnabled(
98 trace_config, base::trace_event::TraceLog::RECORDING_MODE);
99 } else {
100 tracing::EnableStartupTracingIfConfigFileExists();
103 // Android's main browser loop is custom so we set the browser
104 // name here as early as possible.
105 TRACE_EVENT_BEGIN_ETW("BrowserMain", 0, "");
106 base::trace_event::TraceLog::GetInstance()->SetProcessName("Browser");
107 base::trace_event::TraceLog::GetInstance()->SetProcessSortIndex(
108 kTraceEventBrowserProcessSortIndex);
110 // Can only use event tracing after setting up the command line.
111 TRACE_EVENT0("jni", "JNI_OnLoad continuation");
113 logging::LoggingSettings settings;
114 settings.logging_dest = logging::LOG_TO_SYSTEM_DEBUG_LOG;
115 logging::InitLogging(settings);
116 // To view log output with IDs and timestamps use "adb logcat -v threadtime".
117 logging::SetLogItems(false, // Process ID
118 false, // Thread ID
119 false, // Timestamp
120 false); // Tick count
121 VLOG(0) << "Chromium logging enabled: level = " << logging::GetMinLogLevel()
122 << ", default verbosity = " << logging::GetVlogVerbosity();
124 return true;
127 } // namespace content