Skip to content

Commit

Permalink
Chromecast: initial checkin of Android-based cast shell.
Browse files Browse the repository at this point in the history
R=byungchul@chromium.org,lcwu@chromium.org,yfriedman@chromium.org
BUG=400876

Review URL: https://codereview.chromium.org/490603002

Cr-Commit-Position: refs/heads/master@{#294476}
  • Loading branch information
gunsch authored and Commit bot committed Sep 11, 2014
1 parent 149b92d commit 407189f
Show file tree
Hide file tree
Showing 43 changed files with 1,865 additions and 29 deletions.
2 changes: 1 addition & 1 deletion build/common.gypi
Original file line number Diff line number Diff line change
Expand Up @@ -96,7 +96,7 @@
'use_aura%': 1,
}],

['chromecast==1', {
['chromecast==1 and OS!="android"', {
'embedded%': 1,
'use_ozone%': 1,
}],
Expand Down
1 change: 1 addition & 0 deletions chromecast/DEPS
Original file line number Diff line number Diff line change
Expand Up @@ -5,6 +5,7 @@ include_rules = [
"+crypto",
"+grit/chromecast_settings.h",
"+grit/shell_resources.h",
"+jni",
"+net",
"+ui",
]
30 changes: 30 additions & 0 deletions chromecast/android/cast_jni_registrar.cc
Original file line number Diff line number Diff line change
@@ -0,0 +1,30 @@
// Copyright 2014 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 "chromecast/android/cast_jni_registrar.h"

#include "base/android/jni_android.h"
#include "base/android/jni_registrar.h"
#include "chromecast/android/chromecast_config_android.h"
#include "chromecast/shell/browser/android/cast_window_android.h"
#include "chromecast/shell/browser/android/cast_window_manager.h"

namespace chromecast {
namespace android {

namespace {

static base::android::RegistrationMethod kMethods[] = {
{ "CastWindowAndroid", shell::CastWindowAndroid::RegisterJni },
{ "CastWindowManager", shell::RegisterCastWindowManager },
};

} // namespace

bool RegisterJni(JNIEnv* env) {
return RegisterNativeMethods(env, kMethods, arraysize(kMethods));
}

} // namespace android
} // namespace chromecast
19 changes: 19 additions & 0 deletions chromecast/android/cast_jni_registrar.h
Original file line number Diff line number Diff line change
@@ -0,0 +1,19 @@
// Copyright 2014 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.

#ifndef CHROMECAST_ANDROID_CAST_JNI_REGISTRAR_H_
#define CHROMECAST_ANDROID_CAST_JNI_REGISTRAR_H_

#include <jni.h>

namespace chromecast {
namespace android {

// Register all JNI bindings necessary for the Android cast shell.
bool RegisterJni(JNIEnv* env);

} // namespace android
} // namespace chromecast

#endif // CHROMECAST_ANDROID_CAST_JNI_REGISTRAR_H_
33 changes: 33 additions & 0 deletions chromecast/android/chromecast_config_android.cc
Original file line number Diff line number Diff line change
@@ -0,0 +1,33 @@
// Copyright 2014 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 "chromecast/android/chromecast_config_android.h"

namespace chromecast {
namespace android {

namespace {
base::LazyInstance<ChromecastConfigAndroid> g_instance =
LAZY_INSTANCE_INITIALIZER;
} // namespace

// static
ChromecastConfigAndroid* ChromecastConfigAndroid::GetInstance() {
return g_instance.Pointer();
}

ChromecastConfigAndroid::ChromecastConfigAndroid() {
}

ChromecastConfigAndroid::~ChromecastConfigAndroid() {
}

// Registers a handler to be notified when SendUsageStats is changed.
void ChromecastConfigAndroid::SetSendUsageStatsChangedCallback(
const base::Callback<void(bool)>& callback) {
send_usage_stats_changed_callback_ = callback;
}

} // namespace android
} // namespace chromecast
43 changes: 43 additions & 0 deletions chromecast/android/chromecast_config_android.h
Original file line number Diff line number Diff line change
@@ -0,0 +1,43 @@
// Copyright 2014 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.

#ifndef CHROMECAST_ANDROID_CHROMECAST_CONFIG_ANDROID_H_
#define CHROMECAST_ANDROID_CHROMECAST_CONFIG_ANDROID_H_

#include <jni.h>

#include "base/callback.h"
#include "base/lazy_instance.h"
#include "base/macros.h"

namespace chromecast {
namespace android {

class ChromecastConfigAndroid {
public:
static ChromecastConfigAndroid* GetInstance();

// Registers a handler to be notified when SendUsageStats is changed.
void SetSendUsageStatsChangedCallback(
const base::Callback<void(bool)>& callback);

const base::Callback<void(bool)>& send_usage_stats_changed_callback() const {
return send_usage_stats_changed_callback_;
}

private:
friend struct base::DefaultLazyInstanceTraits<ChromecastConfigAndroid>;

ChromecastConfigAndroid();
~ChromecastConfigAndroid();

base::Callback<void(bool)> send_usage_stats_changed_callback_;

DISALLOW_COPY_AND_ASSIGN(ChromecastConfigAndroid);
};

} // namespace android
} // namespace chromecast

#endif // CHROMECAST_ANDROID_CHROMECAST_CONFIG_ANDROID_H_
18 changes: 18 additions & 0 deletions chromecast/android/platform_jni_loader.h
Original file line number Diff line number Diff line change
@@ -0,0 +1,18 @@
// Copyright 2014 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.

#ifndef CHROMECAST_ANDROID_PLATFORM_JNI_LOADER_H_
#define CHROMECAST_ANDROID_PLATFORM_JNI_LOADER_H_

#include <jni.h>

namespace chromecast {
namespace android {

bool PlatformRegisterJni(JNIEnv* env);

} // namespace android
} // namespace chromecast

#endif // CHROMECAST_ANDROID_PLATFORM_JNI_LOADER_H_
16 changes: 16 additions & 0 deletions chromecast/android/platform_jni_loader_stub.cc
Original file line number Diff line number Diff line change
@@ -0,0 +1,16 @@
// Copyright 2014 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 "chromecast/android/platform_jni_loader.h"

namespace chromecast {
namespace android {

bool PlatformRegisterJni(JNIEnv* env) {
// Intentional no-op for public build.
return true;
}

} // namespace android
} // namespace chromecast
2 changes: 2 additions & 0 deletions chromecast/android/src/dummy
Original file line number Diff line number Diff line change
@@ -0,0 +1,2 @@
Note(gunsch): This file is for the cast_shell_apk target in chromecast.gyp.
See the notes above that target's 'java_in_dir' variable in chromecast.gyp.
Loading

0 comments on commit 407189f

Please sign in to comment.