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

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

Issue 8666013: Add a public content/ interface for intents. Use it. (Closed) Base URL: svn://svn.chromium.org/chrome/trunk/src
Patch Set: For try servers. Created 9 years 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') | content/browser/intents/intents_host_impl.h » ('j') | 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/common/intents_messages.h" 12 #include "content/common/intents_messages.h"
13 #include "content/public/common/content_switches.h" 13 #include "content/public/common/content_switches.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 source_tab_(NULL),
19 intent_id_(0) { 20 intent_id_(0) {
20 DCHECK(tab_contents); 21 DCHECK(tab_contents);
21 } 22 }
22 23
23 IntentInjector::~IntentInjector() { 24 IntentInjector::~IntentInjector() {
24 } 25 }
25 26
26 void IntentInjector::TabContentsDestroyed(TabContents* tab) { 27 void IntentInjector::TabContentsDestroyed(TabContents* tab) {
27 if (source_tab_.get() != NULL) { 28 if (source_tab_) {
28 scoped_ptr<IPC::Message::Sender> sender; 29 source_tab_->Send(new IntentsMsg_WebIntentReply(
29 sender.swap(source_tab_);
30 sender->Send(new IntentsMsg_WebIntentReply(
31 0, webkit_glue::WEB_INTENT_SERVICE_TAB_CLOSED, string16(), intent_id_)); 30 0, webkit_glue::WEB_INTENT_SERVICE_TAB_CLOSED, string16(), intent_id_));
32 } 31 }
33 32
34 delete this; 33 delete this;
35 } 34 }
36 35
37 void IntentInjector::SourceTabContentsDestroyed(TabContents* tab) { 36 void IntentInjector::SourceTabContentsDestroyed(TabContents* tab) {
38 source_tab_.reset(NULL); 37 source_tab_ = NULL;
39 } 38 }
40 39
41 void IntentInjector::SetIntent(IPC::Message::Sender* source_tab, 40 void IntentInjector::SetIntent(IPC::Message::Sender* source_tab,
42 const webkit_glue::WebIntentData& intent, 41 const webkit_glue::WebIntentData& intent,
43 int intent_id) { 42 int intent_id) {
44 source_tab_.reset(source_tab); 43 source_tab_ = source_tab;
45 source_intent_.reset(new webkit_glue::WebIntentData(intent)); 44 source_intent_.reset(new webkit_glue::WebIntentData(intent));
46 intent_id_ = intent_id; 45 intent_id_ = intent_id;
47 46
48 SendIntent(); 47 SendIntent();
49 } 48 }
50 49
51 void IntentInjector::RenderViewCreated(RenderViewHost* host) { 50 void IntentInjector::RenderViewCreated(RenderViewHost* host) {
52 SendIntent(); 51 SendIntent();
53 } 52 }
54 53
(...skipping 34 matching lines...) Expand 10 before | Expand all | Expand 10 after
89 return handled; 88 return handled;
90 } 89 }
91 90
92 void IntentInjector::OnReply(const IPC::Message& message, 91 void IntentInjector::OnReply(const IPC::Message& message,
93 webkit_glue::WebIntentReplyType reply_type, 92 webkit_glue::WebIntentReplyType reply_type,
94 const string16& data, 93 const string16& data,
95 int intent_id) { 94 int intent_id) {
96 if (!CommandLine::ForCurrentProcess()->HasSwitch(switches::kEnableWebIntents)) 95 if (!CommandLine::ForCurrentProcess()->HasSwitch(switches::kEnableWebIntents))
97 NOTREACHED(); 96 NOTREACHED();
98 97
99 if (source_tab_.get() != NULL) { 98 if (source_tab_) {
100 // Swap before use since sending this message may cause 99 source_tab_->Send(new IntentsMsg_WebIntentReply(
101 // TabContentsDestroyed to be called.
102 scoped_ptr<IPC::Message::Sender> sender;
103 sender.swap(source_tab_);
104 sender->Send(new IntentsMsg_WebIntentReply(
105 0, reply_type, data, intent_id)); 100 0, reply_type, data, intent_id));
106 } 101 }
107 } 102 }
OLDNEW
« no previous file with comments | « content/browser/intents/intent_injector.h ('k') | content/browser/intents/intents_host_impl.h » ('j') | no next file with comments »

Powered by Google App Engine
This is Rietveld 408576698