| 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/renderer_host/java/java_bridge_dispatcher_host_manager
.h" | 5 #include "content/browser/renderer_host/java/java_bridge_dispatcher_host_manager
.h" |
| 6 | 6 |
| 7 #include "base/utf_string_conversions.h" | 7 #include "base/utf_string_conversions.h" |
| 8 #include "content/browser/renderer_host/java/java_bridge_dispatcher_host.h" | 8 #include "content/browser/renderer_host/java/java_bridge_dispatcher_host.h" |
| 9 #include "content/browser/tab_contents/tab_contents.h" | |
| 10 #include "third_party/WebKit/Source/WebKit/chromium/public/WebBindings.h" | 9 #include "third_party/WebKit/Source/WebKit/chromium/public/WebBindings.h" |
| 11 | 10 |
| 12 JavaBridgeDispatcherHostManager::JavaBridgeDispatcherHostManager( | 11 JavaBridgeDispatcherHostManager::JavaBridgeDispatcherHostManager( |
| 13 TabContents* tab_contents) | 12 content::WebContents* web_contents) |
| 14 : content::WebContentsObserver(tab_contents) { | 13 : content::WebContentsObserver(web_contents) { |
| 15 } | 14 } |
| 16 | 15 |
| 17 JavaBridgeDispatcherHostManager::~JavaBridgeDispatcherHostManager() { | 16 JavaBridgeDispatcherHostManager::~JavaBridgeDispatcherHostManager() { |
| 18 DCHECK_EQ(0U, instances_.size()); | 17 DCHECK_EQ(0U, instances_.size()); |
| 19 } | 18 } |
| 20 | 19 |
| 21 void JavaBridgeDispatcherHostManager::AddNamedObject(const string16& name, | 20 void JavaBridgeDispatcherHostManager::AddNamedObject(const string16& name, |
| 22 NPObject* object) { | 21 NPObject* object) { |
| 23 // Record this object in a map so that we can add it into RenderViewHosts | 22 // Record this object in a map so that we can add it into RenderViewHosts |
| 24 // created later. The JavaBridgeDispatcherHost instances will take a | 23 // created later. The JavaBridgeDispatcherHost instances will take a |
| (...skipping 38 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 63 instances_[render_view_host] = instance; | 62 instances_[render_view_host] = instance; |
| 64 } | 63 } |
| 65 | 64 |
| 66 void JavaBridgeDispatcherHostManager::RenderViewDeleted( | 65 void JavaBridgeDispatcherHostManager::RenderViewDeleted( |
| 67 RenderViewHost* render_view_host) { | 66 RenderViewHost* render_view_host) { |
| 68 instances_.erase(render_view_host); | 67 instances_.erase(render_view_host); |
| 69 } | 68 } |
| 70 | 69 |
| 71 void JavaBridgeDispatcherHostManager::WebContentsDestroyed( | 70 void JavaBridgeDispatcherHostManager::WebContentsDestroyed( |
| 72 content::WebContents* web_contents) { | 71 content::WebContents* web_contents) { |
| 73 // When the tab is shutting down, the TabContents clears its observers before | 72 // When the tab is shutting down, the WebContents clears its observers before |
| 74 // it kills all of its RenderViewHosts, so we won't get a call to | 73 // it kills all of its RenderViewHosts, so we won't get a call to |
| 75 // RenderViewDeleted() for all RenderViewHosts. | 74 // RenderViewDeleted() for all RenderViewHosts. |
| 76 instances_.clear(); | 75 instances_.clear(); |
| 77 } | 76 } |
| OLD | NEW |