| OLD | NEW |
| 1 // Copyright 2015 The Chromium Authors. All rights reserved. | 1 // Copyright 2015 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 #include "chrome/browser/android/fullscreen/fullscreen_infobar_delegate.h" | 5 #include "chrome/browser/android/fullscreen/fullscreen_infobar_delegate.h" |
| 6 | 6 |
| 7 #include "base/android/jni_string.h" | 7 #include "base/android/jni_string.h" |
| 8 #include "base/memory/scoped_ptr.h" | 8 #include "base/memory/scoped_ptr.h" |
| 9 #include "chrome/browser/android/android_theme_resources.h" | 9 #include "chrome/browser/android/android_theme_resources.h" |
| 10 #include "chrome/browser/android/tab_android.h" | 10 #include "chrome/browser/android/tab_android.h" |
| 11 #include "chrome/browser/infobars/infobar_service.h" | 11 #include "chrome/browser/infobars/infobar_service.h" |
| 12 #include "chrome/browser/profiles/profile_manager.h" | |
| 13 #include "chrome/common/pref_names.h" | |
| 14 #include "chrome/grit/generated_resources.h" | 12 #include "chrome/grit/generated_resources.h" |
| 15 #include "components/infobars/core/infobar.h" | 13 #include "components/infobars/core/infobar.h" |
| 16 #include "components/prefs/pref_service.h" | |
| 17 #include "components/url_formatter/elide_url.h" | 14 #include "components/url_formatter/elide_url.h" |
| 18 #include "grit/components_strings.h" | 15 #include "grit/components_strings.h" |
| 19 #include "jni/FullscreenInfoBarDelegate_jni.h" | 16 #include "jni/FullscreenInfoBarDelegate_jni.h" |
| 20 #include "ui/base/l10n/l10n_util.h" | 17 #include "ui/base/l10n/l10n_util.h" |
| 21 #include "url/gurl.h" | 18 #include "url/gurl.h" |
| 22 | 19 |
| 23 // static | 20 // static |
| 24 jlong LaunchFullscreenInfoBar(JNIEnv* env, | 21 jlong LaunchFullscreenInfoBar(JNIEnv* env, |
| 25 const JavaParamRef<jobject>& obj, | 22 const JavaParamRef<jobject>& obj, |
| 26 const JavaParamRef<jobject>& tab) { | 23 const JavaParamRef<jobject>& tab) { |
| (...skipping 36 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 63 infobars::InfoBarDelegate::InfoBarIdentifier | 60 infobars::InfoBarDelegate::InfoBarIdentifier |
| 64 FullscreenInfoBarDelegate::GetIdentifier() const { | 61 FullscreenInfoBarDelegate::GetIdentifier() const { |
| 65 return FULLSCREEN_INFOBAR_DELEGATE; | 62 return FULLSCREEN_INFOBAR_DELEGATE; |
| 66 } | 63 } |
| 67 | 64 |
| 68 int FullscreenInfoBarDelegate::GetIconId() const { | 65 int FullscreenInfoBarDelegate::GetIconId() const { |
| 69 return IDR_ANDROID_INFOBAR_FULLSCREEN; | 66 return IDR_ANDROID_INFOBAR_FULLSCREEN; |
| 70 } | 67 } |
| 71 | 68 |
| 72 base::string16 FullscreenInfoBarDelegate::GetMessageText() const { | 69 base::string16 FullscreenInfoBarDelegate::GetMessageText() const { |
| 73 Profile* profile = | |
| 74 ProfileManager::GetActiveUserProfile()->GetOriginalProfile(); | |
| 75 std::string language = | |
| 76 profile->GetPrefs()->GetString(prefs::kAcceptLanguages); | |
| 77 return l10n_util::GetStringFUTF16( | 70 return l10n_util::GetStringFUTF16( |
| 78 IDS_FULLSCREEN_INFOBAR_TEXT, | 71 IDS_FULLSCREEN_INFOBAR_TEXT, |
| 79 url_formatter::FormatUrlForSecurityDisplay(origin_, language)); | 72 url_formatter::FormatUrlForSecurityDisplay(origin_)); |
| 80 } | 73 } |
| 81 | 74 |
| 82 base::string16 FullscreenInfoBarDelegate::GetButtonLabel( | 75 base::string16 FullscreenInfoBarDelegate::GetButtonLabel( |
| 83 InfoBarButton button) const { | 76 InfoBarButton button) const { |
| 84 return l10n_util::GetStringUTF16((button == BUTTON_OK) ? | 77 return l10n_util::GetStringUTF16((button == BUTTON_OK) ? |
| 85 IDS_FULLSCREEN_INFOBAR_ALLOW_BUTTON : | 78 IDS_FULLSCREEN_INFOBAR_ALLOW_BUTTON : |
| 86 IDS_FULLSCREEN_INFOBAR_EXIT_FULLSCREEN_BUTTON); | 79 IDS_FULLSCREEN_INFOBAR_EXIT_FULLSCREEN_BUTTON); |
| 87 } | 80 } |
| 88 | 81 |
| 89 bool FullscreenInfoBarDelegate::Accept() { | 82 bool FullscreenInfoBarDelegate::Accept() { |
| 90 JNIEnv* env = base::android::AttachCurrentThread(); | 83 JNIEnv* env = base::android::AttachCurrentThread(); |
| 91 ScopedJavaLocalRef<jstring> j_origin = | 84 ScopedJavaLocalRef<jstring> j_origin = |
| 92 base::android::ConvertUTF8ToJavaString(env, origin_.spec()); | 85 base::android::ConvertUTF8ToJavaString(env, origin_.spec()); |
| 93 Java_FullscreenInfoBarDelegate_onFullscreenAllowed( | 86 Java_FullscreenInfoBarDelegate_onFullscreenAllowed( |
| 94 env, j_delegate_.obj(), j_origin.obj()); | 87 env, j_delegate_.obj(), j_origin.obj()); |
| 95 return true; | 88 return true; |
| 96 } | 89 } |
| 97 | 90 |
| 98 bool FullscreenInfoBarDelegate::Cancel() { | 91 bool FullscreenInfoBarDelegate::Cancel() { |
| 99 Java_FullscreenInfoBarDelegate_onFullscreenCancelled( | 92 Java_FullscreenInfoBarDelegate_onFullscreenCancelled( |
| 100 base::android::AttachCurrentThread(), j_delegate_.obj()); | 93 base::android::AttachCurrentThread(), j_delegate_.obj()); |
| 101 return true; | 94 return true; |
| 102 } | 95 } |
| OLD | NEW |