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

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: all comments except listener/cleanup code 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 <set>
9
10 #include "base/compiler_specific.h"
11 #include "base/memory/singleton.h"
12 #include "base/observer_list.h"
13 #include "chrome/browser/profiles/profile_keyed_service.h"
14 #include "chrome/browser/profiles/profile_keyed_service_factory.h"
15 #include "ui/gfx/native_widget_types.h"
16
17 class Profile;
18
19 namespace content {
20 class WebIntentsDispatcher;
21 }
22
23 // The WebIntentCallbacks class tracks the pending callbacks for web intents
24 // that have been delivered to platform apps, for a particular profile.
25 class WebIntentCallbacks : public ProfileKeyedService {
Mihai Parparita -not on Chrome 2012/08/09 04:38:33 This should either be in the extensions namespace
thorogood 2012/08/09 09:56:51 I mostly inspired this class from ShellWindowRegis
26 public:
27 typedef std::map<std::string, content::WebIntentsDispatcher*> CallbackMap;
Mihai Parparita -not on Chrome 2012/08/09 04:38:33 This doesn't seem to need to be public.
thorogood 2012/08/09 09:56:51 I mostly inspired this class from ShellWindowRegis
28
29 WebIntentCallbacks();
30 virtual ~WebIntentCallbacks();
31
32 // Returns the instance for the given profile. This is a convenience wrapper
33 // around WebIntentCallbacks::Factory::GetForProfile.
34 static WebIntentCallbacks* Get(Profile* profile);
35
36 // Registers the callback for the Web Intent we're about to dispatch to a
37 // platform app. Returns an opaque string identifier that should later be
38 // dispatched to RetrieveCallback in order to invoke the callback registered
39 // here.
40 std::string RegisterCallback(content::WebIntentsDispatcher* dispatcher);
41
42 // Retrieves the callback for the given opaque string identifier. This will
43 // clear the callback. If there is no callback registered under this
44 // identifier, then this will return NULL.
45 content::WebIntentsDispatcher* RetrieveCallback(std::string key);
46
47 private:
48 class Factory : public ProfileKeyedServiceFactory {
49 public:
50 static WebIntentCallbacks* GetForProfile(Profile* profile);
51
52 static Factory* GetInstance();
53 private:
54 friend struct DefaultSingletonTraits<Factory>;
55
56 Factory();
57 virtual ~Factory();
58
59 // ProfileKeyedServiceFactory
60 virtual ProfileKeyedService* BuildServiceInstanceFor(
61 Profile* profile) const OVERRIDE;
62 };
63
64 int last_id_;
65
66 CallbackMap pending_;
67 };
68
69 #endif // CHROME_BROWSER_EXTENSIONS_WEB_INTENT_CALLBACKS_H_
OLDNEW

Powered by Google App Engine
This is Rietveld 408576698