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

Side by Side Diff: content/browser/intents/intent_injector.cc

Issue 8508019: Add a method to the controller to close the picker/service tab when a return value is passed. (Closed) Base URL: svn://svn.chromium.org/chrome/trunk/src
Patch Set: Change delegate comment to notification sense of OnClosing. Created 9 years, 1 month 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 | Annotate | Revision Log
« no previous file with comments | « content/browser/intents/intent_injector.h ('k') | no next file » | no next file with comments »
Toggle Intra-line Diffs ('i') | Expand Comments ('e') | Collapse Comments ('c') | Show Comments Hide Comments ('s')
OLDNEW
1 // Copyright (c) 2011 The Chromium Authors. All rights reserved. 1 // Copyright (c) 2011 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 #include "content/browser/intents/intent_injector.h" 5 #include "content/browser/intents/intent_injector.h"
6 6
7 #include "base/command_line.h" 7 #include "base/command_line.h"
8 #include "base/logging.h" 8 #include "base/logging.h"
9 #include "base/string16.h" 9 #include "base/string16.h"
10 #include "content/browser/renderer_host/render_view_host.h" 10 #include "content/browser/renderer_host/render_view_host.h"
11 #include "content/browser/tab_contents/tab_contents.h" 11 #include "content/browser/tab_contents/tab_contents.h"
12 #include "content/public/common/content_switches.h" 12 #include "content/public/common/content_switches.h"
13 #include "ipc/ipc_message_macros.h" 13 #include "ipc/ipc_message_macros.h"
14 #include "webkit/glue/web_intent_data.h" 14 #include "webkit/glue/web_intent_data.h"
15 #include "webkit/glue/web_intent_reply_data.h" 15 #include "webkit/glue/web_intent_reply_data.h"
16 16
17 IntentInjector::IntentInjector(TabContents* tab_contents) 17 IntentInjector::IntentInjector(TabContents* tab_contents)
18 : TabContentsObserver(tab_contents), 18 : TabContentsObserver(tab_contents),
19 intent_id_(0) { 19 intent_id_(0) {
20 DCHECK(tab_contents); 20 DCHECK(tab_contents);
21 } 21 }
22 22
23 IntentInjector::~IntentInjector() { 23 IntentInjector::~IntentInjector() {
24 } 24 }
25 25
26 void IntentInjector::TabContentsDestroyed(TabContents* tab) { 26 void IntentInjector::TabContentsDestroyed(TabContents* tab) {
27 if (source_tab_.get() != NULL) { 27 if (source_tab_.get() != NULL) {
28 source_tab_->Send(new IntentsMsg_WebIntentReply( 28 scoped_ptr<IPC::Message::Sender> sender;
29 sender.swap(source_tab_);
30 sender->Send(new IntentsMsg_WebIntentReply(
29 0, webkit_glue::WEB_INTENT_SERVICE_TAB_CLOSED, string16(), intent_id_)); 31 0, webkit_glue::WEB_INTENT_SERVICE_TAB_CLOSED, string16(), intent_id_));
30 source_tab_.reset(NULL);
31 } 32 }
32 33
33 delete this; 34 delete this;
34 } 35 }
35 36
36 void IntentInjector::SourceTabContentsDestroyed(TabContents* tab) { 37 void IntentInjector::SourceTabContentsDestroyed(TabContents* tab) {
37 source_tab_.reset(NULL); 38 source_tab_.reset(NULL);
38 } 39 }
39 40
40 void IntentInjector::SetIntent(IPC::Message::Sender* source_tab, 41 void IntentInjector::SetIntent(IPC::Message::Sender* source_tab,
(...skipping 48 matching lines...) Expand 10 before | Expand all | Expand 10 after
89 } 90 }
90 91
91 void IntentInjector::OnReply(const IPC::Message& message, 92 void IntentInjector::OnReply(const IPC::Message& message,
92 webkit_glue::WebIntentReplyType reply_type, 93 webkit_glue::WebIntentReplyType reply_type,
93 const string16& data, 94 const string16& data,
94 int intent_id) { 95 int intent_id) {
95 if (!CommandLine::ForCurrentProcess()->HasSwitch(switches::kEnableWebIntents)) 96 if (!CommandLine::ForCurrentProcess()->HasSwitch(switches::kEnableWebIntents))
96 NOTREACHED(); 97 NOTREACHED();
97 98
98 if (source_tab_.get() != NULL) { 99 if (source_tab_.get() != NULL) {
99 source_tab_->Send(new IntentsMsg_WebIntentReply( 100 // Swap before use since sending this message may cause
101 // TabContentsDestroyed to be called.
102 scoped_ptr<IPC::Message::Sender> sender;
103 sender.swap(source_tab_);
104 sender->Send(new IntentsMsg_WebIntentReply(
100 0, reply_type, data, intent_id)); 105 0, reply_type, data, intent_id));
101 source_tab_.reset(NULL);
102 } 106 }
103 } 107 }
OLDNEW
« no previous file with comments | « content/browser/intents/intent_injector.h ('k') | no next file » | no next file with comments »

Powered by Google App Engine
This is Rietveld 408576698