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

Unified 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: Hooked up observing of source WebContents 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 side-by-side diff with in-line comments
Download patch
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..601fbdf12e37447f7928bcc784c4fab9725c0a10
--- /dev/null
+++ b/chrome/browser/extensions/web_intent_callbacks.h
@@ -0,0 +1,82 @@
+// 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"
benwells 2012/08/13 08:27:29 Are all these includes needed?
thorogood 2012/08/14 02:59:08 Done.
+#include "webkit/glue/web_intent_reply_data.h"
+
+class Profile;
+
+namespace content {
+class WebContents;
+class WebIntentsDispatcher;
+}
+
+namespace extensions {
+class Extension;
+
+// 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 {
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?
+ public:
+ 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 the
+ // given extension. Returns an identifier that should later be dispatched to
+ // RetrieveCallback in order to invoke the callback registered here.
+ int RegisterCallback(const Extension* extension,
+ content::WebIntentsDispatcher* dispatcher,
+ content::WebContents* source);
+
+ // Retrieves the callback for the given identifier, for a response from the
+ // specified extension. This will clear the callback. If there is no callback
+ // registered under this identifier, then this will return NULL.
+ content::WebIntentsDispatcher* RetrieveCallback(const Extension* extension,
+ int intent_id);
+
+ private:
+ 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
+
+ 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;
+ };
+
+ class SourceObserver;
+
+ // Used as an incrementing ID for callback keys.
+ int last_id_;
+
+ // Stores all pending callbacks sent to platform apps.
+ CallbackMap pending_;
+};
+
+} // namespace extensions
+
+#endif // CHROME_BROWSER_EXTENSIONS_WEB_INTENT_CALLBACKS_H_

Powered by Google App Engine
This is Rietveld 408576698