diff options
21 files changed, 10 insertions, 105 deletions
diff --git a/chrome/browser/extensions/api/gcm/gcm_api.cc b/chrome/browser/extensions/api/gcm/gcm_api.cc index ef2af71..03a9b9a 100644 --- a/chrome/browser/extensions/api/gcm/gcm_api.cc +++ b/chrome/browser/extensions/api/gcm/gcm_api.cc @@ -8,7 +8,6 @@ #include <map> #include <vector> -#include "base/sha1.h" #include "base/strings/string_number_conversions.h" #include "base/strings/string_util.h" #include "chrome/browser/profiles/profile.h" @@ -31,7 +30,6 @@ const char kGoogleRestrictedPrefix[] = "google"; const char kInvalidParameter[] = "Function was called with invalid parameters."; const char kNotSignedIn[] = "Profile was not signed in."; -const char kCertificateMissing[] = "Manifest key was missing."; const char kAsyncOperationPending[] = "Asynchronous operation is pending."; const char kNetworkError[] = "Network error occurred."; @@ -39,11 +37,6 @@ const char kServerError[] = "Server error occurred."; const char kTtlExceeded[] = "Time-to-live exceeded."; const char kUnknownError[] = "Unknown error occurred."; -std::string SHA1HashHexString(const std::string& str) { - std::string hash = base::SHA1HashString(str); - return base::HexEncode(hash.data(), hash.size()); -} - const char* GcmResultToError(gcm::GCMClient::Result result) { switch (result) { case gcm::GCMClient::SUCCESS: @@ -52,8 +45,6 @@ const char* GcmResultToError(gcm::GCMClient::Result result) { return kInvalidParameter; case gcm::GCMClient::NOT_SIGNED_IN: return kNotSignedIn; - case gcm::GCMClient::CERTIFICATE_MISSING: - return kCertificateMissing; case gcm::GCMClient::ASYNC_OPERATION_PENDING: return kAsyncOperationPending; case gcm::GCMClient::NETWORK_ERROR: @@ -121,16 +112,9 @@ bool GcmRegisterFunction::DoWork() { api::gcm::Register::Params::Create(*args_)); EXTENSION_FUNCTION_VALIDATE(params.get()); - if (GetExtension()->public_key().empty()) { - CompleteFunctionWithResult(std::string(), - gcm::GCMClient::CERTIFICATE_MISSING); - return false; - } - GCMProfileService()->Register( GetExtension()->id(), params->sender_ids, - SHA1HashHexString(GetExtension()->public_key()), base::Bind(&GcmRegisterFunction::CompleteFunctionWithResult, this)); return true; diff --git a/chrome/browser/extensions/api/gcm/gcm_apitest.cc b/chrome/browser/extensions/api/gcm/gcm_apitest.cc index 63ec748..85a70a6 100644 --- a/chrome/browser/extensions/api/gcm/gcm_apitest.cc +++ b/chrome/browser/extensions/api/gcm/gcm_apitest.cc @@ -103,9 +103,6 @@ IN_PROC_BROWSER_TEST_F(GcmApiTest, Register) { StartCollecting(); ASSERT_TRUE(RunExtensionTest("gcm/functions/register")); - // SHA1 of the public key provided in manifest.json. - EXPECT_EQ("26469186F238EE08FA71C38311C6990F61D40DCA", - service()->last_registered_cert()); const std::vector<std::string>& sender_ids = service()->last_registered_sender_ids(); EXPECT_TRUE(std::find(sender_ids.begin(), sender_ids.end(), "Sender1") != @@ -114,13 +111,6 @@ IN_PROC_BROWSER_TEST_F(GcmApiTest, Register) { sender_ids.end()); } -IN_PROC_BROWSER_TEST_F(GcmApiTest, RegisterWithoutKey) { - if (ShouldSkipTest()) - return; - - ASSERT_TRUE(RunExtensionTest("gcm/functions/register_without_key")); -} - IN_PROC_BROWSER_TEST_F(GcmApiTest, SendValidation) { if (ShouldSkipTest()) return; diff --git a/chrome/browser/invalidation/gcm_network_channel_delegate_impl.cc b/chrome/browser/invalidation/gcm_network_channel_delegate_impl.cc index 50245d1..e773f115 100644 --- a/chrome/browser/invalidation/gcm_network_channel_delegate_impl.cc +++ b/chrome/browser/invalidation/gcm_network_channel_delegate_impl.cc @@ -30,11 +30,10 @@ namespace { // legacy format where gmail account can be specificed. Below value is copied // from Android. const char kInvalidationsSenderId[] = "ipc.invalidation@gmail.com"; -// In Android world AppId and Cert are provided by operating system and should +// In Android world AppId is provided by operating system and should // match package name and hash of application. In desktop world these values // are arbitrary and not verified/enforced by registration service (yet). const char kInvalidationsAppId[] = "com.google.chrome.invalidations"; -const char kInvalidationsCert[] = "ABC"; // In each call to Register object of RegisterCall will be created. // Its purpose is to pass context (profile and callback) around between threads @@ -87,7 +86,6 @@ void RegisterCall::RegisterOnUIThread() { gcm_profile_service->Register( kInvalidationsAppId, sender_ids, - kInvalidationsCert, base::Bind(&RegisterCall::RegisterFinishedOnUIThread, this)); } diff --git a/chrome/browser/services/gcm/fake_gcm_profile_service.cc b/chrome/browser/services/gcm/fake_gcm_profile_service.cc index c124f4f..b789d15 100644 --- a/chrome/browser/services/gcm/fake_gcm_profile_service.cc +++ b/chrome/browser/services/gcm/fake_gcm_profile_service.cc @@ -27,7 +27,6 @@ FakeGCMProfileService::~FakeGCMProfileService() {} void FakeGCMProfileService::Register(const std::string& app_id, const std::vector<std::string>& sender_ids, - const std::string& cert, RegisterCallback callback) { base::MessageLoop::current()->PostTask( FROM_HERE, @@ -35,19 +34,16 @@ void FakeGCMProfileService::Register(const std::string& app_id, base::Unretained(this), app_id, sender_ids, - cert, callback)); } void FakeGCMProfileService::RegisterFinished( const std::string& app_id, const std::vector<std::string>& sender_ids, - const std::string& cert, RegisterCallback callback) { if (collect_) { last_registered_app_id_ = app_id; last_registered_sender_ids_ = sender_ids; - last_registered_cert_ = cert; } callback.Run(base::UintToString(sender_ids.size()), GCMClient::SUCCESS); diff --git a/chrome/browser/services/gcm/fake_gcm_profile_service.h b/chrome/browser/services/gcm/fake_gcm_profile_service.h index 1848c0b..324a887 100644 --- a/chrome/browser/services/gcm/fake_gcm_profile_service.h +++ b/chrome/browser/services/gcm/fake_gcm_profile_service.h @@ -26,7 +26,6 @@ class FakeGCMProfileService : public GCMProfileService { // GCMProfileService overrides. virtual void Register(const std::string& app_id, const std::vector<std::string>& sender_ids, - const std::string& cert, RegisterCallback callback) OVERRIDE; virtual void Send(const std::string& app_id, const std::string& receiver_id, @@ -35,7 +34,6 @@ class FakeGCMProfileService : public GCMProfileService { void RegisterFinished(const std::string& app_id, const std::vector<std::string>& sender_ids, - const std::string& cert, RegisterCallback callback); void SendFinished(const std::string& app_id, @@ -59,10 +57,6 @@ class FakeGCMProfileService : public GCMProfileService { return last_registered_sender_ids_; } - const std::string& last_registered_cert() const { - return last_registered_cert_; - } - void set_collect(bool collect) { collect_ = collect; } @@ -73,7 +67,6 @@ class FakeGCMProfileService : public GCMProfileService { bool collect_; std::string last_registered_app_id_; std::vector<std::string> last_registered_sender_ids_; - std::string last_registered_cert_; GCMClient::OutgoingMessage last_sent_message_; std::string last_receiver_id_; diff --git a/chrome/browser/services/gcm/gcm_client_mock.cc b/chrome/browser/services/gcm/gcm_client_mock.cc index de65af2..4ca60bd 100644 --- a/chrome/browser/services/gcm/gcm_client_mock.cc +++ b/chrome/browser/services/gcm/gcm_client_mock.cc @@ -64,7 +64,6 @@ void GCMClientMock::CheckOut() { } void GCMClientMock::Register(const std::string& app_id, - const std::string& cert, const std::vector<std::string>& sender_ids) { DCHECK(content::BrowserThread::CurrentlyOn(content::BrowserThread::IO)); diff --git a/chrome/browser/services/gcm/gcm_client_mock.h b/chrome/browser/services/gcm/gcm_client_mock.h index fef49d7..17be609 100644 --- a/chrome/browser/services/gcm/gcm_client_mock.h +++ b/chrome/browser/services/gcm/gcm_client_mock.h @@ -49,7 +49,6 @@ class GCMClientMock : public GCMClient { virtual void Stop() OVERRIDE; virtual void CheckOut() OVERRIDE; virtual void Register(const std::string& app_id, - const std::string& cert, const std::vector<std::string>& sender_ids) OVERRIDE; virtual void Unregister(const std::string& app_id) OVERRIDE; virtual void Send(const std::string& app_id, diff --git a/chrome/browser/services/gcm/gcm_profile_service.cc b/chrome/browser/services/gcm/gcm_profile_service.cc index 4cb54bd..198024d 100644 --- a/chrome/browser/services/gcm/gcm_profile_service.cc +++ b/chrome/browser/services/gcm/gcm_profile_service.cc @@ -268,8 +268,7 @@ class GCMProfileService::IOWorker void Stop(); void CheckOut(); void Register(const std::string& app_id, - const std::vector<std::string>& sender_ids, - const std::string& cert); + const std::vector<std::string>& sender_ids); void Unregister(const std::string& app_id); void Send(const std::string& app_id, const std::string& receiver_id, @@ -444,11 +443,10 @@ void GCMProfileService::IOWorker::CheckOut() { void GCMProfileService::IOWorker::Register( const std::string& app_id, - const std::vector<std::string>& sender_ids, - const std::string& cert) { + const std::vector<std::string>& sender_ids) { DCHECK(content::BrowserThread::CurrentlyOn(content::BrowserThread::IO)); - gcm_client_->Register(app_id, cert, sender_ids); + gcm_client_->Register(app_id, sender_ids); } void GCMProfileService::IOWorker::Unregister(const std::string& app_id) { @@ -589,7 +587,6 @@ void GCMProfileService::Stop() { void GCMProfileService::Register(const std::string& app_id, const std::vector<std::string>& sender_ids, - const std::string& cert, RegisterCallback callback) { DCHECK(content::BrowserThread::CurrentlyOn(content::BrowserThread::UI)); DCHECK(!app_id.empty() && !sender_ids.empty() && !callback.is_null()); @@ -620,17 +617,15 @@ void GCMProfileService::Register(const std::string& app_id, base::Bind(&GCMProfileService::DoRegister, weak_ptr_factory_.GetWeakPtr(), app_id, - sender_ids, - cert)); + sender_ids)); return; } - DoRegister(app_id, sender_ids, cert); + DoRegister(app_id, sender_ids); } void GCMProfileService::DoRegister(const std::string& app_id, - const std::vector<std::string>& sender_ids, - const std::string& cert) { + const std::vector<std::string>& sender_ids) { std::map<std::string, RegisterCallback>::iterator callback_iter = register_callbacks_.find(app_id); if (callback_iter == register_callbacks_.end()) { @@ -671,8 +666,7 @@ void GCMProfileService::DoRegister(const std::string& app_id, base::Bind(&GCMProfileService::IOWorker::Register, io_worker_, app_id, - normalized_sender_ids, - cert)); + normalized_sender_ids)); } void GCMProfileService::Send(const std::string& app_id, diff --git a/chrome/browser/services/gcm/gcm_profile_service.h b/chrome/browser/services/gcm/gcm_profile_service.h index 6f53ffa..5d4ad45 100644 --- a/chrome/browser/services/gcm/gcm_profile_service.h +++ b/chrome/browser/services/gcm/gcm_profile_service.h @@ -81,14 +81,12 @@ class GCMProfileService : public BrowserContextKeyedService, // Registers |sender_id| for an app. A registration ID will be returned by // the GCM server. // |app_id|: application ID. - // |cert|: SHA-1 of public key of the application, in base16 format. // |sender_ids|: list of IDs of the servers that are allowed to send the // messages to the application. These IDs are assigned by the // Google API Console. // |callback|: to be called once the asynchronous operation is done. virtual void Register(const std::string& app_id, const std::vector<std::string>& sender_ids, - const std::string& cert, RegisterCallback callback); // Sends a message to a given receiver. @@ -151,8 +149,7 @@ class GCMProfileService : public BrowserContextKeyedService, void Unregister(const std::string& app_id); void DoRegister(const std::string& app_id, - const std::vector<std::string>& sender_ids, - const std::string& cert); + const std::vector<std::string>& sender_ids); void DoSend(const std::string& app_id, const std::string& receiver_id, const GCMClient::OutgoingMessage& message); diff --git a/chrome/browser/services/gcm/gcm_profile_service_unittest.cc b/chrome/browser/services/gcm/gcm_profile_service_unittest.cc index cb9c7df..2ab485a 100644 --- a/chrome/browser/services/gcm/gcm_profile_service_unittest.cc +++ b/chrome/browser/services/gcm/gcm_profile_service_unittest.cc @@ -51,7 +51,6 @@ const char kTestingUsername2[] = "user2@example.com"; const char kTestingUsername3[] = "user3@example.com"; const char kTestingAppId[] = "TestApp1"; const char kTestingAppId2[] = "TestApp2"; -const char kTestingSha1Cert[] = "testing_cert1"; const char kUserId[] = "user1"; const char kUserId2[] = "user2"; @@ -364,7 +363,6 @@ class GCMProfileServiceTestConsumer : public GCMProfileService::TestingDelegate{ GetGCMProfileService()->Register( app_id, sender_ids, - kTestingSha1Cert, base::Bind(&GCMProfileServiceTestConsumer::RegisterCompleted, base::Unretained(this))); } diff --git a/chrome/test/data/extensions/api_test/gcm/functions/incognito/manifest.json b/chrome/test/data/extensions/api_test/gcm/functions/incognito/manifest.json index 666b5e4..ff32617 100644 --- a/chrome/test/data/extensions/api_test/gcm/functions/incognito/manifest.json +++ b/chrome/test/data/extensions/api_test/gcm/functions/incognito/manifest.json @@ -1,7 +1,6 @@ { "manifest_version": 2, "name": "Test GCM App", - "key": "MIGfMA0GCSqGSIb3DQEBAQUAA4GNADCBiQKBgQCzXCAvAUOKVNuBGWfaRY6QW1YSs+2EnmERkltllVyk9T6H/a7wkdBAKpvKsEbE9PtjmHrP/Jh/XFX1AdpTFAJ7KsQ55GdyTwUW7iB5HsR4NI6dXewK2ba+vDbtBLytR9msXFpvuVnAsEmLlHf9RGuxczvOEbGXcHkUw0AuzGu72wIDAQAB", "version": "1.0", "description": "Tests GCM API", "background": { diff --git a/chrome/test/data/extensions/api_test/gcm/functions/register/manifest.json b/chrome/test/data/extensions/api_test/gcm/functions/register/manifest.json index 3282e33..6acb9f8 100644 --- a/chrome/test/data/extensions/api_test/gcm/functions/register/manifest.json +++ b/chrome/test/data/extensions/api_test/gcm/functions/register/manifest.json @@ -1,7 +1,6 @@ { "manifest_version": 2, "name": "Test GCM App", - "key": "MIGfMA0GCSqGSIb3DQEBAQUAA4GNADCBiQKBgQCzXCAvAUOKVNuBGWfaRY6QW1YSs+2EnmERkltllVyk9T6H/a7wkdBAKpvKsEbE9PtjmHrP/Jh/XFX1AdpTFAJ7KsQ55GdyTwUW7iB5HsR4NI6dXewK2ba+vDbtBLytR9msXFpvuVnAsEmLlHf9RGuxczvOEbGXcHkUw0AuzGu72wIDAQAB", "version": "1.0", "description": "Tests GCM API", "background": { diff --git a/chrome/test/data/extensions/api_test/gcm/functions/register_without_key/manifest.json b/chrome/test/data/extensions/api_test/gcm/functions/register_without_key/manifest.json deleted file mode 100644 index 6acb9f8..0000000 --- a/chrome/test/data/extensions/api_test/gcm/functions/register_without_key/manifest.json +++ /dev/null @@ -1,10 +0,0 @@ -{ - "manifest_version": 2, - "name": "Test GCM App", - "version": "1.0", - "description": "Tests GCM API", - "background": { - "scripts": ["register.js"] - }, - "permissions": ["gcm"] -} diff --git a/chrome/test/data/extensions/api_test/gcm/functions/register_without_key/register.js b/chrome/test/data/extensions/api_test/gcm/functions/register_without_key/register.js deleted file mode 100644 index 66255eb..0000000 --- a/chrome/test/data/extensions/api_test/gcm/functions/register_without_key/register.js +++ /dev/null @@ -1,15 +0,0 @@ -// 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. - -chrome.test.runTests([ - function testRegister() { - var senderIds = ["Sender1", "Sender2"]; - chrome.gcm.register(senderIds, function(registrationId) { - if (chrome.runtime.lastError.message == "Manifest key was missing.") - chrome.test.succeed(); - else - chrome.test.fail("gcm.register should fail."); - }); - } -]); diff --git a/google_apis/gcm/engine/registration_request.cc b/google_apis/gcm/engine/registration_request.cc index 3acd591..db6981d 100644 --- a/google_apis/gcm/engine/registration_request.cc +++ b/google_apis/gcm/engine/registration_request.cc @@ -28,7 +28,6 @@ const char kRegistrationRequestContentType[] = // Request constants. const char kAppIdKey[] = "app"; -const char kCertKey[] = "cert"; const char kDeviceIdKey[] = "device"; const char kLoginHeader[] = "AidLogin"; const char kSenderKey[] = "sender"; @@ -89,12 +88,10 @@ RegistrationRequest::RequestInfo::RequestInfo( uint64 android_id, uint64 security_token, const std::string& app_id, - const std::string& cert, const std::vector<std::string>& sender_ids) : android_id(android_id), security_token(security_token), app_id(app_id), - cert(cert), sender_ids(sender_ids) { } @@ -121,7 +118,6 @@ void RegistrationRequest::Start() { DCHECK(!callback_.is_null()); DCHECK(request_info_.android_id != 0UL); DCHECK(request_info_.security_token != 0UL); - DCHECK(!request_info_.cert.empty()); DCHECK(0 < request_info_.sender_ids.size() && request_info_.sender_ids.size() <= kMaxSenders); @@ -139,7 +135,6 @@ void RegistrationRequest::Start() { std::string body; BuildFormEncoding(kAppIdKey, request_info_.app_id, &body); - BuildFormEncoding(kCertKey, request_info_.cert, &body); BuildFormEncoding(kDeviceIdKey, android_id, &body); std::string senders; diff --git a/google_apis/gcm/engine/registration_request.h b/google_apis/gcm/engine/registration_request.h index c5aff57..7b7acbb 100644 --- a/google_apis/gcm/engine/registration_request.h +++ b/google_apis/gcm/engine/registration_request.h @@ -62,7 +62,6 @@ class GCM_EXPORT RegistrationRequest : public net::URLFetcherDelegate { RequestInfo(uint64 android_id, uint64 security_token, const std::string& app_id, - const std::string& cert, const std::vector<std::string>& sender_ids); ~RequestInfo(); diff --git a/google_apis/gcm/engine/registration_request_unittest.cc b/google_apis/gcm/engine/registration_request_unittest.cc index f08c4f4..9efb4e1 100644 --- a/google_apis/gcm/engine/registration_request_unittest.cc +++ b/google_apis/gcm/engine/registration_request_unittest.cc @@ -19,7 +19,6 @@ namespace gcm { namespace { const uint64 kAndroidId = 42UL; const char kAppId[] = "TestAppId"; -const char kCert[] = "0DEADBEEF420"; const char kDeveloperId[] = "Project1"; const char kLoginHeader[] = "AidLogin"; const uint64 kSecurityToken = 77UL; @@ -110,7 +109,6 @@ void RegistrationRequestTest::CreateRequest(const std::string& sender_ids) { RegistrationRequest::RequestInfo(kAndroidId, kSecurityToken, kAppId, - kCert, senders), kDefaultBackoffPolicy, base::Bind(&RegistrationRequestTest::RegistrationCallback, @@ -175,7 +173,6 @@ TEST_F(RegistrationRequestTest, RequestDataPassedToFetcher) { std::map<std::string, std::string> expected_pairs; expected_pairs["app"] = kAppId; expected_pairs["sender"] = kDeveloperId; - expected_pairs["cert"] = kCert; expected_pairs["device"] = base::Uint64ToString(kAndroidId); // Verify data was formatted properly. diff --git a/google_apis/gcm/gcm_client.h b/google_apis/gcm/gcm_client.h index a25cb12..f0b1bac 100644 --- a/google_apis/gcm/gcm_client.h +++ b/google_apis/gcm/gcm_client.h @@ -40,8 +40,6 @@ class GCM_EXPORT GCMClient { INVALID_PARAMETER, // Profile not signed in. NOT_SIGNED_IN, - // Certificate was missing. Certain operation, like register, requires it. - CERTIFICATE_MISSING, // Previous asynchronous operation is still pending to finish. Certain // operation, like register, is only allowed one at a time. ASYNC_OPERATION_PENDING, @@ -166,12 +164,10 @@ class GCM_EXPORT GCMClient { // Registers the application for GCM. Delegate::OnRegisterFinished will be // called asynchronously upon completion. // |app_id|: application ID. - // |cert|: SHA-1 of public key of the application, in base16 format. // |sender_ids|: list of IDs of the servers that are allowed to send the // messages to the application. These IDs are assigned by the // Google API Console. virtual void Register(const std::string& app_id, - const std::string& cert, const std::vector<std::string>& sender_ids) = 0; // Unregisters the application from GCM when it is uninstalled. diff --git a/google_apis/gcm/gcm_client_impl.cc b/google_apis/gcm/gcm_client_impl.cc index aa12ee8..19b3d54 100644 --- a/google_apis/gcm/gcm_client_impl.cc +++ b/google_apis/gcm/gcm_client_impl.cc @@ -302,14 +302,12 @@ void GCMClientImpl::CheckOut() { } void GCMClientImpl::Register(const std::string& app_id, - const std::string& cert, const std::vector<std::string>& sender_ids) { DCHECK_EQ(state_, READY); RegistrationRequest::RequestInfo request_info( device_checkin_info_.android_id, device_checkin_info_.secret, app_id, - cert, sender_ids); DCHECK_EQ(0u, pending_registrations_.count(app_id)); diff --git a/google_apis/gcm/gcm_client_impl.h b/google_apis/gcm/gcm_client_impl.h index 247360a..4050b36 100644 --- a/google_apis/gcm/gcm_client_impl.h +++ b/google_apis/gcm/gcm_client_impl.h @@ -59,7 +59,6 @@ class GCM_EXPORT GCMClientImpl : public GCMClient { virtual void Stop() OVERRIDE; virtual void CheckOut() OVERRIDE; virtual void Register(const std::string& app_id, - const std::string& cert, const std::vector<std::string>& sender_ids) OVERRIDE; virtual void Unregister(const std::string& app_id) OVERRIDE; virtual void Send(const std::string& app_id, diff --git a/google_apis/gcm/gcm_client_impl_unittest.cc b/google_apis/gcm/gcm_client_impl_unittest.cc index d45a0fc..b6c401e 100644 --- a/google_apis/gcm/gcm_client_impl_unittest.cc +++ b/google_apis/gcm/gcm_client_impl_unittest.cc @@ -366,7 +366,7 @@ TEST_F(GCMClientImplTest, CheckOut) { TEST_F(GCMClientImplTest, RegisterApp) { std::vector<std::string> senders; senders.push_back("sender"); - gcm_client()->Register("app_id", "cert", senders); + gcm_client()->Register("app_id", senders); CompleteRegistration("reg_id"); EXPECT_EQ(REGISTRATION_COMPLETED, last_event()); |