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

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

Issue 12225076: Delete most web intents code. (Closed) Base URL: svn://svn.chromium.org/chrome/trunk/src
Patch Set: rebase Created 7 years, 10 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 | Annotate | Revision Log
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 // Private method to get and clear the dispatcher for the given string key.
69 // If there is no dispatcher available, this will return NULL. Otherwise, this
70 // transfers ownership of the WebIntentsDispatcher to the caller.
71 content::WebIntentsDispatcher* GetAndClear(const std::string& key);
72
73 class SourceObserver;
74
75 // Used as an incrementing ID for callback keys.
76 int last_id_;
77
78 // Stores all pending callbacks sent to platform apps.
79 CallbackMap pending_;
80 };
81
82 } // namespace extensions
83
84 #endif // CHROME_BROWSER_EXTENSIONS_WEB_INTENT_CALLBACKS_H_
OLDNEW
« no previous file with comments | « chrome/browser/extensions/platform_app_launcher.cc ('k') | chrome/browser/extensions/web_intent_callbacks.cc » ('j') | no next file with comments »

Powered by Google App Engine
This is Rietveld 408576698