| OLD | NEW |
| 1 // Copyright (c) 2012 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 "chrome/browser/extensions/message_handler.h" | 5 #include "chrome/browser/extensions/message_handler.h" |
| 6 | 6 |
| 7 #include "base/values.h" | |
| 8 #include "chrome/browser/extensions/api/messaging/message_service.h" | 7 #include "chrome/browser/extensions/api/messaging/message_service.h" |
| 9 #include "chrome/browser/extensions/extension_system.h" | 8 #include "chrome/browser/extensions/extension_system.h" |
| 10 #include "chrome/browser/profiles/profile.h" | 9 #include "chrome/browser/profiles/profile.h" |
| 11 #include "chrome/common/extensions/extension_messages.h" | 10 #include "chrome/common/extensions/extension_messages.h" |
| 12 #include "content/public/browser/render_process_host.h" | 11 #include "content/public/browser/render_process_host.h" |
| 13 #include "content/public/browser/render_view_host.h" | 12 #include "content/public/browser/render_view_host.h" |
| 14 #include "content/public/browser/web_contents.h" | 13 #include "content/public/browser/web_contents.h" |
| 15 #include "extensions/browser/view_type_utils.h" | 14 #include "extensions/browser/view_type_utils.h" |
| 16 | 15 |
| 17 using content::WebContents; | 16 using content::WebContents; |
| (...skipping 19 matching lines...) Expand all Loading... |
| 37 } | 36 } |
| 38 | 37 |
| 39 void MessageHandler::RenderViewHostInitialized() { | 38 void MessageHandler::RenderViewHostInitialized() { |
| 40 WebContents* web_contents = | 39 WebContents* web_contents = |
| 41 WebContents::FromRenderViewHost(render_view_host()); | 40 WebContents::FromRenderViewHost(render_view_host()); |
| 42 Send(new ExtensionMsg_NotifyRenderViewType( | 41 Send(new ExtensionMsg_NotifyRenderViewType( |
| 43 routing_id(), extensions::GetViewType(web_contents))); | 42 routing_id(), extensions::GetViewType(web_contents))); |
| 44 } | 43 } |
| 45 | 44 |
| 46 void MessageHandler::OnPostMessage(int port_id, | 45 void MessageHandler::OnPostMessage(int port_id, |
| 47 const base::ListValue& message) { | 46 const std::string& message) { |
| 48 Profile* profile = Profile::FromBrowserContext( | 47 Profile* profile = Profile::FromBrowserContext( |
| 49 render_view_host()->GetProcess()->GetBrowserContext()); | 48 render_view_host()->GetProcess()->GetBrowserContext()); |
| 50 MessageService* message_service = MessageService::Get(profile); | 49 MessageService* message_service = MessageService::Get(profile); |
| 51 if (message_service) { | 50 if (message_service) { |
| 52 message_service->PostMessage(port_id, make_scoped_ptr(message.DeepCopy())); | 51 message_service->PostMessage(port_id, message); |
| 53 } | 52 } |
| 54 } | 53 } |
| 55 | 54 |
| 56 } // namespace extensions | 55 } // namespace extensions |
| OLD | NEW |