Disable signin-to-Chrome when using Guest profile.
[chromium-blink-merge.git] / content / app / android / library_loader_hooks.cc
blobf69933f1367d205ec4031b8937de5603d3cf6f5d
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/public/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/debug/trace_event.h"
15 #include "base/files/file_path.h"
16 #include "base/logging.h"
17 #include "base/strings/string_util.h"
18 #include "base/tracked_objects.h"
19 #include "content/app/android/app_jni_registrar.h"
20 #include "content/browser/android/browser_jni_registrar.h"
21 #include "content/common/android/common_jni_registrar.h"
22 #include "content/common/content_constants_internal.h"
23 #include "content/public/common/content_switches.h"
24 #include "content/public/common/result_codes.h"
25 #include "media/base/android/media_jni_registrar.h"
26 #include "net/android/net_jni_registrar.h"
27 #include "ui/base/android/ui_base_jni_registrar.h"
28 #include "ui/gfx/android/gfx_jni_registrar.h"
29 #include "ui/gl/android/gl_jni_registrar.h"
30 #include "ui/shell_dialogs/android/shell_dialogs_jni_registrar.h"
32 namespace content {
34 bool EnsureJniRegistered(JNIEnv* env) {
35 static bool g_jni_init_done = false;
37 if (!g_jni_init_done) {
38 if (!base::android::RegisterJni(env))
39 return false;
41 if (!gfx::android::RegisterJni(env))
42 return false;
44 if (!net::android::RegisterJni(env))
45 return false;
47 if (!ui::android::RegisterJni(env))
48 return false;
50 if (!ui::gl::android::RegisterJni(env))
51 return false;
53 if (!ui::shell_dialogs::RegisterJni(env))
54 return false;
56 if (!content::android::RegisterCommonJni(env))
57 return false;
59 if (!content::android::RegisterBrowserJni(env))
60 return false;
62 if (!content::android::RegisterAppJni(env))
63 return false;
65 if (!media::RegisterJni(env))
66 return false;
68 g_jni_init_done = true;
71 return true;
74 bool LibraryLoaded(JNIEnv* env, jclass clazz,
75 jobjectArray init_command_line) {
76 base::android::InitNativeCommandLineFromJavaArray(env, init_command_line);
78 CommandLine* command_line = CommandLine::ForCurrentProcess();
80 if (command_line->HasSwitch(switches::kTraceStartup)) {
81 base::debug::CategoryFilter category_filter(
82 command_line->GetSwitchValueASCII(switches::kTraceStartup));
83 base::debug::TraceLog::GetInstance()->SetEnabled(category_filter,
84 base::debug::TraceLog::RECORDING_MODE,
85 base::debug::TraceLog::RECORD_UNTIL_FULL);
88 // Android's main browser loop is custom so we set the browser
89 // name here as early as possible.
90 TRACE_EVENT_BEGIN_ETW("BrowserMain", 0, "");
91 base::debug::TraceLog::GetInstance()->SetProcessName("Browser");
92 base::debug::TraceLog::GetInstance()->SetProcessSortIndex(
93 kTraceEventBrowserProcessSortIndex);
95 // Can only use event tracing after setting up the command line.
96 TRACE_EVENT0("jni", "JNI_OnLoad continuation");
98 logging::LoggingSettings settings;
99 settings.logging_dest = logging::LOG_TO_SYSTEM_DEBUG_LOG;
100 logging::InitLogging(settings);
101 // To view log output with IDs and timestamps use "adb logcat -v threadtime".
102 logging::SetLogItems(false, // Process ID
103 false, // Thread ID
104 false, // Timestamp
105 false); // Tick count
106 VLOG(0) << "Chromium logging enabled: level = " << logging::GetMinLogLevel()
107 << ", default verbosity = " << logging::GetVlogVerbosity();
109 return EnsureJniRegistered(env);
112 } // namespace content