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

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: 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 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..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_

Powered by Google App Engine
This is Rietveld 408576698