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

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

Issue 2132163002: Add BlimpClientContext and factory with real and dummy implementation (Closed) Base URL: https://chromium.googlesource.com/chromium/src.git@move-blimp-client-core-public-to-blimp-client
Patch Set: git merge origin/master before CQ for good measure Created 4 years, 5 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
(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_client_context_impl.h"
6
7 #include "base/memory/ptr_util.h"
8 #include "base/supports_user_data.h"
9 #include "blimp/client/core/blimp_contents_impl.h"
10 #include "blimp/client/public/blimp_client_context_delegate.h"
11
12 #if defined(OS_ANDROID)
13 #include "blimp/client/core/android/blimp_client_context_impl_android.h"
14 #endif // OS_ANDROID
15
16 namespace blimp {
17 namespace client {
18
19 namespace {
20
21 #if defined(OS_ANDROID)
22 const char kBlimpClientContextImplAndroidKey[] =
23 "blimp_client_context_impl_android";
24 #endif // OS_ANDROID
25 }
26
27 // This function is declared in //blimp/client/public/blimp_client_context.h,
28 // and either this function or the one in
29 // //blimp/client/core/dummy_blimp_client_context.cc should be linked in to
30 // any binary using BlimpClientContext::Create.
31 // static
32 BlimpClientContext* BlimpClientContext::Create() {
33 return new BlimpClientContextImpl();
34 }
35
36 BlimpClientContextImpl::BlimpClientContextImpl() : BlimpClientContext() {}
37
38 BlimpClientContextImpl::~BlimpClientContextImpl() {}
39
40 #if defined(OS_ANDROID)
41
42 base::android::ScopedJavaLocalRef<jobject>
43 BlimpClientContextImpl::GetJavaObject() {
44 return GetBlimpClientContextImplAndroid()->GetJavaObject();
45 }
46
47 BlimpClientContextImplAndroid*
48 BlimpClientContextImpl::GetBlimpClientContextImplAndroid() {
49 BlimpClientContextImplAndroid* blimp_client_contents_impl_android =
50 static_cast<BlimpClientContextImplAndroid*>(
51 GetUserData(kBlimpClientContextImplAndroidKey));
52 if (!blimp_client_contents_impl_android) {
53 blimp_client_contents_impl_android =
54 new BlimpClientContextImplAndroid(this);
55 SetUserData(kBlimpClientContextImplAndroidKey,
56 blimp_client_contents_impl_android);
57 }
58 return blimp_client_contents_impl_android;
59 }
60
61 #endif // defined(OS_ANDROID)
62
63 void BlimpClientContextImpl::SetDelegate(BlimpClientContextDelegate* delegate) {
64 delegate_ = delegate;
65 }
66
67 std::unique_ptr<BlimpContents> BlimpClientContextImpl::CreateBlimpContents() {
68 std::unique_ptr<BlimpContents> blimp_contents =
69 base::WrapUnique(new BlimpContentsImpl);
70 delegate_->AttachBlimpContentsHelpers(blimp_contents.get());
71 return blimp_contents;
72 }
73
74 } // namespace client
75 } // namespace blimp
OLDNEW
« no previous file with comments | « blimp/client/core/blimp_client_context_impl.h ('k') | blimp/client/core/blimp_client_context_impl_unittest.cc » ('j') | no next file with comments »

Powered by Google App Engine
This is Rietveld 408576698