OLD | NEW |
1 // Copyright (c) 2011 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 #include "content/browser/intents/intent_injector.h" | 5 #include "content/browser/intents/intent_injector.h" |
6 | 6 |
7 #include "base/bind.h" | 7 #include "base/bind.h" |
8 #include "base/command_line.h" | 8 #include "base/command_line.h" |
9 #include "base/logging.h" | 9 #include "base/logging.h" |
10 #include "base/string16.h" | 10 #include "base/string16.h" |
11 #include "content/browser/renderer_host/render_view_host.h" | 11 #include "content/browser/renderer_host/render_view_host.h" |
(...skipping 37 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
49 source_intent_.reset(new webkit_glue::WebIntentData(intent)); | 49 source_intent_.reset(new webkit_glue::WebIntentData(intent)); |
50 } | 50 } |
51 | 51 |
52 void IntentInjector::OnSendReturnMessage( | 52 void IntentInjector::OnSendReturnMessage( |
53 webkit_glue::WebIntentReplyType reply_type) { | 53 webkit_glue::WebIntentReplyType reply_type) { |
54 intents_dispatcher_ = NULL; | 54 intents_dispatcher_ = NULL; |
55 } | 55 } |
56 | 56 |
57 void IntentInjector::RenderViewCreated(RenderViewHost* render_view_host) { | 57 void IntentInjector::RenderViewCreated(RenderViewHost* render_view_host) { |
58 if (source_intent_.get() == NULL || | 58 if (source_intent_.get() == NULL || |
59 !CommandLine::ForCurrentProcess()->HasSwitch( | 59 CommandLine::ForCurrentProcess()->HasSwitch( |
60 switches::kEnableWebIntents) || | 60 switches::kDisableWebIntents) || |
61 web_contents()->GetRenderViewHost() == NULL) { | 61 web_contents()->GetRenderViewHost() == NULL) { |
62 return; | 62 return; |
63 } | 63 } |
64 | 64 |
65 render_view_host->Send(new IntentsMsg_SetWebIntentData( | 65 render_view_host->Send(new IntentsMsg_SetWebIntentData( |
66 render_view_host->routing_id(), *(source_intent_.get()))); | 66 render_view_host->routing_id(), *(source_intent_.get()))); |
67 } | 67 } |
68 | 68 |
69 bool IntentInjector::OnMessageReceived(const IPC::Message& message) { | 69 bool IntentInjector::OnMessageReceived(const IPC::Message& message) { |
70 bool handled = true; | 70 bool handled = true; |
71 IPC_BEGIN_MESSAGE_MAP(IntentInjector, message) | 71 IPC_BEGIN_MESSAGE_MAP(IntentInjector, message) |
72 IPC_MESSAGE_HANDLER(IntentsHostMsg_WebIntentReply, OnReply); | 72 IPC_MESSAGE_HANDLER(IntentsHostMsg_WebIntentReply, OnReply); |
73 IPC_MESSAGE_UNHANDLED(handled = false) | 73 IPC_MESSAGE_UNHANDLED(handled = false) |
74 IPC_END_MESSAGE_MAP() | 74 IPC_END_MESSAGE_MAP() |
75 return handled; | 75 return handled; |
76 } | 76 } |
77 | 77 |
78 void IntentInjector::OnReply(webkit_glue::WebIntentReplyType reply_type, | 78 void IntentInjector::OnReply(webkit_glue::WebIntentReplyType reply_type, |
79 const string16& data) { | 79 const string16& data) { |
80 if (!CommandLine::ForCurrentProcess()->HasSwitch(switches::kEnableWebIntents)) | 80 if (CommandLine::ForCurrentProcess()->HasSwitch(switches::kDisableWebIntents)) |
81 NOTREACHED(); | 81 NOTREACHED(); |
82 | 82 |
83 if (intents_dispatcher_) { | 83 if (intents_dispatcher_) { |
84 // Ensure we only call SendReplyMessage once. | 84 // Ensure we only call SendReplyMessage once. |
85 content::WebIntentsDispatcher* intents_dispatcher = intents_dispatcher_; | 85 content::WebIntentsDispatcher* intents_dispatcher = intents_dispatcher_; |
86 intents_dispatcher_ = NULL; | 86 intents_dispatcher_ = NULL; |
87 intents_dispatcher->SendReplyMessage(reply_type, data); | 87 intents_dispatcher->SendReplyMessage(reply_type, data); |
88 } | 88 } |
89 } | 89 } |
OLD | NEW |