Chromium Code Reviews| OLD | NEW |
|---|---|
| (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" | |
|
benwells
2012/08/13 08:27:29
Are all these includes needed?
thorogood
2012/08/14 02:59:08
Done.
| |
| 16 #include "webkit/glue/web_intent_reply_data.h" | |
| 17 | |
| 18 class Profile; | |
| 19 | |
| 20 namespace content { | |
| 21 class WebContents; | |
| 22 class WebIntentsDispatcher; | |
| 23 } | |
| 24 | |
| 25 namespace extensions { | |
| 26 class Extension; | |
| 27 | |
| 28 // The WebIntentCallbacks class tracks the pending callbacks for web intents | |
| 29 // that have been delivered to platform apps, for a particular profile. | |
| 30 class WebIntentCallbacks : public ProfileKeyedService { | |
|
benwells
2012/08/13 08:27:29
I know we're now in the extensions namespace, but
thorogood
2012/08/14 02:59:08
Done.
benwells
2012/08/14 06:57:07
Ah .. I meant by changing the class name, but I'm
thorogood
2012/08/15 06:15:49
Ok. What about PlatformAppIntentRegistry?
| |
| 31 public: | |
| 32 WebIntentCallbacks(); | |
| 33 virtual ~WebIntentCallbacks(); | |
| 34 | |
| 35 // Returns the instance for the given profile. This is a convenience wrapper | |
| 36 // around WebIntentCallbacks::Factory::GetForProfile. | |
| 37 static WebIntentCallbacks* Get(Profile* profile); | |
| 38 | |
| 39 // Registers the callback for the Web Intent we're about to dispatch to the | |
| 40 // given extension. Returns an identifier that should later be dispatched to | |
| 41 // RetrieveCallback in order to invoke the callback registered here. | |
| 42 int RegisterCallback(const Extension* extension, | |
| 43 content::WebIntentsDispatcher* dispatcher, | |
| 44 content::WebContents* source); | |
| 45 | |
| 46 // Retrieves the callback for the given identifier, for a response from the | |
| 47 // specified extension. This will clear the callback. If there is no callback | |
| 48 // registered under this identifier, then this will return NULL. | |
| 49 content::WebIntentsDispatcher* RetrieveCallback(const Extension* extension, | |
| 50 int intent_id); | |
| 51 | |
| 52 private: | |
| 53 typedef std::map<std::string, content::WebIntentsDispatcher*> CallbackMap; | |
|
benwells
2012/08/13 08:27:29
Is there any chance of us holding onto the dispatc
thorogood
2012/08/14 02:59:08
So: I've done a bit of checking. What I've implici
| |
| 54 | |
| 55 class Factory : public ProfileKeyedServiceFactory { | |
| 56 public: | |
| 57 static WebIntentCallbacks* GetForProfile(Profile* profile); | |
| 58 | |
| 59 static Factory* GetInstance(); | |
| 60 private: | |
| 61 friend struct DefaultSingletonTraits<Factory>; | |
| 62 | |
| 63 Factory(); | |
| 64 virtual ~Factory(); | |
| 65 | |
| 66 // ProfileKeyedServiceFactory | |
| 67 virtual ProfileKeyedService* BuildServiceInstanceFor( | |
| 68 Profile* profile) const OVERRIDE; | |
| 69 }; | |
| 70 | |
| 71 class SourceObserver; | |
| 72 | |
| 73 // Used as an incrementing ID for callback keys. | |
| 74 int last_id_; | |
| 75 | |
| 76 // Stores all pending callbacks sent to platform apps. | |
| 77 CallbackMap pending_; | |
| 78 }; | |
| 79 | |
| 80 } // namespace extensions | |
| 81 | |
| 82 #endif // CHROME_BROWSER_EXTENSIONS_WEB_INTENT_CALLBACKS_H_ | |
| OLD | NEW |