Chromium Code Reviews| OLD | NEW |
|---|---|
| 1 // Copyright (c) 2012 The Chromium Authors. All rights reserved. | 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 | 2 // Use of this source code is governed by a BSD-style license that can be |
| 3 // found in the LICENSE file. | 3 // found in the LICENSE file. |
| 4 | 4 |
| 5 #ifndef CONTENT_BROWSER_INTENTS_INTENT_INJECTOR_H_ | 5 #ifndef CONTENT_BROWSER_INTENTS_INTENT_INJECTOR_H_ |
| 6 #define CONTENT_BROWSER_INTENTS_INTENT_INJECTOR_H_ | 6 #define CONTENT_BROWSER_INTENTS_INTENT_INJECTOR_H_ |
| 7 #pragma once | 7 #pragma once |
| 8 | 8 |
| 9 #include "base/basictypes.h" | 9 #include "base/basictypes.h" |
| 10 #include "base/gtest_prod_util.h" | |
| 10 #include "base/memory/scoped_ptr.h" | 11 #include "base/memory/scoped_ptr.h" |
| 12 #include "base/memory/weak_ptr.h" | |
| 11 #include "base/string16.h" | 13 #include "base/string16.h" |
| 12 #include "content/public/browser/web_contents_observer.h" | 14 #include "content/public/browser/web_contents_observer.h" |
| 13 #include "content/common/content_export.h" | 15 #include "content/common/content_export.h" |
| 14 #include "googleurl/src/gurl.h" | 16 #include "googleurl/src/gurl.h" |
| 15 #include "webkit/glue/web_intent_reply_data.h" | 17 #include "webkit/glue/web_intent_reply_data.h" |
| 16 | 18 |
| 17 namespace content { | 19 namespace content { |
| 18 class WebIntentsDispatcher; | 20 class WebIntentsDispatcher; |
| 19 } | 21 } |
| 20 | 22 |
| (...skipping 27 matching lines...) Expand all Loading... | |
| 48 void SourceWebContentsDestroyed(content::WebContents* contents); | 50 void SourceWebContentsDestroyed(content::WebContents* contents); |
| 49 | 51 |
| 50 // Sets the intent data to be injected. Call after the user has selected a | 52 // Sets the intent data to be injected. Call after the user has selected a |
| 51 // service to pass the intent data to that service. |intents_dispatcher| is a | 53 // service to pass the intent data to that service. |intents_dispatcher| is a |
| 52 // sender to use to communicate to the source contents. The caller must | 54 // sender to use to communicate to the source contents. The caller must |
| 53 // ensure that SourceWebContentsDestroyed is called when this object becomes | 55 // ensure that SourceWebContentsDestroyed is called when this object becomes |
| 54 // unusable. |intent| is the intent data from the source. | 56 // unusable. |intent| is the intent data from the source. |
| 55 void SetIntent(content::WebIntentsDispatcher* intents_dispatcher, | 57 void SetIntent(content::WebIntentsDispatcher* intents_dispatcher, |
| 56 const webkit_glue::WebIntentData& intent); | 58 const webkit_glue::WebIntentData& intent); |
| 57 | 59 |
| 60 // Abandon this injector. Used when re-delivering an intent to a different | |
| 61 // service provider, i.e. when abandoning an inline disposition and picking | |
| 62 // a new provider. | |
|
Greg Billock
2012/04/25 14:26:52
Document that this self-deletes.
groby-ooo-7-16
2012/04/25 16:40:10
Done.
| |
| 63 void Abandon(); | |
| 64 | |
| 58 private: | 65 private: |
| 66 FRIEND_TEST_ALL_PREFIXES(IntentInjectorTest, AbandonDeletes); | |
| 67 | |
| 59 // Handles receiving a reply from the intent delivery page. | 68 // Handles receiving a reply from the intent delivery page. |
| 60 void OnReply(webkit_glue::WebIntentReplyType reply_type, | 69 void OnReply(webkit_glue::WebIntentReplyType reply_type, |
| 61 const string16& data); | 70 const string16& data); |
| 62 | 71 |
| 63 // Gets notification that someone else has replied to the intent call. | 72 // Gets notification that someone else has replied to the intent call. |
| 64 void OnSendReturnMessage(webkit_glue::WebIntentReplyType reply_type); | 73 void OnSendReturnMessage(webkit_glue::WebIntentReplyType reply_type); |
| 65 | 74 |
| 66 // Source intent data provided by caller. | 75 // Source intent data provided by caller. |
| 67 scoped_ptr<webkit_glue::WebIntentData> source_intent_; | 76 scoped_ptr<webkit_glue::WebIntentData> source_intent_; |
| 68 | 77 |
| 69 // Weak pointer to the message forwarder to the contents invoking the intent. | 78 // Weak pointer to the message forwarder to the contents invoking the intent. |
| 70 content::WebIntentsDispatcher* intents_dispatcher_; | 79 content::WebIntentsDispatcher* intents_dispatcher_; |
| 71 | 80 |
| 72 // Remember the initial delivery url for origin restriction. | 81 // Remember the initial delivery url for origin restriction. |
| 73 GURL initial_url_; | 82 GURL initial_url_; |
| 74 | 83 |
| 84 // The injector is used as a callback target by the intent dispatcher, | |
| 85 // but is not guaranteed to outlive it. Use weak pointers to handle lifetime | |
|
Greg Billock
2012/04/25 14:26:52
"The injector may be Abandon()ed and deleted befor
groby-ooo-7-16
2012/04/25 16:40:10
Done.
| |
| 86 // issues. | |
| 87 base::WeakPtrFactory<IntentInjector> weak_factory_; | |
|
Greg Billock
2012/04/25 14:26:52
weak_ptr_factory_
groby-ooo-7-16
2012/04/25 16:40:10
weak_factory_ seems to be the preferred naming, ac
| |
| 88 | |
| 75 DISALLOW_COPY_AND_ASSIGN(IntentInjector); | 89 DISALLOW_COPY_AND_ASSIGN(IntentInjector); |
| 76 }; | 90 }; |
| 77 | 91 |
| 78 #endif // CONTENT_BROWSER_INTENTS_INTENT_INJECTOR_H_ | 92 #endif // CONTENT_BROWSER_INTENTS_INTENT_INJECTOR_H_ |
| OLD | NEW |