Only grant permissions to new extensions from sync if they have the expected version
[chromium-blink-merge.git] / components / proximity_auth / cryptauth / fake_cryptauth_gcm_manager.h
blobb25eb83066ec59fb99ee7ee119a708b199172af1
1 // Copyright 2015 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.
5 #ifndef COMPONENTS_PROXIMITY_AUTH_FAKE_CRYPTAUTH_FAKE_CRYPTAUTH_GCM_MANAGER_H
6 #define COMPONENTS_PROXIMITY_AUTH_FAKE_CRYPTAUTH_FAKE_CRYPTAUTH_GCM_MANAGER_H
8 #include "base/macros.h"
9 #include "base/observer_list.h"
10 #include "components/proximity_auth/cryptauth/cryptauth_gcm_manager.h"
12 namespace proximity_auth {
14 // CryptAuthGCMManager implementation for testing purposes.
15 class FakeCryptAuthGCMManager : public CryptAuthGCMManager {
16 public:
17 // Creates the instance:
18 // |registration_id|: The GCM registration id from a previous successful
19 // enrollment. Pass in an empty |registration_id| to simulate never having
20 // registered successfully.
21 explicit FakeCryptAuthGCMManager(const std::string& registration_id);
23 ~FakeCryptAuthGCMManager() override;
25 // CryptAuthGCMManager:
26 void StartListening() override;
27 void RegisterWithGCM() override;
28 std::string GetRegistrationId() override;
29 void AddObserver(Observer* observer) override;
30 void RemoveObserver(Observer* observer) override;
32 // Simulates completing a GCM registration with the resulting
33 // |registration_id|. Passing an empty |registration_id| will simulate a
34 // registration failure.
35 // A registration attempt must currently be in progress.
36 void CompleteRegistration(const std::string& registration_id);
38 // Simulates receiving a re-enroll push message from GCM.
39 void PushReenrollMessage();
41 // Simulates receiving a re-sync push message from GCM.
42 void PushResyncMessage();
44 bool registration_in_progress() { return registration_in_progress_; }
46 void set_registration_id(const std::string& registration_id) {
47 registration_id_ = registration_id;
50 private:
51 // Whether a registration attempt is currently in progress.
52 bool registration_in_progress_;
54 // The registration id obtained from the last successful registration.
55 std::string registration_id_;
57 base::ObserverList<Observer> observers_;
59 DISALLOW_COPY_AND_ASSIGN(FakeCryptAuthGCMManager);
62 } // namespace proximity_auth
64 #endif // COMPONENTS_PROXIMITY_FAKE_CRYPTAUTH_FAKE_CRYPTAUTH_GCM_MANAGER_H