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

Side by Side Diff: blimp/client/core/blimp_contents_impl.cc

Issue 2059443002: Java versions of BlimpContents[,Observer] and BlimpNavigationController (Closed) Base URL: https://chromium.googlesource.com/chromium/src.git@chrome-with-blimp
Patch Set: fixed gn order thing and fixed java visibility Created 4 years, 6 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
OLDNEW
1 // Copyright 2016 The Chromium Authors. All rights reserved. 1 // Copyright 2016 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 "blimp/client/core/blimp_contents_impl.h" 5 #include "blimp/client/core/blimp_contents_impl.h"
6 6
7 #include "base/memory/ptr_util.h" 7 #include "base/memory/ptr_util.h"
8 #include "base/supports_user_data.h"
8 #include "blimp/client/core/public/blimp_contents_observer.h" 9 #include "blimp/client/core/public/blimp_contents_observer.h"
9 10
11 #if defined(OS_ANDROID)
12 #include "blimp/client/core/android/blimp_contents_impl_android.h"
13 #endif // OS_ANDROID
14
10 namespace blimp { 15 namespace blimp {
11 namespace client { 16 namespace client {
12 17
18 namespace {
19
20 #if defined(OS_ANDROID)
21 const char kBlimpContentsImplAndroidKey[] = "blimp_contents_impl_android";
22 #endif // OS_ANDROID
23 }
24
13 BlimpContentsImpl::BlimpContentsImpl() : navigation_controller_(this) {} 25 BlimpContentsImpl::BlimpContentsImpl() : navigation_controller_(this) {}
14 26
15 BlimpContentsImpl::~BlimpContentsImpl() {} 27 BlimpContentsImpl::~BlimpContentsImpl() {
28 #if defined(OS_ANDROID)
29 BlimpContentsImplAndroid* blimp_contents_impl_android =
30 static_cast<BlimpContentsImplAndroid*>(
31 GetUserData(kBlimpContentsImplAndroidKey));
32 if (blimp_contents_impl_android) {
33 delete blimp_contents_impl_android;
David Trainor- moved to gerrit 2016/06/20 17:24:22 Will this crash? Doesn't the underlying map actua
nyquist 2016/06/21 20:27:20 Yes it will. :-( Updated the Java test code to ens
34 }
35 #endif
36 }
37
38 #if defined(OS_ANDROID)
39
40 base::android::ScopedJavaLocalRef<jobject>
41 BlimpContentsImpl::GetJavaBlimpContentsImpl() {
42 return GetBlimpContentsImplAndroid()->GetJavaObject();
43 }
44
45 BlimpContentsImplAndroid* BlimpContentsImpl::GetBlimpContentsImplAndroid() {
46 BlimpContentsImplAndroid* blimp_contents_impl_android =
47 static_cast<BlimpContentsImplAndroid*>(
48 GetUserData(kBlimpContentsImplAndroidKey));
49 if (!blimp_contents_impl_android) {
50 blimp_contents_impl_android = new BlimpContentsImplAndroid(this);
51 SetUserData(kBlimpContentsImplAndroidKey, blimp_contents_impl_android);
52 }
53 return blimp_contents_impl_android;
54 }
55
56 #endif // defined(OS_ANDROID)
16 57
17 BlimpNavigationControllerImpl& BlimpContentsImpl::GetNavigationController() { 58 BlimpNavigationControllerImpl& BlimpContentsImpl::GetNavigationController() {
18 return navigation_controller_; 59 return navigation_controller_;
19 } 60 }
20 61
21 void BlimpContentsImpl::AddObserver(BlimpContentsObserver* observer) { 62 void BlimpContentsImpl::AddObserver(BlimpContentsObserver* observer) {
22 observers_.AddObserver(observer); 63 observers_.AddObserver(observer);
23 } 64 }
24 65
25 void BlimpContentsImpl::RemoveObserver(BlimpContentsObserver* observer) { 66 void BlimpContentsImpl::RemoveObserver(BlimpContentsObserver* observer) {
26 observers_.RemoveObserver(observer); 67 observers_.RemoveObserver(observer);
27 } 68 }
28 69
29 void BlimpContentsImpl::NotifyURLLoaded(const GURL& url) { 70 void BlimpContentsImpl::NotifyURLLoaded(const GURL& url) {
30 FOR_EACH_OBSERVER(BlimpContentsObserver, observers_, OnURLUpdated(url)); 71 FOR_EACH_OBSERVER(BlimpContentsObserver, observers_, OnURLUpdated(url));
31 } 72 }
32 73
33 } // namespace client 74 } // namespace client
34 } // namespace blimp 75 } // namespace blimp
OLDNEW

Powered by Google App Engine
This is Rietveld 408576698