Chromium Code Reviews
chromiumcodereview-hr@appspot.gserviceaccount.com (chromiumcodereview-hr) | Please choose your nickname with Settings | Help | Chromium Project | Gerrit Changes | Sign out
(257)

Side by Side Diff: chrome/browser/extensions/web_intent_callbacks.h

Issue 10828172: Allow platform apps to respond to Web Intents (Closed) Base URL: http://git.chromium.org/chromium/src.git@master
Patch Set: Ben' Created 8 years, 4 months ago
Use n/p to move between diff chunks; N/P to move between comments. Draft comments are only viewable by you.
Jump to:
View unified diff | Download patch
OLDNEW
(Empty)
1 // Copyright (c) 2012 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.
4
5 #ifndef CHROME_BROWSER_EXTENSIONS_WEB_INTENT_CALLBACKS_H_
6 #define CHROME_BROWSER_EXTENSIONS_WEB_INTENT_CALLBACKS_H_
7
8 #include "base/memory/singleton.h"
9 #include "chrome/browser/profiles/profile_keyed_service.h"
10 #include "chrome/browser/profiles/profile_keyed_service_factory.h"
11
12 class Profile;
13
14 namespace content {
15 class WebContents;
16 class WebIntentsDispatcher;
17 }
18
19 namespace extensions {
20 class Extension;
21
22 // The WebIntentCallbacks class tracks the pending callbacks for web intents
23 // that have been delivered to packaged apps (i.e., new-style apps containing
24 // shell windows), for a particular profile.
25 class WebIntentCallbacks : public ProfileKeyedService {
26 public:
27 WebIntentCallbacks();
28 virtual ~WebIntentCallbacks();
29
30 // Returns the instance for the given profile. This is a convenience wrapper
31 // around WebIntentCallbacks::Factory::GetForProfile.
32 static WebIntentCallbacks* Get(Profile* profile);
33
34 // Registers the callback for the Web Intent we're about to dispatch to the
35 // given extension. Returns an identifier that should later be dispatched to
36 // RetrieveCallback in order to invoke the callback registered here.
37 // This transfers ownership of WebIntentsDispatcher to this class.
38 int RegisterCallback(const Extension* extension,
39 content::WebIntentsDispatcher* dispatcher,
40 content::WebContents* source);
41
42 // Retrieves the callback for the given identifier, for a response from the
43 // specified extension. This will clear the callback. If there is no callback
44 // registered under this identifier, then this will return NULL. This
45 // transfers ownership of WebIntentsDispatcher to the caller.
46 content::WebIntentsDispatcher* RetrieveCallback(const Extension* extension,
47 int intent_id);
48
49 private:
50 typedef std::map<std::string, content::WebIntentsDispatcher*> CallbackMap;
51
52 class Factory : public ProfileKeyedServiceFactory {
53 public:
54 static WebIntentCallbacks* GetForProfile(Profile* profile);
55
56 static Factory* GetInstance();
57 private:
58 friend struct DefaultSingletonTraits<Factory>;
59
60 Factory();
61 virtual ~Factory();
62
63 // ProfileKeyedServiceFactory
64 virtual ProfileKeyedService* BuildServiceInstanceFor(
65 Profile* profile) const OVERRIDE;
66 };
67
68 content::WebIntentsDispatcher* InternalRetrieveCallback(std::string key);
benwells 2012/08/14 06:57:07 There should be a comment here to say you're also
thorogood 2012/08/15 06:15:49 Done.
69
70 class SourceObserver;
71
72 // Used as an incrementing ID for callback keys.
73 int last_id_;
74
75 // Stores all pending callbacks sent to platform apps.
76 CallbackMap pending_;
77 };
78
79 } // namespace extensions
80
81 #endif // CHROME_BROWSER_EXTENSIONS_WEB_INTENT_CALLBACKS_H_
OLDNEW

Powered by Google App Engine
This is Rietveld 408576698