OLD | NEW |
| (Empty) |
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 | |
3 // found in the LICENSE file. | |
4 | |
5 #include "blimp/client/core/blimp_contents_impl.h" | |
6 | |
7 #include "base/memory/ptr_util.h" | |
8 #include "base/supports_user_data.h" | |
9 #include "blimp/client/public/blimp_contents_observer.h" | |
10 | |
11 #if defined(OS_ANDROID) | |
12 #include "blimp/client/core/android/blimp_contents_impl_android.h" | |
13 #endif // OS_ANDROID | |
14 | |
15 namespace blimp { | |
16 namespace client { | |
17 | |
18 namespace { | |
19 | |
20 #if defined(OS_ANDROID) | |
21 const char kBlimpContentsImplAndroidKey[] = "blimp_contents_impl_android"; | |
22 #endif // OS_ANDROID | |
23 } | |
24 | |
25 BlimpContentsImpl::BlimpContentsImpl() : navigation_controller_(this) {} | |
26 | |
27 BlimpContentsImpl::~BlimpContentsImpl() {} | |
28 | |
29 #if defined(OS_ANDROID) | |
30 | |
31 base::android::ScopedJavaLocalRef<jobject> | |
32 BlimpContentsImpl::GetJavaBlimpContentsImpl() { | |
33 return GetBlimpContentsImplAndroid()->GetJavaObject(); | |
34 } | |
35 | |
36 BlimpContentsImplAndroid* BlimpContentsImpl::GetBlimpContentsImplAndroid() { | |
37 BlimpContentsImplAndroid* blimp_contents_impl_android = | |
38 static_cast<BlimpContentsImplAndroid*>( | |
39 GetUserData(kBlimpContentsImplAndroidKey)); | |
40 if (!blimp_contents_impl_android) { | |
41 blimp_contents_impl_android = new BlimpContentsImplAndroid(this); | |
42 SetUserData(kBlimpContentsImplAndroidKey, blimp_contents_impl_android); | |
43 } | |
44 return blimp_contents_impl_android; | |
45 } | |
46 | |
47 #endif // defined(OS_ANDROID) | |
48 | |
49 BlimpNavigationControllerImpl& BlimpContentsImpl::GetNavigationController() { | |
50 return navigation_controller_; | |
51 } | |
52 | |
53 void BlimpContentsImpl::AddObserver(BlimpContentsObserver* observer) { | |
54 observers_.AddObserver(observer); | |
55 } | |
56 | |
57 void BlimpContentsImpl::RemoveObserver(BlimpContentsObserver* observer) { | |
58 observers_.RemoveObserver(observer); | |
59 } | |
60 | |
61 void BlimpContentsImpl::NotifyURLLoaded(const GURL& url) { | |
62 FOR_EACH_OBSERVER(BlimpContentsObserver, observers_, OnURLUpdated(url)); | |
63 } | |
64 | |
65 } // namespace client | |
66 } // namespace blimp | |
OLD | NEW |