OLD | NEW |
1 // Copyright (c) 2009 The Chromium Authors. All rights reserved. | 1 // Copyright (c) 2009 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/automation/extension_port_container.h" | 5 #include "chrome/browser/automation/extension_port_container.h" |
6 | 6 |
7 #include "base/logging.h" | 7 #include "base/logging.h" |
8 #include "base/json_reader.h" | 8 #include "base/json_reader.h" |
9 #include "base/json_writer.h" | 9 #include "base/json_writer.h" |
10 #include "base/values.h" | 10 #include "base/values.h" |
11 #include "chrome/common/render_messages.h" | 11 #include "chrome/common/render_messages.h" |
12 #include "chrome/browser/automation/automation_provider.h" | 12 #include "chrome/browser/automation/automation_provider.h" |
13 #include "chrome/browser/automation/extension_automation_constants.h" | 13 #include "chrome/browser/automation/extension_automation_constants.h" |
14 #include "chrome/browser/chrome_thread.h" | 14 #include "chrome/browser/chrome_thread.h" |
15 #include "chrome/browser/extensions/extension_message_service.h" | 15 #include "chrome/browser/extensions/extension_message_service.h" |
16 #include "chrome/browser/profile.h" | 16 #include "chrome/browser/profile.h" |
17 #include "chrome/browser/renderer_host/render_view_host.h" | 17 #include "chrome/browser/renderer_host/render_view_host.h" |
18 #include "chrome/test/automation/automation_messages.h" | 18 #include "chrome/test/automation/automation_messages.h" |
19 | 19 |
20 // TODO(siggi): Find a more structured way to read and write JSON messages. | 20 // TODO(siggi): Find a more structured way to read and write JSON messages. |
21 | 21 |
22 namespace ext = extension_automation_constants; | 22 namespace ext = extension_automation_constants; |
23 | 23 |
24 ExtensionPortContainer::ExtensionPortContainer(AutomationProvider* automation, | 24 ExtensionPortContainer::ExtensionPortContainer(AutomationProvider* automation, |
25 int tab_handle) : | 25 int tab_handle) : |
26 automation_(automation), service_(NULL), port_id_(-1), | 26 automation_(automation), service_(NULL), port_id_(-1), |
27 tab_handle_(tab_handle) { | 27 tab_handle_(tab_handle) { |
28 URLRequestContext* context = automation_->profile()->GetRequestContext(); | 28 service_ = automation_->profile()->GetExtensionMessageService();; |
29 service_ = ExtensionMessageService::GetInstance(context); | |
30 DCHECK(service_); | 29 DCHECK(service_); |
31 } | 30 } |
32 | 31 |
33 ExtensionPortContainer::~ExtensionPortContainer() { | 32 ExtensionPortContainer::~ExtensionPortContainer() { |
34 DCHECK_EQ(MessageLoop::current()->type(), MessageLoop::TYPE_UI); | 33 DCHECK_EQ(MessageLoop::current()->type(), MessageLoop::TYPE_UI); |
35 | 34 |
36 if (port_id_ != -1) | 35 if (port_id_ != -1) |
37 service_->CloseChannel(port_id_); | 36 service_->CloseChannel(port_id_); |
38 } | 37 } |
39 | 38 |
(...skipping 161 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
201 DCHECK(port); | 200 DCHECK(port); |
202 if (port) | 201 if (port) |
203 port->PostMessageFromExternalPort(data); | 202 port->PostMessageFromExternalPort(data); |
204 } else { | 203 } else { |
205 // We don't expect other messages here. | 204 // We don't expect other messages here. |
206 NOTREACHED(); | 205 NOTREACHED(); |
207 } | 206 } |
208 | 207 |
209 return true; | 208 return true; |
210 } | 209 } |
OLD | NEW |