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

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

Issue 1049383008: Properly attach InfoBarContainer when it is swapped to a new WebContents (Closed) Base URL: https://chromium.googlesource.com/chromium/src.git@master
Patch Set: Comments Created 5 years, 8 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
« no previous file with comments | « chrome/browser/ui/android/infobars/infobar_container_android.h ('k') | no next file » | no next file with comments »
Toggle Intra-line Diffs ('i') | Expand Comments ('e') | Collapse Comments ('c') | Show Comments Hide Comments ('s')
OLDNEW
1 // Copyright 2013 The Chromium Authors. All rights reserved. 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 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/ui/android/infobars/infobar_container_android.h" 5 #include "chrome/browser/ui/android/infobars/infobar_container_android.h"
6 6
7 #include "base/android/jni_android.h" 7 #include "base/android/jni_android.h"
8 #include "base/logging.h" 8 #include "base/logging.h"
9 #include "base/message_loop/message_loop.h" 9 #include "base/message_loop/message_loop.h"
10 #include "chrome/browser/infobars/infobar_service.h" 10 #include "chrome/browser/infobars/infobar_service.h"
11 #include "chrome/browser/ui/android/infobars/infobar_android.h" 11 #include "chrome/browser/ui/android/infobars/infobar_android.h"
12 #include "components/infobars/core/infobar.h" 12 #include "components/infobars/core/infobar.h"
13 #include "components/infobars/core/infobar_delegate.h" 13 #include "components/infobars/core/infobar_delegate.h"
14 #include "content/public/browser/web_contents.h" 14 #include "content/public/browser/web_contents.h"
15 #include "jni/InfoBarContainer_jni.h" 15 #include "jni/InfoBarContainer_jni.h"
16 16
17 17
18 // InfoBarContainerAndroid ---------------------------------------------------- 18 // InfoBarContainerAndroid ----------------------------------------------------
19 19
20 InfoBarContainerAndroid::InfoBarContainerAndroid(JNIEnv* env, 20 InfoBarContainerAndroid::InfoBarContainerAndroid(JNIEnv* env,
21 jobject obj) 21 jobject obj)
22 : infobars::InfoBarContainer(NULL), 22 : infobars::InfoBarContainer(NULL),
23 weak_java_infobar_container_(env, obj) {} 23 weak_java_infobar_container_(env, obj) {}
24 24
25 InfoBarContainerAndroid::~InfoBarContainerAndroid() { 25 InfoBarContainerAndroid::~InfoBarContainerAndroid() {
26 RemoveAllInfoBarsForDestruction(); 26 RemoveAllInfoBarsForDestruction();
27 } 27 }
28 28
29 void InfoBarContainerAndroid::SetWebContents(JNIEnv* env,
30 jobject obj,
31 jobject web_contents) {
32 InfoBarService* infobar_service = InfoBarService::FromWebContents(
33 content::WebContents::FromJavaWebContents(web_contents));
34 ChangeInfoBarManager(infobar_service);
35 }
36
29 void InfoBarContainerAndroid::Destroy(JNIEnv* env, jobject obj) { 37 void InfoBarContainerAndroid::Destroy(JNIEnv* env, jobject obj) {
30 delete this; 38 delete this;
31 } 39 }
32 40
33 void InfoBarContainerAndroid::PlatformSpecificAddInfoBar( 41 void InfoBarContainerAndroid::PlatformSpecificAddInfoBar(
34 infobars::InfoBar* infobar, 42 infobars::InfoBar* infobar,
35 size_t position) { 43 size_t position) {
36 DCHECK(infobar); 44 DCHECK(infobar);
37 InfoBarAndroid* android_bar = static_cast<InfoBarAndroid*>(infobar); 45 InfoBarAndroid* android_bar = static_cast<InfoBarAndroid*>(infobar);
38 if (!android_bar) { 46 if (!android_bar) {
(...skipping 28 matching lines...) Expand all
67 75
68 void InfoBarContainerAndroid::PlatformSpecificRemoveInfoBar( 76 void InfoBarContainerAndroid::PlatformSpecificRemoveInfoBar(
69 infobars::InfoBar* infobar) { 77 infobars::InfoBar* infobar) {
70 InfoBarAndroid* android_infobar = static_cast<InfoBarAndroid*>(infobar); 78 InfoBarAndroid* android_infobar = static_cast<InfoBarAndroid*>(infobar);
71 android_infobar->CloseJavaInfoBar(); 79 android_infobar->CloseJavaInfoBar();
72 } 80 }
73 81
74 82
75 // Native JNI methods --------------------------------------------------------- 83 // Native JNI methods ---------------------------------------------------------
76 84
77 static jlong Init(JNIEnv* env, 85 static jlong Init(JNIEnv* env, jobject obj) {
78 jobject obj,
79 jobject web_contents) {
80 InfoBarContainerAndroid* infobar_container = 86 InfoBarContainerAndroid* infobar_container =
81 new InfoBarContainerAndroid(env, obj); 87 new InfoBarContainerAndroid(env, obj);
82 InfoBarService* infobar_service = InfoBarService::FromWebContents(
83 content::WebContents::FromJavaWebContents(web_contents));
84 infobar_container->ChangeInfoBarManager(infobar_service);
85 return reinterpret_cast<intptr_t>(infobar_container); 88 return reinterpret_cast<intptr_t>(infobar_container);
86 } 89 }
87 90
88 bool RegisterInfoBarContainer(JNIEnv* env) { 91 bool RegisterInfoBarContainer(JNIEnv* env) {
89 return RegisterNativesImpl(env); 92 return RegisterNativesImpl(env);
90 } 93 }
OLDNEW
« no previous file with comments | « chrome/browser/ui/android/infobars/infobar_container_android.h ('k') | no next file » | no next file with comments »

Powered by Google App Engine
This is Rietveld 408576698