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

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

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 unified diff | Download patch
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 #include "base/stringprintf.h"
6 #include "chrome/browser/extensions/web_intent_callbacks.h"
7 #include "chrome/browser/profiles/profile_dependency_manager.h"
8 #include "content/public/browser/web_intents_dispatcher.h"
9
10 WebIntentCallbacks::WebIntentCallbacks() {}
11
12 WebIntentCallbacks::~WebIntentCallbacks() {}
13
14 // static
15 WebIntentCallbacks* WebIntentCallbacks::Get(Profile* profile) {
16 return Factory::GetForProfile(profile);
17 }
18
19 std::string WebIntentCallbacks::RegisterCallback(
20 content::WebIntentsDispatcher* dispatcher) {
21 std::string key = StringPrintf("key_%d", last_id_++);
Mihai Parparita -not on Chrome 2012/08/09 04:38:33 Can keys somehow be scoped by the extension ID of
thorogood 2012/08/09 09:56:51 I've taken the first approach, and scoped the key
22
23 // TODO(thorogood): cleanup task, perhaps we can watch renderer threads.
Mihai Parparita -not on Chrome 2012/08/09 04:38:33 Can you do this cleanup when the launchData object
thorogood 2012/08/09 09:56:51 So I haven't solved this yet, but we talked about
24 pending_[key] = dispatcher;
25 return key;
26 }
27
28 content::WebIntentsDispatcher* WebIntentCallbacks::RetrieveCallback(
29 std::string key) {
30 if (key.empty() || !pending_.count(key))
31 return NULL;
32
33 content::WebIntentsDispatcher* dispatcher = pending_[key];
34 pending_.erase(key);
35 return dispatcher;
36 }
37
38 ///////////////////////////////////////////////////////////////////////////////
39 // Factory boilerplate
40
41 // static
42 WebIntentCallbacks* WebIntentCallbacks::Factory::GetForProfile(
43 Profile* profile) {
44 return static_cast<WebIntentCallbacks*>(
45 GetInstance()->GetServiceForProfile(profile, true));
46 }
47
48 WebIntentCallbacks::Factory* WebIntentCallbacks::Factory::GetInstance() {
49 return Singleton<WebIntentCallbacks::Factory>::get();
50 }
51
52 WebIntentCallbacks::Factory::Factory()
53 : ProfileKeyedServiceFactory("WebIntentCallbacks",
54 ProfileDependencyManager::GetInstance()) {
55 }
56
57 WebIntentCallbacks::Factory::~Factory() {
58 }
59
60 ProfileKeyedService* WebIntentCallbacks::Factory::BuildServiceInstanceFor(
61 Profile* profile) const {
62 return new WebIntentCallbacks();
63 }
OLDNEW

Powered by Google App Engine
This is Rietveld 408576698