Chromium Code Reviews
chromiumcodereview-hr@appspot.gserviceaccount.com (chromiumcodereview-hr) | Please choose your nickname with Settings | Help | Chromium Project | Gerrit Changes | Sign out
(620)

Side by Side Diff: chrome/browser/task_manager/task_manager_resource_providers.cc

Issue 11772005: Implement a prototype to render cross-site iframes in a separate process from their parent. (Closed) Base URL: svn://svn.chromium.org/chrome/trunk/src
Patch Set: Some cleanup. Created 7 years, 11 months ago
Use n/p to move between diff chunks; N/P to move between comments. Draft comments are only viewable by you.
Jump to:
View unified diff | Download patch | Annotate | Revision Log
OLDNEW
1 // Copyright 2012 The Chromium Authors. All rights reserved. 1 // Copyright 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/task_manager/task_manager_resource_providers.h" 5 #include "chrome/browser/task_manager/task_manager_resource_providers.h"
6 6
7 #include <string> 7 #include <string>
8 8
9 #include "base/basictypes.h" 9 #include "base/basictypes.h"
10 #include "base/bind.h" 10 #include "base/bind.h"
11 #include "base/command_line.h" 11 #include "base/command_line.h"
12 #include "base/file_version_info.h" 12 #include "base/file_version_info.h"
13 #include "base/i18n/rtl.h" 13 #include "base/i18n/rtl.h"
14 #include "base/memory/scoped_ptr.h" 14 #include "base/memory/scoped_ptr.h"
15 #include "base/process_util.h" 15 #include "base/process_util.h"
16 #include "base/stl_util.h" 16 #include "base/stl_util.h"
17 #include "base/string_util.h" 17 #include "base/string_util.h"
18 #include "base/threading/thread.h" 18 #include "base/threading/thread.h"
19 #include "base/utf_string_conversions.h" 19 #include "base/utf_string_conversions.h"
20 #include "build/build_config.h" 20 #include "build/build_config.h"
21 #include "chrome/app/chrome_command_ids.h" 21 #include "chrome/app/chrome_command_ids.h"
22 #include "chrome/browser/background/background_contents_service.h" 22 #include "chrome/browser/background/background_contents_service.h"
23 #include "chrome/browser/background/background_contents_service_factory.h" 23 #include "chrome/browser/background/background_contents_service_factory.h"
24 #include "chrome/browser/browser_process.h" 24 #include "chrome/browser/browser_process.h"
25 #include "chrome/browser/devtools/devtools_window.h" 25 #include "chrome/browser/devtools/devtools_window.h"
26 #include "chrome/browser/extensions/extension_host.h" 26 #include "chrome/browser/extensions/extension_host.h"
27 #include "chrome/browser/extensions/extension_process_manager.h" 27 #include "chrome/browser/extensions/extension_process_manager.h"
28 #include "chrome/browser/extensions/extension_service.h" 28 #include "chrome/browser/extensions/extension_service.h"
29 #include "chrome/browser/extensions/extension_system.h" 29 #include "chrome/browser/extensions/extension_system.h"
30 #include "chrome/browser/extensions/tab_helper.h"
30 #include "chrome/browser/favicon/favicon_tab_helper.h" 31 #include "chrome/browser/favicon/favicon_tab_helper.h"
31 #include "chrome/browser/prerender/prerender_manager.h" 32 #include "chrome/browser/prerender/prerender_manager.h"
32 #include "chrome/browser/prerender/prerender_manager_factory.h" 33 #include "chrome/browser/prerender/prerender_manager_factory.h"
33 #include "chrome/browser/printing/background_printing_manager.h" 34 #include "chrome/browser/printing/background_printing_manager.h"
34 #include "chrome/browser/profiles/profile.h" 35 #include "chrome/browser/profiles/profile.h"
35 #include "chrome/browser/profiles/profile_info_cache.h" 36 #include "chrome/browser/profiles/profile_info_cache.h"
36 #include "chrome/browser/profiles/profile_manager.h" 37 #include "chrome/browser/profiles/profile_manager.h"
37 #include "chrome/browser/tab_contents/background_contents.h" 38 #include "chrome/browser/tab_contents/background_contents.h"
38 #include "chrome/browser/tab_contents/tab_util.h" 39 #include "chrome/browser/tab_contents/tab_util.h"
39 #include "chrome/browser/ui/browser.h" 40 #include "chrome/browser/ui/browser.h"
(...skipping 1802 matching lines...) Expand 10 before | Expand all | Expand 10 after
1842 if (contents && 1843 if (contents &&
1843 contents->GetRenderProcessHost()->GetID() == render_process_host_id && 1844 contents->GetRenderProcessHost()->GetID() == render_process_host_id &&
1844 contents->GetRenderViewHost()->GetRoutingID() == routing_id) { 1845 contents->GetRenderViewHost()->GetRoutingID() == routing_id) {
1845 return i->second; 1846 return i->second;
1846 } 1847 }
1847 } 1848 }
1848 1849
1849 return NULL; 1850 return NULL;
1850 } 1851 }
1851 1852
1853 // Given a RenderViewHost, return true if this RVH is Cross-site Iframe.
Charlie Reis 2013/01/17 19:44:54 This comment belongs in .h file. We should have a
nasko 2013/01/17 22:19:13 We discussed this in person and both agreed this i
1854 bool TaskManagerGuestResourceProvider::IsOOPIframe(RenderProcessHost* host) {
1855 if (host==NULL || !host->GetHandle())
Charlie Reis 2013/01/17 19:44:54 nit: !host
nasko 2013/01/17 22:19:13 Done.
1856 return false;
1857
1858 for (TabContentsIterator iterator; !iterator.done(); ++iterator) {
1859 if ((*iterator)->GetRenderProcessHost()->GetHandle() == host->GetHandle())
Charlie Reis 2013/01/17 19:44:54 Is it possible for this to crash if a TabContents
nasko 2013/01/17 22:19:13 Done.
1860 return false;
1861 }
1862 return true;
1863 }
1864
1852 void TaskManagerGuestResourceProvider::StartUpdating() { 1865 void TaskManagerGuestResourceProvider::StartUpdating() {
1853 DCHECK(!updating_); 1866 DCHECK(!updating_);
1854 updating_ = true; 1867 updating_ = true;
1855 1868
1856 // Add all the existing guest WebContents. 1869 // Add all the existing guest WebContents.
1857 for (RenderProcessHost::iterator i( 1870 for (RenderProcessHost::iterator i(
1858 RenderProcessHost::AllHostsIterator()); 1871 RenderProcessHost::AllHostsIterator());
1859 !i.IsAtEnd(); i.Advance()) { 1872 !i.IsAtEnd(); i.Advance()) {
1860 RenderProcessHost* host = i.GetCurrentValue(); 1873 RenderProcessHost* host = i.GetCurrentValue();
1861 if (host->IsGuest()) { 1874 if (host->IsGuest() || IsOOPIframe(host)) {
1875 // Current RPH only contains Browser-Plugin Guest or Cross-Site IFrame.
1862 RenderProcessHost::RenderWidgetHostsIterator iter = 1876 RenderProcessHost::RenderWidgetHostsIterator iter =
1863 host->GetRenderWidgetHostsIterator(); 1877 host->GetRenderWidgetHostsIterator();
1864 for (; !iter.IsAtEnd(); iter.Advance()) { 1878 for (; !iter.IsAtEnd(); iter.Advance()) {
1865 const RenderWidgetHost* widget = iter.GetCurrentValue(); 1879 const RenderWidgetHost* widget = iter.GetCurrentValue();
1866 Add(RenderViewHost::From( 1880 Add(RenderViewHost::From(const_cast<RenderWidgetHost*>(widget)));
1867 const_cast<RenderWidgetHost*>(widget)));
1868 } 1881 }
1869 } 1882 }
1870 } 1883 }
1871 1884
1872 // Then we register for notifications to get new guests. 1885 // Then we register for notifications to get new guests.
1873 registrar_.Add(this, content::NOTIFICATION_WEB_CONTENTS_CONNECTED, 1886 registrar_.Add(this, content::NOTIFICATION_WEB_CONTENTS_CONNECTED,
1874 content::NotificationService::AllBrowserContextsAndSources()); 1887 content::NotificationService::AllBrowserContextsAndSources());
1875 registrar_.Add(this, content::NOTIFICATION_WEB_CONTENTS_DISCONNECTED, 1888 registrar_.Add(this, content::NOTIFICATION_WEB_CONTENTS_DISCONNECTED,
1876 content::NotificationService::AllBrowserContextsAndSources()); 1889 content::NotificationService::AllBrowserContextsAndSources());
1877 } 1890 }
(...skipping 34 matching lines...) Expand 10 before | Expand all | Expand 10 after
1912 TaskManagerGuestResource* resource = iter->second; 1925 TaskManagerGuestResource* resource = iter->second;
1913 task_manager_->RemoveResource(resource); 1926 task_manager_->RemoveResource(resource);
1914 resources_.erase(iter); 1927 resources_.erase(iter);
1915 delete resource; 1928 delete resource;
1916 } 1929 }
1917 1930
1918 void TaskManagerGuestResourceProvider::Observe(int type, 1931 void TaskManagerGuestResourceProvider::Observe(int type,
1919 const content::NotificationSource& source, 1932 const content::NotificationSource& source,
1920 const content::NotificationDetails& details) { 1933 const content::NotificationDetails& details) {
1921 WebContents* web_contents = content::Source<WebContents>(source).ptr(); 1934 WebContents* web_contents = content::Source<WebContents>(source).ptr();
1922 if (!web_contents || !web_contents->GetRenderProcessHost()->IsGuest()) 1935 if (!web_contents ||
1936 (!web_contents->GetRenderProcessHost()->IsGuest() &&
1937 !IsOOPIframe(web_contents->GetRenderProcessHost())))
1923 return; 1938 return;
1924 1939
1925 switch (type) { 1940 switch (type) {
1926 case content::NOTIFICATION_WEB_CONTENTS_CONNECTED: 1941 case content::NOTIFICATION_WEB_CONTENTS_CONNECTED:
1927 Add(web_contents->GetRenderViewHost()); 1942 Add(web_contents->GetRenderViewHost());
1928 break; 1943 break;
1929 case content::NOTIFICATION_WEB_CONTENTS_DISCONNECTED: 1944 case content::NOTIFICATION_WEB_CONTENTS_DISCONNECTED:
1930 Remove(web_contents->GetRenderViewHost()); 1945 Remove(web_contents->GetRenderViewHost());
1931 break; 1946 break;
1932 default: 1947 default:
1933 NOTREACHED() << "Unexpected notification."; 1948 NOTREACHED() << "Unexpected notification.";
1934 } 1949 }
1935 } 1950 }
OLDNEW

Powered by Google App Engine
This is Rietveld 408576698