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

Unified 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 side-by-side diff with in-line comments
Download patch
Index: blimp/client/core/blimp_client_context_impl.cc
diff --git a/blimp/client/core/blimp_client_context_impl.cc b/blimp/client/core/blimp_client_context_impl.cc
new file mode 100644
index 0000000000000000000000000000000000000000..73fbeedcf696953653b1b175713889600ba4af55
--- /dev/null
+++ b/blimp/client/core/blimp_client_context_impl.cc
@@ -0,0 +1,75 @@
+// Copyright 2016 The Chromium Authors. All rights reserved.
+// Use of this source code is governed by a BSD-style license that can be
+// found in the LICENSE file.
+
+#include "blimp/client/core/blimp_client_context_impl.h"
+
+#include "base/memory/ptr_util.h"
+#include "base/supports_user_data.h"
+#include "blimp/client/core/blimp_contents_impl.h"
+#include "blimp/client/public/blimp_client_context_delegate.h"
+
+#if defined(OS_ANDROID)
+#include "blimp/client/core/android/blimp_client_context_impl_android.h"
+#endif // OS_ANDROID
+
+namespace blimp {
+namespace client {
+
+namespace {
+
+#if defined(OS_ANDROID)
+const char kBlimpClientContextImplAndroidKey[] =
+ "blimp_client_context_impl_android";
+#endif // OS_ANDROID
+}
+
+// This function is declared in //blimp/client/public/blimp_client_context.h,
+// and either this function or the one in
+// //blimp/client/core/dummy_blimp_client_context.cc should be linked in to
+// any binary using BlimpClientContext::Create.
+// static
+BlimpClientContext* BlimpClientContext::Create() {
+ return new BlimpClientContextImpl();
+}
+
+BlimpClientContextImpl::BlimpClientContextImpl() : BlimpClientContext() {}
+
+BlimpClientContextImpl::~BlimpClientContextImpl() {}
+
+#if defined(OS_ANDROID)
+
+base::android::ScopedJavaLocalRef<jobject>
+BlimpClientContextImpl::GetJavaObject() {
+ return GetBlimpClientContextImplAndroid()->GetJavaObject();
+}
+
+BlimpClientContextImplAndroid*
+BlimpClientContextImpl::GetBlimpClientContextImplAndroid() {
+ BlimpClientContextImplAndroid* blimp_client_contents_impl_android =
+ static_cast<BlimpClientContextImplAndroid*>(
+ GetUserData(kBlimpClientContextImplAndroidKey));
+ if (!blimp_client_contents_impl_android) {
+ blimp_client_contents_impl_android =
+ new BlimpClientContextImplAndroid(this);
+ SetUserData(kBlimpClientContextImplAndroidKey,
+ blimp_client_contents_impl_android);
+ }
+ return blimp_client_contents_impl_android;
+}
+
+#endif // defined(OS_ANDROID)
+
+void BlimpClientContextImpl::SetDelegate(BlimpClientContextDelegate* delegate) {
+ delegate_ = delegate;
+}
+
+std::unique_ptr<BlimpContents> BlimpClientContextImpl::CreateBlimpContents() {
+ std::unique_ptr<BlimpContents> blimp_contents =
+ base::WrapUnique(new BlimpContentsImpl);
+ delegate_->AttachBlimpContentsHelpers(blimp_contents.get());
+ return blimp_contents;
+}
+
+} // namespace client
+} // namespace blimp
« 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