| OLD | NEW |
| 1 // Copyright 2014 The Chromium Authors. All rights reserved. | 1 // Copyright 2014 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/extension_information.h" | 5 #include "chrome/browser/task_manager/extension_information.h" |
| 6 | 6 |
| 7 #include "base/strings/string16.h" | 7 #include "base/strings/string16.h" |
| 8 #include "base/strings/utf_string_conversions.h" | 8 #include "base/strings/utf_string_conversions.h" |
| 9 #include "chrome/browser/browser_process.h" | 9 #include "chrome/browser/browser_process.h" |
| 10 #include "chrome/browser/profiles/profile.h" | 10 #include "chrome/browser/profiles/profile.h" |
| 11 #include "chrome/browser/profiles/profile_manager.h" | 11 #include "chrome/browser/profiles/profile_manager.h" |
| 12 #include "chrome/browser/task_manager/renderer_resource.h" | 12 #include "chrome/browser/task_manager/renderer_resource.h" |
| 13 #include "chrome/browser/task_manager/task_manager_util.h" | 13 #include "chrome/browser/task_manager/task_manager_util.h" |
| 14 #include "content/public/browser/render_frame_host.h" | 14 #include "content/public/browser/render_frame_host.h" |
| 15 #include "content/public/browser/render_process_host.h" | 15 #include "content/public/browser/render_process_host.h" |
| 16 #include "content/public/browser/render_view_host.h" | 16 #include "content/public/browser/render_view_host.h" |
| 17 #include "content/public/browser/web_contents.h" | 17 #include "content/public/browser/web_contents.h" |
| 18 #include "extensions/browser/extension_system.h" | |
| 19 #include "extensions/browser/guest_view/guest_view_base.h" | 18 #include "extensions/browser/guest_view/guest_view_base.h" |
| 20 #include "extensions/browser/process_manager.h" | 19 #include "extensions/browser/process_manager.h" |
| 21 #include "extensions/browser/view_type_utils.h" | 20 #include "extensions/browser/view_type_utils.h" |
| 22 #include "extensions/common/extension.h" | 21 #include "extensions/common/extension.h" |
| 23 #include "grit/theme_resources.h" | 22 #include "grit/theme_resources.h" |
| 24 #include "ui/base/l10n/l10n_util.h" | 23 #include "ui/base/l10n/l10n_util.h" |
| 25 #include "ui/base/resource/resource_bundle.h" | 24 #include "ui/base/resource/resource_bundle.h" |
| 26 #include "ui/gfx/image/image_skia.h" | 25 #include "ui/gfx/image/image_skia.h" |
| 27 | 26 |
| 28 using content::WebContents; | 27 using content::WebContents; |
| 29 using extensions::Extension; | 28 using extensions::Extension; |
| 30 | 29 |
| 31 namespace { | 30 namespace { |
| 32 | 31 |
| 33 const Extension* GetExtensionForWebContents(WebContents* web_contents) { | 32 const Extension* GetExtensionForWebContents(WebContents* web_contents) { |
| 34 Profile* profile = | 33 return extensions::ProcessManager::Get(web_contents->GetBrowserContext()) |
| 35 Profile::FromBrowserContext(web_contents->GetBrowserContext()); | 34 ->GetExtensionForRenderViewHost(web_contents->GetRenderViewHost()); |
| 36 extensions::ProcessManager* process_manager = | |
| 37 extensions::ExtensionSystem::Get(profile)->process_manager(); | |
| 38 return process_manager->GetExtensionForRenderViewHost( | |
| 39 web_contents->GetRenderViewHost()); | |
| 40 } | 35 } |
| 41 | 36 |
| 42 } // namespace | 37 } // namespace |
| 43 | 38 |
| 44 namespace task_manager { | 39 namespace task_manager { |
| 45 | 40 |
| 46 class ExtensionProcessResource : public RendererResource { | 41 class ExtensionProcessResource : public RendererResource { |
| 47 public: | 42 public: |
| 48 explicit ExtensionProcessResource(const Extension* extension, | 43 explicit ExtensionProcessResource(const Extension* extension, |
| 49 content::RenderViewHost* render_view_host); | 44 content::RenderViewHost* render_view_host); |
| (...skipping 72 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 122 ProfileManager* profile_manager = g_browser_process->profile_manager(); | 117 ProfileManager* profile_manager = g_browser_process->profile_manager(); |
| 123 std::vector<Profile*> profiles(profile_manager->GetLoadedProfiles()); | 118 std::vector<Profile*> profiles(profile_manager->GetLoadedProfiles()); |
| 124 size_t num_default_profiles = profiles.size(); | 119 size_t num_default_profiles = profiles.size(); |
| 125 for (size_t i = 0; i < num_default_profiles; ++i) { | 120 for (size_t i = 0; i < num_default_profiles; ++i) { |
| 126 if (profiles[i]->HasOffTheRecordProfile()) { | 121 if (profiles[i]->HasOffTheRecordProfile()) { |
| 127 profiles.push_back(profiles[i]->GetOffTheRecordProfile()); | 122 profiles.push_back(profiles[i]->GetOffTheRecordProfile()); |
| 128 } | 123 } |
| 129 } | 124 } |
| 130 | 125 |
| 131 for (size_t i = 0; i < profiles.size(); ++i) { | 126 for (size_t i = 0; i < profiles.size(); ++i) { |
| 132 extensions::ProcessManager* process_manager = | 127 const extensions::ProcessManager::ViewSet all_views = |
| 133 extensions::ExtensionSystem::Get(profiles[i])->process_manager(); | 128 extensions::ProcessManager::Get(profiles[i])->GetAllViews(); |
| 134 if (process_manager) { | 129 extensions::ProcessManager::ViewSet::const_iterator jt = all_views.begin(); |
| 135 const extensions::ProcessManager::ViewSet all_views = | 130 for (; jt != all_views.end(); ++jt) { |
| 136 process_manager->GetAllViews(); | 131 WebContents* web_contents = WebContents::FromRenderViewHost(*jt); |
| 137 extensions::ProcessManager::ViewSet::const_iterator jt = | 132 if (CheckOwnership(web_contents)) |
| 138 all_views.begin(); | 133 callback.Run(web_contents); |
| 139 for (; jt != all_views.end(); ++jt) { | |
| 140 WebContents* web_contents = WebContents::FromRenderViewHost(*jt); | |
| 141 if (CheckOwnership(web_contents)) | |
| 142 callback.Run(web_contents); | |
| 143 } | |
| 144 } | 134 } |
| 145 } | 135 } |
| 146 } | 136 } |
| 147 | 137 |
| 148 bool ExtensionInformation::CheckOwnership(WebContents* web_contents) { | 138 bool ExtensionInformation::CheckOwnership(WebContents* web_contents) { |
| 149 // Don't add WebContents that belong to a guest (those are handled by | 139 // Don't add WebContents that belong to a guest (those are handled by |
| 150 // GuestInformation). Otherwise they will be added twice. | 140 // GuestInformation). Otherwise they will be added twice. |
| 151 if (extensions::GuestViewBase::IsGuest(web_contents)) | 141 if (extensions::GuestViewBase::IsGuest(web_contents)) |
| 152 return false; | 142 return false; |
| 153 | 143 |
| (...skipping 18 matching lines...) Expand all Loading... |
| 172 const Extension* extension = GetExtensionForWebContents(web_contents); | 162 const Extension* extension = GetExtensionForWebContents(web_contents); |
| 173 if (!extension) { | 163 if (!extension) { |
| 174 NOTREACHED(); | 164 NOTREACHED(); |
| 175 return scoped_ptr<RendererResource>(); | 165 return scoped_ptr<RendererResource>(); |
| 176 } | 166 } |
| 177 return scoped_ptr<RendererResource>(new ExtensionProcessResource( | 167 return scoped_ptr<RendererResource>(new ExtensionProcessResource( |
| 178 extension, web_contents->GetRenderViewHost())); | 168 extension, web_contents->GetRenderViewHost())); |
| 179 } | 169 } |
| 180 | 170 |
| 181 } // namespace task_manager | 171 } // namespace task_manager |
| OLD | NEW |