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 "chrome/android/testshell/testshell_tab.h"
6
7#include "base/android/jni_string.h"
8#include "base/logging.h"
9#include "chrome/browser/android/chrome_web_contents_delegate_android.h"
10#include "chrome/browser/ui/android/window_android_helper.h"
11#include "chrome/browser/ui/browser_navigator.h"
12#include "chrome/common/net/url_fixer_upper.h"
13#include "content/public/browser/android/content_view_core.h"
14#include "content/public/browser/web_contents.h"
15#include "jni/TestShellTab_jni.h"
16#include "ui/base/android/window_android.h"
17#include "url/gurl.h"
18
19using base::android::ConvertJavaStringToUTF8;
20using base::android::ConvertUTF8ToJavaString;
21using base::android::ScopedJavaLocalRef;
22using chrome::android::ChromeWebContentsDelegateAndroid;
23using content::WebContents;
24using ui::WindowAndroid;
25
26TestShellTab::TestShellTab(JNIEnv* env,
27                           jobject obj)
28    : TabAndroid(env, obj) {
29}
30
31TestShellTab::~TestShellTab() {
32}
33
34void TestShellTab::Destroy(JNIEnv* env, jobject obj) {
35  delete this;
36}
37
38void TestShellTab::OnReceivedHttpAuthRequest(jobject auth_handler,
39                                             const string16& host,
40                                             const string16& realm) {
41  NOTIMPLEMENTED();
42}
43
44void TestShellTab::AddShortcutToBookmark(
45    const GURL& url, const string16& title, const SkBitmap& skbitmap,
46    int r_value, int g_value, int b_value) {
47  NOTIMPLEMENTED();
48}
49
50void TestShellTab::EditBookmark(int64 node_id,
51                                const base::string16& node_title,
52                                bool is_folder,
53                                bool is_partner_bookmark) {
54  NOTIMPLEMENTED();
55}
56
57bool TestShellTab::ShouldWelcomePageLinkToTermsOfService() {
58  NOTIMPLEMENTED();
59  return false;
60}
61
62void TestShellTab::OnNewTabPageReady() {
63  NOTIMPLEMENTED();
64}
65
66void TestShellTab::HandlePopupNavigation(chrome::NavigateParams* params) {
67  NOTIMPLEMENTED();
68}
69
70bool TestShellTab::RegisterTestShellTab(JNIEnv* env) {
71  return RegisterNativesImpl(env);
72}
73
74ScopedJavaLocalRef<jstring> TestShellTab::FixupUrl(JNIEnv* env,
75                                                   jobject obj,
76                                                   jstring url) {
77  GURL fixed_url(URLFixerUpper::FixupURL(ConvertJavaStringToUTF8(env, url),
78                                         std::string()));
79
80  std::string fixed_spec;
81  if (fixed_url.is_valid())
82    fixed_spec = fixed_url.spec();
83
84  return ConvertUTF8ToJavaString(env, fixed_spec);
85}
86
87static jlong Init(JNIEnv* env, jobject obj) {
88  return reinterpret_cast<intptr_t>(new TestShellTab(env, obj));
89}
90