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

Unified Diff: content/browser/intents/intent_injector.h

Issue 10218009: Allow severing connection between dispatcher and injector (Closed) Base URL: http://git.chromium.org/chromium/src.git@master
Patch Set: Fix compile issue for browser_tests Created 8 years, 8 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: content/browser/intents/intent_injector.h
diff --git a/content/browser/intents/intent_injector.h b/content/browser/intents/intent_injector.h
index 30b9c7a616d41a48cf3363a52c13b7eaae4fafac..17f187efa8f88d656f0afa42ac18bde6a409dfdf 100644
--- a/content/browser/intents/intent_injector.h
+++ b/content/browser/intents/intent_injector.h
@@ -7,7 +7,9 @@
#pragma once
#include "base/basictypes.h"
+#include "base/gtest_prod_util.h"
#include "base/memory/scoped_ptr.h"
+#include "base/memory/weak_ptr.h"
#include "base/string16.h"
#include "content/public/browser/web_contents_observer.h"
#include "content/common/content_export.h"
@@ -36,7 +38,6 @@ class CONTENT_EXPORT IntentInjector : public content::WebContentsObserver {
public:
// |web_contents| must not be NULL.
explicit IntentInjector(content::WebContents* web_contents);
- virtual ~IntentInjector();
// content::WebContentsObserver implementation.
virtual void RenderViewCreated(
@@ -55,7 +56,17 @@ class CONTENT_EXPORT IntentInjector : public content::WebContentsObserver {
void SetIntent(content::WebIntentsDispatcher* intents_dispatcher,
const webkit_glue::WebIntentData& intent);
+ // Abandon this injector. Used when re-delivering an intent to a different
+ // service provider, i.e. when abandoning an inline disposition and picking
+ // a new provider. Self-deletes.
+ void Abandon();
+
private:
+ FRIEND_TEST_ALL_PREFIXES(IntentInjectorTest, AbandonDeletes);
+
+ // Private, since the class is self-deleting.
+ virtual ~IntentInjector();
+
// Handles receiving a reply from the intent delivery page.
void OnReply(webkit_glue::WebIntentReplyType reply_type,
const string16& data);
@@ -72,6 +83,10 @@ class CONTENT_EXPORT IntentInjector : public content::WebContentsObserver {
// Remember the initial delivery url for origin restriction.
GURL initial_url_;
+ // The injector may be Abandon()ed and deleted before the dispatcher. Use weak
+ // pointers to ensure the notification callback remains valid.
+ base::WeakPtrFactory<IntentInjector> weak_factory_;
+
DISALLOW_COPY_AND_ASSIGN(IntentInjector);
};
« no previous file with comments | « chrome/browser/ui/intents/web_intent_picker_controller_browsertest.cc ('k') | content/browser/intents/intent_injector.cc » ('j') | no next file with comments »

Powered by Google App Engine
This is Rietveld 408576698