| OLD | NEW |
| 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/public/common/content_switches.h" | 13 #include "content/public/common/content_switches.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() { |
| (...skipping 23 matching lines...) Expand all Loading... |
| 47 | 47 |
| 48 SendIntent(); | 48 SendIntent(); |
| 49 } | 49 } |
| 50 | 50 |
| 51 void IntentInjector::RenderViewCreated(RenderViewHost* host) { | 51 void IntentInjector::RenderViewCreated(RenderViewHost* host) { |
| 52 SendIntent(); | 52 SendIntent(); |
| 53 } | 53 } |
| 54 | 54 |
| 55 void IntentInjector::DidNavigateMainFrame( | 55 void IntentInjector::DidNavigateMainFrame( |
| 56 const content::LoadCommittedDetails& details, | 56 const content::LoadCommittedDetails& details, |
| 57 const ViewHostMsg_FrameNavigate_Params& params) { | 57 const content::FrameNavigateParams& params) { |
| 58 SendIntent(); | 58 SendIntent(); |
| 59 } | 59 } |
| 60 | 60 |
| 61 // TODO(gbillock): The "correct" thing here is for this to be a | 61 // TODO(gbillock): The "correct" thing here is for this to be a |
| 62 // RenderViewHostObserver, and do this on RenderViewHostInitialized. There's no | 62 // RenderViewHostObserver, and do this on RenderViewHostInitialized. There's no |
| 63 // good hooks for attaching the intent to such an object, though. All RVHOs get | 63 // good hooks for attaching the intent to such an object, though. All RVHOs get |
| 64 // made deep inside tab contents initialization. Idea: propagate out | 64 // made deep inside tab contents initialization. Idea: propagate out |
| 65 // RenderViewHostInitialized to a TabContentsObserver latch? That still looks | 65 // RenderViewHostInitialized to a TabContentsObserver latch? That still looks |
| 66 // like it might be racy, though. | 66 // like it might be racy, though. |
| 67 void IntentInjector::SendIntent() { | 67 void IntentInjector::SendIntent() { |
| (...skipping 30 matching lines...) Expand all Loading... |
| 98 | 98 |
| 99 if (source_tab_.get() != NULL) { | 99 if (source_tab_.get() != NULL) { |
| 100 // Swap before use since sending this message may cause | 100 // Swap before use since sending this message may cause |
| 101 // TabContentsDestroyed to be called. | 101 // TabContentsDestroyed to be called. |
| 102 scoped_ptr<IPC::Message::Sender> sender; | 102 scoped_ptr<IPC::Message::Sender> sender; |
| 103 sender.swap(source_tab_); | 103 sender.swap(source_tab_); |
| 104 sender->Send(new IntentsMsg_WebIntentReply( | 104 sender->Send(new IntentsMsg_WebIntentReply( |
| 105 0, reply_type, data, intent_id)); | 105 0, reply_type, data, intent_id)); |
| 106 } | 106 } |
| 107 } | 107 } |
| OLD | NEW |