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

Side by Side Diff: chrome/browser/ui/android/infobars/tabbed_mode_opt_in_infobar_delegate.cc

Issue 1435263003: [Android] Show document mode opt-out InfoBar on selected devices. (Closed) Base URL: https://chromium.googlesource.com/chromium/src.git@master
Patch Set: removed isOptedInToDocumentMode Created 5 years, 1 month 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
OLDNEW
(Empty)
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
3 // found in the LICENSE file.
4
5 #include "chrome/browser/ui/android/infobars/tabbed_mode_opt_in_infobar_delegate .h"
6
7 #include "base/metrics/user_metrics.h"
8 #include "chrome/browser/android/android_theme_resources.h"
9 #include "chrome/browser/android/tab_android.h"
10 #include "chrome/browser/infobars/infobar_service.h"
11 #include "chrome/grit/generated_resources.h"
12 #include "components/infobars/core/infobar.h"
13 #include "jni/TabbedModeOptInInfoBarDelegate_jni.h"
14 #include "ui/base/l10n/l10n_util.h"
15
16 // static
17 jlong LaunchTabbedModeOptInInfoBar(JNIEnv* env,
18 const JavaParamRef<jobject>& jcaller,
19 const JavaParamRef<jobject>& tab) {
20 base::RecordAction(base::UserMetricsAction("TabbedModeOptInInfoBar_Shown"));
21
22 TabbedModeOptInInfoBarDelegate* delegate = new TabbedModeOptInInfoBarDelegate(
23 env, jcaller);
24 InfoBarService* infobar_service = InfoBarService::FromWebContents(
25 TabAndroid::GetNativeTab(env, tab)->web_contents());
26 infobar_service->AddInfoBar(
27 infobar_service->CreateConfirmInfoBar(make_scoped_ptr(delegate)));
28 return reinterpret_cast<intptr_t>(delegate);
29 }
30
31 // static
32 bool TabbedModeOptInInfoBarDelegate::RegisterTabbedModeOptInInfoBarDelegate(
33 JNIEnv* env) {
34 return RegisterNativesImpl(env);
35 }
36
37 TabbedModeOptInInfoBarDelegate::TabbedModeOptInInfoBarDelegate(JNIEnv* env,
38 jobject obj)
39 : ConfirmInfoBarDelegate() {
40 j_delegate_.Reset(env, obj);
41 }
42
43 TabbedModeOptInInfoBarDelegate::~TabbedModeOptInInfoBarDelegate() {
44 }
45
46 int TabbedModeOptInInfoBarDelegate::GetIconId() const {
47 return IDR_ANDROID_INFOBAR_TABBED_MODE_OPT_IN;
48 }
49
50 bool TabbedModeOptInInfoBarDelegate::ShouldExpire(
51 const NavigationDetails& details) const {
52 return false;
53 }
54
55 void TabbedModeOptInInfoBarDelegate::InfoBarDismissed() {
56 base::RecordAction(
57 base::UserMetricsAction("TabbedModeOptInInfoBar_UserDismissed"));
58 }
59
60 base::string16 TabbedModeOptInInfoBarDelegate::GetMessageText() const {
61 return l10n_util::GetStringUTF16(IDS_TABBED_MODE_OPT_IN_INFOBAR_TEXT);
62 }
63
64 int TabbedModeOptInInfoBarDelegate::GetButtons() const {
65 return BUTTON_OK | BUTTON_CANCEL;
66 }
67
68 base::string16 TabbedModeOptInInfoBarDelegate::GetButtonLabel(
69 InfoBarButton button) const {
70 DCHECK(button == BUTTON_OK || button == BUTTON_CANCEL);
71 return l10n_util::GetStringUTF16(
72 button == BUTTON_OK ? IDS_OK : IDS_NO_THANKS);
73 }
74
75 bool TabbedModeOptInInfoBarDelegate::Accept() {
76 base::RecordAction(
77 base::UserMetricsAction("TabbedModeOptInInfoBar_UserOptIn"));
78 Java_TabbedModeOptInInfoBarDelegate_accept(
79 base::android::AttachCurrentThread(), j_delegate_.obj());
80
81 // Chrome is restarting as tabbed mode so we don't need to close.
gone 2015/11/17 23:18:16 as tabbed mode -> in tabbed mode
Kibeom Kim (inactive) 2015/11/20 11:44:15 Done.
82 // The visual difference is that, if we return true here, infobar starts to
83 // slide down and Chrome is restarted before the sliding is finished.
gone 2015/11/17 23:18:16 infobar -> InfoBar.
Kibeom Kim (inactive) 2015/11/20 11:44:15 Done.
84 return false;
85 }
86
87 bool TabbedModeOptInInfoBarDelegate::Cancel() {
88 base::RecordAction(
89 base::UserMetricsAction("TabbedModeOptInInfoBar_UserDenied"));
90 Java_TabbedModeOptInInfoBarDelegate_cancel(
91 base::android::AttachCurrentThread(), j_delegate_.obj());
92 return true;
93 }
OLDNEW

Powered by Google App Engine
This is Rietveld 408576698