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

Side by Side Diff: content/public/android/java/src/org/chromium/content/browser/ContentSettings.java

Issue 10704049: Split out ContentViewCore from ContentView for embedders. (Closed) Base URL: svn://svn.chromium.org/chrome/trunk/src
Patch Set: Rebase Created 8 years, 5 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 | Annotate | Revision Log
OLDNEW
1 // Copyright (c) 2012 The Chromium Authors. All rights reserved. 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 2 // Use of this source code is governed by a BSD-style license that can be
3 // found in the LICENSE file. 3 // found in the LICENSE file.
4 4
5 package org.chromium.content.browser; 5 package org.chromium.content.browser;
6 6
7 import android.os.Handler; 7 import android.os.Handler;
8 import android.os.Message; 8 import android.os.Message;
9 import android.webkit.WebSettings.PluginState; 9 import android.webkit.WebSettings.PluginState;
10 import android.webkit.WebView; 10 import android.webkit.WebView;
(...skipping 11 matching lines...) Expand all
22 @JNINamespace("content") 22 @JNINamespace("content")
23 public class ContentSettings { 23 public class ContentSettings {
24 private static final String TAG = "ContentSettings"; 24 private static final String TAG = "ContentSettings";
25 25
26 // This class must be created on the UI thread. Afterwards, it can be 26 // This class must be created on the UI thread. Afterwards, it can be
27 // used from any thread. Internally, the class uses a message queue 27 // used from any thread. Internally, the class uses a message queue
28 // to call native code on the UI thread only. 28 // to call native code on the UI thread only.
29 29
30 private int mNativeContentSettings = 0; 30 private int mNativeContentSettings = 0;
31 31
32 private ContentView mContentView; 32 private ContentViewCore mContentViewCore;
33 33
34 // When ContentView is used in PERSONALITY_CHROME mode, settings can't 34 // When ContentView is used in PERSONALITY_CHROME mode, settings can't
35 // be modified through the ContentSettings instance. 35 // be modified through the ContentSettings instance.
36 private boolean mCanModifySettings; 36 private boolean mCanModifySettings;
37 37
38 // A flag to avoid sending superfluous synchronization messages. 38 // A flag to avoid sending superfluous synchronization messages.
39 private boolean mIsSyncMessagePending = false; 39 private boolean mIsSyncMessagePending = false;
40 // Custom handler that queues messages to call native code on the UI thread. 40 // Custom handler that queues messages to call native code on the UI thread.
41 private final EventHandler mEventHandler; 41 private final EventHandler mEventHandler;
42 42
(...skipping 34 matching lines...) Expand 10 before | Expand all | Expand 10 after
77 // Message id for syncing 77 // Message id for syncing
78 private static final int SYNC = 0; 78 private static final int SYNC = 0;
79 // Message id for updating user agent in the view 79 // Message id for updating user agent in the view
80 private static final int UPDATE_UA = 1; 80 private static final int UPDATE_UA = 1;
81 // Message id for updating multi-touch zoom state in the view 81 // Message id for updating multi-touch zoom state in the view
82 private static final int UPDATE_MULTI_TOUCH = 2; 82 private static final int UPDATE_MULTI_TOUCH = 2;
83 // Actual UI thread handler 83 // Actual UI thread handler
84 private Handler mHandler; 84 private Handler mHandler;
85 85
86 EventHandler() { 86 EventHandler() {
87 mHandler = mContentView.isPersonalityView() ? 87 mHandler = mContentViewCore.isPersonalityView() ?
88 new Handler() { 88 new Handler() {
89 @Override 89 @Override
90 public void handleMessage(Message msg) { 90 public void handleMessage(Message msg) {
91 switch (msg.what) { 91 switch (msg.what) {
92 case SYNC: 92 case SYNC:
93 synchronized (ContentSettings.this) { 93 synchronized (ContentSettings.this) {
94 nativeSyncToNative(mNativeContentSetting s); 94 nativeSyncToNative(mNativeContentSetting s);
95 mIsSyncMessagePending = false; 95 mIsSyncMessagePending = false;
96 } 96 }
97 break; 97 break;
98 case UPDATE_UA: 98 case UPDATE_UA:
99 synchronized (mContentView) { 99 synchronized (mContentViewCore) {
100 mContentView.setAllUserAgentOverridesInH istory(); 100 mContentViewCore.setAllUserAgentOverride sInHistory();
101 } 101 }
102 break; 102 break;
103 case UPDATE_MULTI_TOUCH: 103 case UPDATE_MULTI_TOUCH:
104 synchronized (mContentView) { 104 synchronized (mContentViewCore) {
105 mContentView.updateMultiTouchZoomSupport (); 105 mContentViewCore.updateMultiTouchZoomSup port();
106 } 106 }
107 break; 107 break;
108 } 108 }
109 } 109 }
110 } : 110 } :
111 new Handler() { 111 new Handler() {
112 @Override 112 @Override
113 public void handleMessage(Message msg) { 113 public void handleMessage(Message msg) {
114 switch (msg.what) { 114 switch (msg.what) {
115 case SYNC: 115 case SYNC:
(...skipping 17 matching lines...) Expand all
133 133
134 private synchronized void sendUpdateMultiTouchMessage() { 134 private synchronized void sendUpdateMultiTouchMessage() {
135 mHandler.sendMessage(Message.obtain(null, UPDATE_MULTI_TOUCH)); 135 mHandler.sendMessage(Message.obtain(null, UPDATE_MULTI_TOUCH));
136 } 136 }
137 } 137 }
138 138
139 /** 139 /**
140 * Package constructor to prevent clients from creating a new settings 140 * Package constructor to prevent clients from creating a new settings
141 * instance. Must be called on the UI thread. 141 * instance. Must be called on the UI thread.
142 */ 142 */
143 ContentSettings(ContentView contentView, int nativeContentView) { 143 ContentSettings(ContentViewCore contentViewCore, int nativeContentView) {
144 ThreadUtils.assertOnUiThread(); 144 ThreadUtils.assertOnUiThread();
145 mContentView = contentView; 145 mContentViewCore = contentViewCore;
146 mCanModifySettings = mContentView.isPersonalityView(); 146 mCanModifySettings = mContentViewCore.isPersonalityView();
147 mNativeContentSettings = nativeInit(nativeContentView, mCanModifySetting s); 147 mNativeContentSettings = nativeInit(nativeContentView, mCanModifySetting s);
148 assert mNativeContentSettings != 0; 148 assert mNativeContentSettings != 0;
149 149
150 mEventHandler = new EventHandler(); 150 mEventHandler = new EventHandler();
151 if (mCanModifySettings) { 151 if (mCanModifySettings) {
152 // PERSONALITY_VIEW 152 // PERSONALITY_VIEW
153 mDefaultUserAgent = nativeGetDefaultUserAgent(); 153 mDefaultUserAgent = nativeGetDefaultUserAgent();
154 mUserAgent = mDefaultUserAgent; 154 mUserAgent = mDefaultUserAgent;
155 nativeSyncToNative(mNativeContentSettings); 155 nativeSyncToNative(mNativeContentSettings);
156 } else { 156 } else {
(...skipping 514 matching lines...) Expand 10 before | Expand all | Expand 10 after
671 private native void nativeDestroy(int nativeContentSettings); 671 private native void nativeDestroy(int nativeContentSettings);
672 672
673 private static native String nativeGetDefaultUserAgent(); 673 private static native String nativeGetDefaultUserAgent();
674 674
675 // Synchronize Java settings from native settings. 675 // Synchronize Java settings from native settings.
676 private native void nativeSyncFromNative(int nativeContentSettings); 676 private native void nativeSyncFromNative(int nativeContentSettings);
677 677
678 // Synchronize native settings from Java settings. 678 // Synchronize native settings from Java settings.
679 private native void nativeSyncToNative(int nativeContentSettings); 679 private native void nativeSyncToNative(int nativeContentSettings);
680 } 680 }
OLDNEW
« no previous file with comments | « content/content_jni.gypi ('k') | content/public/android/java/src/org/chromium/content/browser/ContentView.java » ('j') | no next file with comments »

Powered by Google App Engine
This is Rietveld 408576698