Chromium Code Reviews
chromiumcodereview-hr@appspot.gserviceaccount.com (chromiumcodereview-hr) | Please choose your nickname with Settings | Help | Chromium Project | Gerrit Changes | Sign out
(664)

Side by Side Diff: content/browser/android/content_settings.cc

Issue 920693003: Revert "Revert of [Android] Migrate javascript settings to a content setting from a pref. (patchset… (Closed) Base URL: https://chromium.googlesource.com/chromium/src.git@master
Patch Set: Remove jni registration Created 5 years, 10 months ago
Use n/p to move between diff chunks; N/P to move between comments. Draft comments are only viewable by you.
Jump to:
View unified diff | Download patch
« no previous file with comments | « content/browser/android/content_settings.h ('k') | content/content_browser.gypi » ('j') | no next file with comments »
Toggle Intra-line Diffs ('i') | Expand Comments ('e') | Collapse Comments ('c') | Show Comments Hide Comments ('s')
OLDNEW
(Empty)
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.
4
5 #include "content/browser/android/content_settings.h"
6
7 #include "base/android/jni_android.h"
8 #include "content/browser/android/content_view_core_impl.h"
9 #include "content/browser/renderer_host/render_view_host_delegate.h"
10 #include "content/browser/renderer_host/render_view_host_impl.h"
11 #include "content/public/browser/web_contents.h"
12 #include "content/public/common/web_preferences.h"
13 #include "jni/ContentSettings_jni.h"
14
15 namespace content {
16
17 ContentSettings::ContentSettings(JNIEnv* env,
18 jobject obj,
19 WebContents* contents)
20 : WebContentsObserver(contents),
21 content_settings_(env, obj) {
22 }
23
24 ContentSettings::~ContentSettings() {
25 JNIEnv* env = base::android::AttachCurrentThread();
26 ScopedJavaLocalRef<jobject> obj = content_settings_.get(env);
27 if (obj.obj()) {
28 Java_ContentSettings_onNativeContentSettingsDestroyed(env, obj.obj(),
29 reinterpret_cast<intptr_t>(this));
30 }
31 }
32
33 // static
34 bool ContentSettings::RegisterContentSettings(JNIEnv* env) {
35 return RegisterNativesImpl(env);
36 }
37
38 bool ContentSettings::GetJavaScriptEnabled(JNIEnv* env, jobject obj) {
39 RenderViewHost* render_view_host = web_contents()->GetRenderViewHost();
40 if (!render_view_host)
41 return false;
42 return render_view_host->GetWebkitPreferences().javascript_enabled;
43 }
44
45 void ContentSettings::WebContentsDestroyed() {
46 delete this;
47 }
48
49 static jlong Init(JNIEnv* env, jobject obj, jlong nativeContentViewCore) {
50 WebContents* web_contents =
51 reinterpret_cast<ContentViewCoreImpl*>(nativeContentViewCore)
52 ->GetWebContents();
53 ContentSettings* content_settings =
54 new ContentSettings(env, obj, web_contents);
55 return reinterpret_cast<intptr_t>(content_settings);
56 }
57
58 } // namespace content
OLDNEW
« no previous file with comments | « content/browser/android/content_settings.h ('k') | content/content_browser.gypi » ('j') | no next file with comments »

Powered by Google App Engine
This is Rietveld 408576698