| OLD | NEW |
| 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_client_context_impl.h" | 5 #include "blimp/client/core/blimp_client_context_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 "base/supports_user_data.h" |
| 9 #include "blimp/client/core/contents/blimp_contents_impl.h" | 9 #include "blimp/client/core/contents/blimp_contents_impl.h" |
| 10 #include "blimp/client/core/contents/blimp_contents_manager.h" |
| 10 #include "blimp/client/public/blimp_client_context_delegate.h" | 11 #include "blimp/client/public/blimp_client_context_delegate.h" |
| 11 | 12 |
| 12 #if defined(OS_ANDROID) | 13 #if defined(OS_ANDROID) |
| 13 #include "blimp/client/core/android/blimp_client_context_impl_android.h" | 14 #include "blimp/client/core/android/blimp_client_context_impl_android.h" |
| 14 #endif // OS_ANDROID | 15 #endif // OS_ANDROID |
| 15 | 16 |
| 16 namespace blimp { | 17 namespace blimp { |
| 17 namespace client { | 18 namespace client { |
| 18 | 19 |
| 19 namespace { | 20 namespace { |
| 20 | 21 |
| 21 #if defined(OS_ANDROID) | 22 #if defined(OS_ANDROID) |
| 22 const char kBlimpClientContextImplAndroidKey[] = | 23 const char kBlimpClientContextImplAndroidKey[] = |
| 23 "blimp_client_context_impl_android"; | 24 "blimp_client_context_impl_android"; |
| 24 #endif // OS_ANDROID | 25 #endif // OS_ANDROID |
| 25 } | 26 } |
| 26 | 27 |
| 27 // This function is declared in //blimp/client/public/blimp_client_context.h, | 28 // This function is declared in //blimp/client/public/blimp_client_context.h, |
| 28 // and either this function or the one in | 29 // and either this function or the one in |
| 29 // //blimp/client/core/dummy_blimp_client_context.cc should be linked in to | 30 // //blimp/client/core/dummy_blimp_client_context.cc should be linked in to |
| 30 // any binary using BlimpClientContext::Create. | 31 // any binary using BlimpClientContext::Create. |
| 31 // static | 32 // static |
| 32 BlimpClientContext* BlimpClientContext::Create() { | 33 BlimpClientContext* BlimpClientContext::Create() { |
| 33 return new BlimpClientContextImpl(); | 34 return new BlimpClientContextImpl(); |
| 34 } | 35 } |
| 35 | 36 |
| 36 BlimpClientContextImpl::BlimpClientContextImpl() : BlimpClientContext() {} | 37 BlimpClientContextImpl::BlimpClientContextImpl() |
| 38 : BlimpClientContext(), blimp_contents_manager_(new BlimpContentsManager) {} |
| 37 | 39 |
| 38 BlimpClientContextImpl::~BlimpClientContextImpl() {} | 40 BlimpClientContextImpl::~BlimpClientContextImpl() {} |
| 39 | 41 |
| 40 #if defined(OS_ANDROID) | 42 #if defined(OS_ANDROID) |
| 41 | 43 |
| 42 base::android::ScopedJavaLocalRef<jobject> | 44 base::android::ScopedJavaLocalRef<jobject> |
| 43 BlimpClientContextImpl::GetJavaObject() { | 45 BlimpClientContextImpl::GetJavaObject() { |
| 44 return GetBlimpClientContextImplAndroid()->GetJavaObject(); | 46 return GetBlimpClientContextImplAndroid()->GetJavaObject(); |
| 45 } | 47 } |
| 46 | 48 |
| (...skipping 12 matching lines...) Expand all Loading... |
| 59 } | 61 } |
| 60 | 62 |
| 61 #endif // defined(OS_ANDROID) | 63 #endif // defined(OS_ANDROID) |
| 62 | 64 |
| 63 void BlimpClientContextImpl::SetDelegate(BlimpClientContextDelegate* delegate) { | 65 void BlimpClientContextImpl::SetDelegate(BlimpClientContextDelegate* delegate) { |
| 64 delegate_ = delegate; | 66 delegate_ = delegate; |
| 65 } | 67 } |
| 66 | 68 |
| 67 std::unique_ptr<BlimpContents> BlimpClientContextImpl::CreateBlimpContents() { | 69 std::unique_ptr<BlimpContents> BlimpClientContextImpl::CreateBlimpContents() { |
| 68 std::unique_ptr<BlimpContents> blimp_contents = | 70 std::unique_ptr<BlimpContents> blimp_contents = |
| 69 base::WrapUnique(new BlimpContentsImpl); | 71 blimp_contents_manager_->CreateBlimpContents(); |
| 70 delegate_->AttachBlimpContentsHelpers(blimp_contents.get()); | 72 delegate_->AttachBlimpContentsHelpers(blimp_contents.get()); |
| 71 return blimp_contents; | 73 return blimp_contents; |
| 72 } | 74 } |
| 73 | 75 |
| 74 } // namespace client | 76 } // namespace client |
| 75 } // namespace blimp | 77 } // namespace blimp |
| OLD | NEW |