Chromium Code Reviews| 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/guest_information.h" | 5 #include "chrome/browser/task_manager/guest_information.h" |
| 6 | 6 |
| 7 #include "base/strings/string16.h" | 7 #include "base/strings/string16.h" |
| 8 #include "chrome/browser/chrome_notification_types.h" | 8 #include "chrome/browser/chrome_notification_types.h" |
| 9 #include "chrome/browser/favicon/favicon_tab_helper.h" | 9 #include "chrome/browser/favicon/favicon_tab_helper.h" |
| 10 #include "chrome/browser/profiles/profile.h" | 10 #include "chrome/browser/profiles/profile.h" |
| 11 #include "chrome/browser/task_manager/renderer_resource.h" | 11 #include "chrome/browser/task_manager/renderer_resource.h" |
| 12 #include "chrome/browser/task_manager/resource_provider.h" | 12 #include "chrome/browser/task_manager/resource_provider.h" |
| 13 #include "chrome/browser/task_manager/task_manager.h" | 13 #include "chrome/browser/task_manager/task_manager.h" |
| 14 #include "chrome/browser/task_manager/task_manager_util.h" | 14 #include "chrome/browser/task_manager/task_manager_util.h" |
| 15 #include "chrome/grit/generated_resources.h" | 15 #include "chrome/grit/generated_resources.h" |
| 16 #include "content/public/browser/notification_service.h" | 16 #include "content/public/browser/notification_service.h" |
| 17 #include "content/public/browser/render_frame_host.h" | 17 #include "content/public/browser/render_frame_host.h" |
| 18 #include "content/public/browser/render_process_host.h" | 18 #include "content/public/browser/render_process_host.h" |
| 19 #include "content/public/browser/render_view_host.h" | 19 #include "content/public/browser/render_view_host.h" |
| 20 #include "content/public/browser/render_widget_host_iterator.h" | 20 #include "content/public/browser/render_widget_host_iterator.h" |
| 21 #include "content/public/browser/site_instance.h" | 21 #include "content/public/browser/site_instance.h" |
| 22 #include "content/public/browser/web_contents.h" | 22 #include "content/public/browser/web_contents.h" |
| 23 #include "extensions/browser/guest_view/guest_view_base.h" | |
| 23 #include "ui/base/l10n/l10n_util.h" | 24 #include "ui/base/l10n/l10n_util.h" |
| 24 #include "ui/gfx/image/image.h" | 25 #include "ui/gfx/image/image.h" |
| 25 #include "ui/gfx/image/image_skia.h" | 26 #include "ui/gfx/image/image_skia.h" |
| 26 | 27 |
| 27 using content::RenderProcessHost; | 28 using content::RenderProcessHost; |
| 28 using content::RenderViewHost; | 29 using content::RenderViewHost; |
| 29 using content::RenderWidgetHost; | 30 using content::RenderWidgetHost; |
| 30 using content::WebContents; | 31 using content::WebContents; |
| 31 using extensions::Extension; | 32 using extensions::Extension; |
| 32 | 33 |
| (...skipping 22 matching lines...) Expand all Loading... | |
| 55 | 56 |
| 56 GuestResource::~GuestResource() { | 57 GuestResource::~GuestResource() { |
| 57 } | 58 } |
| 58 | 59 |
| 59 Resource::Type GuestResource::GetType() const { | 60 Resource::Type GuestResource::GetType() const { |
| 60 return GUEST; | 61 return GUEST; |
| 61 } | 62 } |
| 62 | 63 |
| 63 base::string16 GuestResource::GetTitle() const { | 64 base::string16 GuestResource::GetTitle() const { |
| 64 WebContents* web_contents = GetWebContents(); | 65 WebContents* web_contents = GetWebContents(); |
| 65 const int message_id = IDS_TASK_MANAGER_WEBVIEW_TAG_PREFIX; | 66 if (!web_contents) { |
| 66 if (web_contents) { | 67 const int message_id = IDS_TASK_MANAGER_WEBVIEW_TAG_PREFIX; |
| 67 base::string16 title = util::GetTitleFromWebContents(web_contents); | 68 return l10n_util::GetStringFUTF16(message_id, base::string16()); |
| 68 return l10n_util::GetStringFUTF16(message_id, title); | |
| 69 } | 69 } |
| 70 return l10n_util::GetStringFUTF16(message_id, base::string16()); | 70 return extensions::GuestViewBase::FromWebContents(web_contents)-> |
| 71 GetTaskName(); | |
|
Charlie Reis
2014/08/22 21:11:43
Who determines this value? I'm skeptical about al
Fady Samuel
2014/08/22 21:15:31
Apps don't: however, there are multiple GuestView
Fady Samuel
2014/08/22 21:16:24
For example: Here is what appview does: https://co
Charlie Reis
2014/08/22 21:23:20
Ah, thanks. That sounds fine. I just didn't want
Fady Samuel
2014/08/22 21:48:54
MIMETypeHandler (in a separate CL) is used to load
Charlie Reis
2014/08/22 21:57:47
Could we do that by setting the title of that WebC
Charlie Reis
2014/08/22 22:40:01
Is this suggestion feasible? (Not sure if you saw
| |
| 71 } | 72 } |
| 72 | 73 |
| 73 gfx::ImageSkia GuestResource::GetIcon() const { | 74 gfx::ImageSkia GuestResource::GetIcon() const { |
| 74 WebContents* web_contents = GetWebContents(); | 75 WebContents* web_contents = GetWebContents(); |
| 75 if (web_contents && FaviconTabHelper::FromWebContents(web_contents)) { | 76 if (web_contents && FaviconTabHelper::FromWebContents(web_contents)) { |
| 76 return FaviconTabHelper::FromWebContents(web_contents)-> | 77 return FaviconTabHelper::FromWebContents(web_contents)-> |
| 77 GetFavicon().AsImageSkia(); | 78 GetFavicon().AsImageSkia(); |
| 78 } | 79 } |
| 79 return gfx::ImageSkia(); | 80 return gfx::ImageSkia(); |
| 80 } | 81 } |
| 81 | 82 |
| 82 WebContents* GuestResource::GetWebContents() const { | 83 WebContents* GuestResource::GetWebContents() const { |
| 83 return WebContents::FromRenderViewHost(render_view_host()); | 84 return WebContents::FromRenderViewHost(render_view_host()); |
| 84 } | 85 } |
| 85 | 86 |
| 86 //////////////////////////////////////////////////////////////////////////////// | 87 //////////////////////////////////////////////////////////////////////////////// |
| 87 // GuestInformation class | 88 // GuestInformation class |
| 88 //////////////////////////////////////////////////////////////////////////////// | 89 //////////////////////////////////////////////////////////////////////////////// |
| 89 | 90 |
| 90 GuestInformation::GuestInformation() {} | 91 GuestInformation::GuestInformation() {} |
| 91 | 92 |
| 92 GuestInformation::~GuestInformation() {} | 93 GuestInformation::~GuestInformation() {} |
| 93 | 94 |
| 94 bool GuestInformation::CheckOwnership(WebContents* web_contents) { | 95 bool GuestInformation::CheckOwnership(WebContents* web_contents) { |
| 95 // Guest WebContentses are created and owned internally by the content layer. | 96 // Guest WebContentses are created and owned internally by the content layer. |
| 96 return web_contents->IsSubframe(); | 97 return extensions::GuestViewBase::IsGuest(web_contents); |
| 97 } | 98 } |
| 98 | 99 |
| 99 void GuestInformation::GetAll(const NewWebContentsCallback& callback) { | 100 void GuestInformation::GetAll(const NewWebContentsCallback& callback) { |
| 100 scoped_ptr<content::RenderWidgetHostIterator> widgets( | 101 scoped_ptr<content::RenderWidgetHostIterator> widgets( |
| 101 content::RenderWidgetHost::GetRenderWidgetHosts()); | 102 content::RenderWidgetHost::GetRenderWidgetHosts()); |
| 102 while (content::RenderWidgetHost* widget = widgets->GetNextHost()) { | 103 while (content::RenderWidgetHost* widget = widgets->GetNextHost()) { |
| 103 if (widget->IsRenderView()) { | 104 if (widget->IsRenderView()) { |
| 104 content::RenderViewHost* rvh = content::RenderViewHost::From(widget); | 105 content::RenderViewHost* rvh = content::RenderViewHost::From(widget); |
| 105 WebContents* web_contents = WebContents::FromRenderViewHost(rvh); | 106 WebContents* web_contents = WebContents::FromRenderViewHost(rvh); |
| 106 if (web_contents && web_contents->IsSubframe()) | 107 if (web_contents && extensions::GuestViewBase::IsGuest(web_contents)) |
| 107 callback.Run(web_contents); | 108 callback.Run(web_contents); |
| 108 } | 109 } |
| 109 } | 110 } |
| 110 } | 111 } |
| 111 | 112 |
| 112 scoped_ptr<RendererResource> GuestInformation::MakeResource( | 113 scoped_ptr<RendererResource> GuestInformation::MakeResource( |
| 113 WebContents* web_contents) { | 114 WebContents* web_contents) { |
| 114 return scoped_ptr<RendererResource>( | 115 return scoped_ptr<RendererResource>( |
| 115 new GuestResource(web_contents->GetRenderViewHost())); | 116 new GuestResource(web_contents->GetRenderViewHost())); |
| 116 } | 117 } |
| 117 | 118 |
| 118 } // namespace task_manager | 119 } // namespace task_manager |
| OLD | NEW |