Commit df279583 authored by jianli's avatar jianli Committed by Commit bot

Make chrome.instanceID only available on dev and canary.

Also, we don't need field trial for dev and canary.

BUG=477084
TEST=new tests

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

Cr-Commit-Position: refs/heads/master@{#330273}
parent 34e43ad7
...@@ -10,7 +10,7 @@ ...@@ -10,7 +10,7 @@
#include "chrome/browser/services/gcm/fake_gcm_profile_service.h" #include "chrome/browser/services/gcm/fake_gcm_profile_service.h"
#include "chrome/browser/services/gcm/gcm_profile_service_factory.h" #include "chrome/browser/services/gcm/gcm_profile_service_factory.h"
#include "chrome/browser/services/gcm/instance_id/instance_id_profile_service_factory.h" #include "chrome/browser/services/gcm/instance_id/instance_id_profile_service_factory.h"
#include "chrome/common/chrome_switches.h" #include "chrome/common/extensions/features/feature_channel.h"
#include "chrome/test/base/ui_test_utils.h" #include "chrome/test/base/ui_test_utils.h"
#include "components/gcm_driver/instance_id/fake_gcm_driver_for_instance_id.h" #include "components/gcm_driver/instance_id/fake_gcm_driver_for_instance_id.h"
#include "extensions/test/result_catcher.h" #include "extensions/test/result_catcher.h"
...@@ -36,7 +36,6 @@ class InstanceIDApiTest : public ExtensionApiTest { ...@@ -36,7 +36,6 @@ class InstanceIDApiTest : public ExtensionApiTest {
protected: protected:
void SetUpOnMainThread() override; void SetUpOnMainThread() override;
void SetUpCommandLine(base::CommandLine* command_line) override;
private: private:
DISALLOW_COPY_AND_ASSIGN(InstanceIDApiTest); DISALLOW_COPY_AND_ASSIGN(InstanceIDApiTest);
...@@ -49,35 +48,40 @@ void InstanceIDApiTest::SetUpOnMainThread() { ...@@ -49,35 +48,40 @@ void InstanceIDApiTest::SetUpOnMainThread() {
ExtensionApiTest::SetUpOnMainThread(); ExtensionApiTest::SetUpOnMainThread();
} }
void InstanceIDApiTest::SetUpCommandLine(base::CommandLine* command_line) {
ExtensionApiTest::SetUpCommandLine(command_line);
// Makes sure InstanceID is enabled for testing.
command_line->AppendSwitchASCII(
switches::kForceFieldTrials, "InstanceID/Enabled/");
}
IN_PROC_BROWSER_TEST_F(InstanceIDApiTest, GetID) { IN_PROC_BROWSER_TEST_F(InstanceIDApiTest, GetID) {
extensions::ScopedCurrentChannel current_channel(
chrome::VersionInfo::CHANNEL_DEV);
ASSERT_TRUE(RunExtensionTest("instance_id/get_id")); ASSERT_TRUE(RunExtensionTest("instance_id/get_id"));
} }
IN_PROC_BROWSER_TEST_F(InstanceIDApiTest, GetCreationTime) { IN_PROC_BROWSER_TEST_F(InstanceIDApiTest, GetCreationTime) {
extensions::ScopedCurrentChannel current_channel(
chrome::VersionInfo::CHANNEL_DEV);
ASSERT_TRUE(RunExtensionTest("instance_id/get_creation_time")); ASSERT_TRUE(RunExtensionTest("instance_id/get_creation_time"));
} }
IN_PROC_BROWSER_TEST_F(InstanceIDApiTest, DeleteID) { IN_PROC_BROWSER_TEST_F(InstanceIDApiTest, DeleteID) {
extensions::ScopedCurrentChannel current_channel(
chrome::VersionInfo::CHANNEL_DEV);
ASSERT_TRUE(RunExtensionTest("instance_id/delete_id")); ASSERT_TRUE(RunExtensionTest("instance_id/delete_id"));
} }
IN_PROC_BROWSER_TEST_F(InstanceIDApiTest, GetToken) { IN_PROC_BROWSER_TEST_F(InstanceIDApiTest, GetToken) {
extensions::ScopedCurrentChannel current_channel(
chrome::VersionInfo::CHANNEL_DEV);
ASSERT_TRUE(RunExtensionTest("instance_id/get_token")); ASSERT_TRUE(RunExtensionTest("instance_id/get_token"));
} }
IN_PROC_BROWSER_TEST_F(InstanceIDApiTest, DeleteToken) { IN_PROC_BROWSER_TEST_F(InstanceIDApiTest, DeleteToken) {
extensions::ScopedCurrentChannel current_channel(
chrome::VersionInfo::CHANNEL_DEV);
ASSERT_TRUE(RunExtensionTest("instance_id/delete_token")); ASSERT_TRUE(RunExtensionTest("instance_id/delete_token"));
} }
IN_PROC_BROWSER_TEST_F(InstanceIDApiTest, Incognito) { IN_PROC_BROWSER_TEST_F(InstanceIDApiTest, Incognito) {
extensions::ScopedCurrentChannel current_channel(
chrome::VersionInfo::CHANNEL_DEV);
ResultCatcher catcher; ResultCatcher catcher;
catcher.RestrictToBrowserContext(profile()); catcher.RestrictToBrowserContext(profile());
ResultCatcher incognito_catcher; ResultCatcher incognito_catcher;
...@@ -90,4 +94,16 @@ IN_PROC_BROWSER_TEST_F(InstanceIDApiTest, Incognito) { ...@@ -90,4 +94,16 @@ IN_PROC_BROWSER_TEST_F(InstanceIDApiTest, Incognito) {
EXPECT_TRUE(incognito_catcher.GetNextResult()) << incognito_catcher.message(); EXPECT_TRUE(incognito_catcher.GetNextResult()) << incognito_catcher.message();
} }
IN_PROC_BROWSER_TEST_F(InstanceIDApiTest, BetaChannel) {
extensions::ScopedCurrentChannel current_channel(
chrome::VersionInfo::CHANNEL_BETA);
ASSERT_TRUE(RunExtensionTest("instance_id/channel"));
}
IN_PROC_BROWSER_TEST_F(InstanceIDApiTest, StableChannel) {
extensions::ScopedCurrentChannel current_channel(
chrome::VersionInfo::CHANNEL_STABLE);
ASSERT_TRUE(RunExtensionTest("instance_id/channel"));
}
} // namespace extensions } // namespace extensions
...@@ -19,10 +19,12 @@ bool InstanceIDProfileService::IsInstanceIDEnabled(Profile* profile) { ...@@ -19,10 +19,12 @@ bool InstanceIDProfileService::IsInstanceIDEnabled(Profile* profile) {
if (!gcm::GCMProfileService::IsGCMEnabled(profile)) if (!gcm::GCMProfileService::IsGCMEnabled(profile))
return false; return false;
// Enabled for trunk build. // Enabled only for trunk/canary/dev builds.
chrome::VersionInfo::Channel channel = chrome::VersionInfo::GetChannel(); chrome::VersionInfo::Channel channel = chrome::VersionInfo::GetChannel();
if (channel == chrome::VersionInfo::CHANNEL_UNKNOWN) if (channel == chrome::VersionInfo::CHANNEL_BETA ||
return true; channel == chrome::VersionInfo::CHANNEL_STABLE) {
return false;
}
return InstanceIDDriver::IsInstanceIDEnabled(); return InstanceIDDriver::IsInstanceIDEnabled();
} }
......
...@@ -508,6 +508,7 @@ ...@@ -508,6 +508,7 @@
"contexts": ["blessed_extension"] "contexts": ["blessed_extension"]
}, },
"instanceID": { "instanceID": {
"channel": "dev",
"dependencies": ["permission:gcm"], "dependencies": ["permission:gcm"],
"contexts": ["blessed_extension"] "contexts": ["blessed_extension"]
}, },
......
{
"manifest_version": 2,
"name": "Test InstanceID App",
"version": "1.0",
"description": "Tests InstanceID API",
"background": {
"scripts": ["test.js"]
},
"permissions": ["gcm"]
}
// Copyright 2015 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.
chrome.test.runTests([
function test() {
if (chrome.instanceID)
chrome.test.fail();
else
chrome.test.succeed();
}
]);
...@@ -4,26 +4,17 @@ ...@@ -4,26 +4,17 @@
#include "components/gcm_driver/instance_id/instance_id_driver.h" #include "components/gcm_driver/instance_id/instance_id_driver.h"
#include "base/metrics/field_trial.h"
#include "components/gcm_driver/instance_id/instance_id.h" #include "components/gcm_driver/instance_id/instance_id.h"
namespace instance_id { namespace instance_id {
namespace {
#if !defined(OS_ANDROID)
const char kInstanceIDFieldTrialName[] = "InstanceID";
const char kInstanceIDFieldTrialEnabledGroupName[] = "Enabled";
#endif // !defined(OS_ANDROID)
} // namespace
// static // static
bool InstanceIDDriver::IsInstanceIDEnabled() { bool InstanceIDDriver::IsInstanceIDEnabled() {
#if defined(OS_ANDROID) #if defined(OS_ANDROID)
return true; // Not implemented yet.
return false;
#else #else
std::string group_name = return true;
base::FieldTrialList::FindFullName(kInstanceIDFieldTrialName);
return group_name == kInstanceIDFieldTrialEnabledGroupName;
#endif // defined(OS_ANDROID) #endif // defined(OS_ANDROID)
} }
......
Markdown is supported
0%
or
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment