Refactor WebsiteSettings to operate on a SecurityInfo
[chromium-blink-merge.git] / content / shell / browser / shell_android.cc
blobb1a2348dec3c632415109ea79c04fb17391705b2
1 // Copyright 2013 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/shell/browser/shell.h"
7 #include <jni.h>
9 #include "base/android/jni_string.h"
10 #include "base/android/scoped_java_ref.h"
11 #include "base/command_line.h"
12 #include "base/logging.h"
13 #include "base/strings/string_piece.h"
14 #include "content/public/browser/web_contents.h"
15 #include "content/public/common/content_switches.h"
16 #include "content/shell/android/shell_manager.h"
17 #include "jni/Shell_jni.h"
19 using base::android::AttachCurrentThread;
20 using base::android::ConvertUTF8ToJavaString;
22 namespace content {
24 void Shell::PlatformInitialize(const gfx::Size& default_window_size) {
27 void Shell::PlatformExit() {
30 void Shell::PlatformCleanUp() {
31 JNIEnv* env = AttachCurrentThread();
32 if (java_object_.is_null())
33 return;
34 Java_Shell_onNativeDestroyed(env, java_object_.obj());
37 void Shell::PlatformEnableUIControl(UIControl control, bool is_enabled) {
38 JNIEnv* env = AttachCurrentThread();
39 if (java_object_.is_null())
40 return;
41 Java_Shell_enableUiControl(env, java_object_.obj(), control, is_enabled);
44 void Shell::PlatformSetAddressBarURL(const GURL& url) {
45 JNIEnv* env = AttachCurrentThread();
46 ScopedJavaLocalRef<jstring> j_url = ConvertUTF8ToJavaString(env, url.spec());
47 Java_Shell_onUpdateUrl(env, java_object_.obj(), j_url.obj());
50 void Shell::PlatformSetIsLoading(bool loading) {
51 JNIEnv* env = AttachCurrentThread();
52 Java_Shell_setIsLoading(env, java_object_.obj(), loading);
55 void Shell::PlatformCreateWindow(int width, int height) {
56 java_object_.Reset(CreateShellView(this));
59 void Shell::PlatformSetContents() {
60 JNIEnv* env = AttachCurrentThread();
61 Java_Shell_initFromNativeTabContents(
62 env, java_object_.obj(), web_contents()->GetJavaWebContents().obj());
65 void Shell::PlatformResizeSubViews() {
66 // Not needed; subviews are bound.
69 void Shell::PlatformSetTitle(const base::string16& title) {
70 NOTIMPLEMENTED() << ": " << title;
73 void Shell::LoadProgressChanged(WebContents* source, double progress) {
74 JNIEnv* env = AttachCurrentThread();
75 Java_Shell_onLoadProgressChanged(env, java_object_.obj(), progress);
78 void Shell::PlatformToggleFullscreenModeForTab(WebContents* web_contents,
79 bool enter_fullscreen) {
80 JNIEnv* env = AttachCurrentThread();
81 Java_Shell_toggleFullscreenModeForTab(
82 env, java_object_.obj(), enter_fullscreen);
85 bool Shell::PlatformIsFullscreenForTabOrPending(
86 const WebContents* web_contents) const {
87 JNIEnv* env = AttachCurrentThread();
88 return Java_Shell_isFullscreenForTabOrPending(env, java_object_.obj());
91 bool Shell::PlatformHandleContextMenu(
92 const content::ContextMenuParams& params) {
93 return false;
96 void Shell::Close() {
97 RemoveShellView(java_object_.obj());
98 delete this;
101 // static
102 bool Shell::Register(JNIEnv* env) {
103 return RegisterNativesImpl(env);
106 // static
107 void CloseShell(JNIEnv* env,
108 const JavaParamRef<jclass>& clazz,
109 jlong shellPtr) {
110 Shell* shell = reinterpret_cast<Shell*>(shellPtr);
111 shell->Close();
114 } // namespace content