#include "content/public/browser/notification_types.h"
#include "content/public/browser/render_process_host.h"
#include "content/public/browser/render_view_host.h"
+#include "content/public/browser/resource_request_info.h"
#include "content/public/browser/web_contents.h"
#include "content/public/browser/web_contents_observer.h"
+#include "content/public/common/process_type.h"
using content::BrowserThread;
using content::RenderProcessHost;
render_view_host_(host) {
}
- virtual void RenderViewDeleted(content::RenderViewHost* host) OVERRIDE {
+ void RenderViewDeleted(content::RenderViewHost* host) override {
if (host != render_view_host_)
return;
BrowserThread::PostTask(
: public content::NotificationObserver {
public:
TabObserver();
- virtual ~TabObserver();
+ ~TabObserver() override;
private:
// content::NotificationObserver interface.
- virtual void Observe(int type,
- const content::NotificationSource& source,
- const content::NotificationDetails& details) OVERRIDE;
+ void Observe(int type,
+ const content::NotificationSource& source,
+ const content::NotificationDetails& details) override;
content::NotificationRegistrar registrar_;
};
ExtensionRendererState::TabObserver::TabObserver() {
- DCHECK(BrowserThread::CurrentlyOn(BrowserThread::UI));
+ DCHECK_CURRENTLY_ON(BrowserThread::UI);
registrar_.Add(this,
content::NOTIFICATION_WEB_CONTENTS_RENDER_VIEW_HOST_CREATED,
content::NotificationService::AllBrowserContextsAndSources());
}
ExtensionRendererState::TabObserver::~TabObserver() {
- DCHECK(BrowserThread::CurrentlyOn(BrowserThread::UI));
+ DCHECK_CURRENTLY_ON(BrowserThread::UI);
}
void ExtensionRendererState::TabObserver::Observe(
void ExtensionRendererState::SetTabAndWindowId(
int render_process_host_id, int routing_id, int tab_id, int window_id) {
- DCHECK(BrowserThread::CurrentlyOn(BrowserThread::IO));
+ DCHECK_CURRENTLY_ON(BrowserThread::IO);
RenderId render_id(render_process_host_id, routing_id);
map_[render_id] = TabAndWindowId(tab_id, window_id);
}
void ExtensionRendererState::ClearTabAndWindowId(
int render_process_host_id, int routing_id) {
- DCHECK(BrowserThread::CurrentlyOn(BrowserThread::IO));
+ DCHECK_CURRENTLY_ON(BrowserThread::IO);
RenderId render_id(render_process_host_id, routing_id);
map_.erase(render_id);
}
bool ExtensionRendererState::GetTabAndWindowId(
- int render_process_host_id, int routing_id, int* tab_id, int* window_id) {
- DCHECK(BrowserThread::CurrentlyOn(BrowserThread::IO));
- RenderId render_id(render_process_host_id, routing_id);
+ const content::ResourceRequestInfo* info, int* tab_id, int* window_id) {
+ DCHECK_CURRENTLY_ON(BrowserThread::IO);
+ int render_process_id;
+ if (info->GetProcessType() == content::PROCESS_TYPE_PLUGIN) {
+ render_process_id = info->GetOriginPID();
+ } else {
+ render_process_id = info->GetChildID();
+ }
+ int render_view_id = info->GetRouteID();
+ RenderId render_id(render_process_id, render_view_id);
TabAndWindowIdMap::iterator iter = map_.find(render_id);
if (iter != map_.end()) {
*tab_id = iter->second.first;
}
return false;
}
-
-void ExtensionRendererState::AddWebView(int guest_process_id,
- int guest_routing_id,
- const WebViewInfo& webview_info) {
- DCHECK(BrowserThread::CurrentlyOn(BrowserThread::IO));
- RenderId render_id(guest_process_id, guest_routing_id);
- webview_info_map_[render_id] = webview_info;
-}
-
-void ExtensionRendererState::RemoveWebView(int guest_process_id,
- int guest_routing_id) {
- DCHECK(BrowserThread::CurrentlyOn(BrowserThread::IO));
- RenderId render_id(guest_process_id, guest_routing_id);
- webview_info_map_.erase(render_id);
-}
-
-bool ExtensionRendererState::GetWebViewInfo(int guest_process_id,
- int guest_routing_id,
- WebViewInfo* webview_info) {
- DCHECK(BrowserThread::CurrentlyOn(BrowserThread::IO));
- RenderId render_id(guest_process_id, guest_routing_id);
- WebViewInfoMap::iterator iter = webview_info_map_.find(render_id);
- if (iter != webview_info_map_.end()) {
- *webview_info = iter->second;
- return true;
- }
- return false;
-}