Chromium Code Reviews| Index: chrome/browser/extensions/web_intent_callbacks.h |
| diff --git a/chrome/browser/extensions/web_intent_callbacks.h b/chrome/browser/extensions/web_intent_callbacks.h |
| new file mode 100644 |
| index 0000000000000000000000000000000000000000..df2ebfd7b8b65832b07656d1113b5a8ad98afa5f |
| --- /dev/null |
| +++ b/chrome/browser/extensions/web_intent_callbacks.h |
| @@ -0,0 +1,69 @@ |
| +// Copyright (c) 2012 The Chromium Authors. All rights reserved. |
| +// Use of this source code is governed by a BSD-style license that can be |
| +// found in the LICENSE file. |
| + |
| +#ifndef CHROME_BROWSER_EXTENSIONS_WEB_INTENT_CALLBACKS_H_ |
| +#define CHROME_BROWSER_EXTENSIONS_WEB_INTENT_CALLBACKS_H_ |
| + |
| +#include <set> |
| + |
| +#include "base/compiler_specific.h" |
| +#include "base/memory/singleton.h" |
| +#include "base/observer_list.h" |
| +#include "chrome/browser/profiles/profile_keyed_service.h" |
| +#include "chrome/browser/profiles/profile_keyed_service_factory.h" |
| +#include "ui/gfx/native_widget_types.h" |
| + |
| +class Profile; |
| + |
| +namespace content { |
| +class WebIntentsDispatcher; |
| +} |
| + |
| +// The WebIntentCallbacks class tracks the pending callbacks for web intents |
| +// that have been delivered to platform apps, for a particular profile. |
| +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
|
| + public: |
| + 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
|
| + |
| + WebIntentCallbacks(); |
| + virtual ~WebIntentCallbacks(); |
| + |
| + // Returns the instance for the given profile. This is a convenience wrapper |
| + // around WebIntentCallbacks::Factory::GetForProfile. |
| + static WebIntentCallbacks* Get(Profile* profile); |
| + |
| + // Registers the callback for the Web Intent we're about to dispatch to a |
| + // platform app. Returns an opaque string identifier that should later be |
| + // dispatched to RetrieveCallback in order to invoke the callback registered |
| + // here. |
| + std::string RegisterCallback(content::WebIntentsDispatcher* dispatcher); |
| + |
| + // Retrieves the callback for the given opaque string identifier. This will |
| + // clear the callback. If there is no callback registered under this |
| + // identifier, then this will return NULL. |
| + content::WebIntentsDispatcher* RetrieveCallback(std::string key); |
| + |
| + private: |
| + class Factory : public ProfileKeyedServiceFactory { |
| + public: |
| + static WebIntentCallbacks* GetForProfile(Profile* profile); |
| + |
| + static Factory* GetInstance(); |
| + private: |
| + friend struct DefaultSingletonTraits<Factory>; |
| + |
| + Factory(); |
| + virtual ~Factory(); |
| + |
| + // ProfileKeyedServiceFactory |
| + virtual ProfileKeyedService* BuildServiceInstanceFor( |
| + Profile* profile) const OVERRIDE; |
| + }; |
| + |
| + int last_id_; |
| + |
| + CallbackMap pending_; |
| +}; |
| + |
| +#endif // CHROME_BROWSER_EXTENSIONS_WEB_INTENT_CALLBACKS_H_ |