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

Unified Diff: chrome/browser/ui/intents/web_intent_picker_controller.cc

Issue 10805094: Mark down in web intents picker controller when it is part of a TabContents that is hosting a web i… (Closed) Base URL: svn://svn.chromium.org/chrome/trunk/src
Patch Set: Change assert Created 8 years, 5 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/ui/intents/web_intent_picker_controller.cc
diff --git a/chrome/browser/ui/intents/web_intent_picker_controller.cc b/chrome/browser/ui/intents/web_intent_picker_controller.cc
index 64463a8a23073a8232211952567fe8ac2810c387..d832d0c15d2986e48266bed95dd28ea0d752ece3 100644
--- a/chrome/browser/ui/intents/web_intent_picker_controller.cc
+++ b/chrome/browser/ui/intents/web_intent_picker_controller.cc
@@ -35,6 +35,7 @@
#include "content/public/browser/navigation_controller.h"
#include "content/public/browser/notification_source.h"
#include "content/public/browser/web_contents.h"
+#include "content/public/browser/web_contents_observer.h"
#include "content/public/browser/web_intents_dispatcher.h"
#include "grit/generated_resources.h"
#include "ipc/ipc_message.h"
@@ -137,6 +138,25 @@ void URLFetcherTrampoline::OnURLFetchComplete(
delete this;
}
+class SourceWindowObserver : content::WebContentsObserver {
+ public:
+ SourceWindowObserver(content::WebContents* web_contents,
+ base::WeakPtr<WebIntentPickerController> controller)
+ : content::WebContentsObserver(web_contents),
+ controller_(controller) {}
+ virtual ~SourceWindowObserver() {}
+
+ // Implement WebContentsObserver
+ virtual void WebContentsDestroyed(content::WebContents* web_contents) {
+ if (controller_)
+ controller_->SourceWebContentsDestroyed(web_contents);
+ delete this;
+ }
+
+ private:
+ base::WeakPtr<WebIntentPickerController> controller_;
+};
+
} // namespace
WebIntentPickerController::WebIntentPickerController(
@@ -147,6 +167,8 @@ WebIntentPickerController::WebIntentPickerController(
pending_async_count_(0),
pending_registry_calls_count_(0),
picker_shown_(false),
+ window_disposition_source_(NULL),
+ source_intents_dispatcher_(NULL),
intents_dispatcher_(NULL),
service_tab_(NULL),
weak_ptr_factory_(this) {
@@ -247,7 +269,7 @@ void WebIntentPickerController::ShowDialog(const string16& action,
action, type,
base::Bind(&WebIntentPickerController::OnCWSIntentServicesAvailable,
weak_ptr_factory_.GetWeakPtr()));
- }
+}
void WebIntentPickerController::Observe(
int type,
@@ -291,6 +313,11 @@ void WebIntentPickerController::OnServiceChosen(const GURL& url,
tab_contents_->profile(), url),
MSG_ROUTING_NONE, NULL, NULL);
+ // Let the controller for the target TabContents know that it is hosting a
+ // web intents service.
+ contents->web_intent_picker_controller()->SetWindowDispositionSource(
+ tab_contents_->web_contents(), intents_dispatcher_);
+
intents_dispatcher_->DispatchIntent(contents->web_contents());
service_tab_ = contents->web_contents();
@@ -681,6 +708,39 @@ void WebIntentPickerController::OnExtensionIconUnavailable(
AsyncOperationFinished();
}
+void WebIntentPickerController::SetWindowDispositionSource(
+ content::WebContents* source,
+ content::WebIntentsDispatcher* dispatcher) {
+ window_disposition_source_ = source;
+ if (window_disposition_source_) {
+ // This object is self-deleting when the source WebContents is destroyed.
+ new SourceWindowObserver(window_disposition_source_,
+ weak_ptr_factory_.GetWeakPtr());
+ }
+
+ source_intents_dispatcher_ = dispatcher;
+ if (dispatcher) {
+ dispatcher->RegisterReplyNotification(
+ base::Bind(&WebIntentPickerController::SourceDispatcherReplied,
+ weak_ptr_factory_.GetWeakPtr()));
+ }
+}
+
+void WebIntentPickerController::SourceWebContentsDestroyed(
+ content::WebContents* source) {
+ window_disposition_source_ = NULL;
+}
+
+void WebIntentPickerController::SourceDispatcherReplied(
+ webkit_glue::WebIntentReplyType reply_type) {
+ source_intents_dispatcher_ = NULL;
+}
+
+bool WebIntentPickerController::ShowLocationBarPickerTool() {
+ return window_disposition_source_ != NULL ||
groby-ooo-7-16 2012/07/30 20:10:05 nit: without != NULL
Greg Billock 2012/07/30 20:23:57 Done.
+ source_intents_dispatcher_ != NULL;
+}
+
void WebIntentPickerController::OnExtensionInstallServiceAvailable(
const std::vector<webkit_glue::WebIntentServiceData>& services) {
DCHECK(services.size() > 0);

Powered by Google App Engine
This is Rietveld 408576698