Check USB device path access when prompting users to select a device.
[chromium-blink-merge.git] / chrome / browser / push_messaging / push_messaging_application_id.h
blobdea7a595347c7cef460666a717df2834a6e35048
1 // Copyright 2014 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 CHROME_BROWSER_PUSH_MESSAGING_PUSH_MESSAGING_APPLICATION_ID_H_
6 #define CHROME_BROWSER_PUSH_MESSAGING_PUSH_MESSAGING_APPLICATION_ID_H_
8 #include <string>
9 #include <vector>
11 #include "base/basictypes.h"
12 #include "url/gurl.h"
14 class Profile;
16 namespace user_prefs {
17 class PrefRegistrySyncable;
20 // The prefix used for all push messaging application ids.
21 extern const char kPushMessagingApplicationIdPrefix[];
23 // Type used to identify a web app from a Push API perspective.
24 // These can be persisted to disk, in a 1:1 mapping between app_id_guid and
25 // pair<origin, service_worker_registration_id>.
26 class PushMessagingApplicationId {
27 public:
28 // Register profile-specific prefs.
29 static void RegisterProfilePrefs(user_prefs::PrefRegistrySyncable* registry);
31 // Generates a new application id with random app_id_guid.
32 static PushMessagingApplicationId Generate(
33 const GURL& origin,
34 int64 service_worker_registration_id);
36 // Looks up an application id by app_id_guid. Will be invalid if not found.
37 static PushMessagingApplicationId Get(Profile* profile,
38 const std::string& app_id_guid);
40 // Looks up an application id by origin & service worker registration id.
41 // Will be invalid if not found.
42 static PushMessagingApplicationId Get(Profile* profile,
43 const GURL& origin,
44 int64 service_worker_registration_id);
46 // Returns all the PushMessagingApplicationId currently registered for the
47 // given |profile|.
48 static std::vector<PushMessagingApplicationId> GetAll(Profile* profile);
50 ~PushMessagingApplicationId();
52 // Persist this application id to disk.
53 void PersistToDisk(Profile* profile) const;
55 // Delete this application id from disk.
56 void DeleteFromDisk(Profile* profile) const; // TODO: Does const make sense?
58 bool IsValid() const;
60 const std::string& app_id_guid() const { return app_id_guid_; }
61 const GURL& origin() const { return origin_; }
62 int64 service_worker_registration_id() const {
63 return service_worker_registration_id_;
66 private:
67 friend class PushMessagingApplicationIdTest;
69 // Constructs an invalid app id.
70 PushMessagingApplicationId();
71 // Constructs a valid app id.
72 PushMessagingApplicationId(const std::string& app_id_guid,
73 const GURL& origin,
74 int64 service_worker_registration_id);
76 std::string app_id_guid_;
77 GURL origin_;
78 int64 service_worker_registration_id_;
81 #endif // CHROME_BROWSER_PUSH_MESSAGING_PUSH_MESSAGING_APPLICATION_ID_H_