| OLD | NEW |
| 1 // Copyright 2015 The Chromium Authors. All rights reserved. | 1 // Copyright 2015 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/providers/web_contents/extension_task.h" | 5 #include "chrome/browser/task_manager/providers/web_contents/extension_task.h" |
| 6 | 6 |
| 7 #include "base/strings/utf_string_conversions.h" | 7 #include "base/strings/utf_string_conversions.h" |
| 8 #include "chrome/browser/profiles/profile.h" | 8 #include "chrome/browser/profiles/profile.h" |
| 9 #include "chrome/browser/ui/browser.h" | 9 #include "chrome/browser/ui/browser.h" |
| 10 #include "chrome/browser/ui/browser_finder.h" | 10 #include "chrome/browser/ui/browser_finder.h" |
| (...skipping 28 matching lines...) Expand all Loading... |
| 39 } | 39 } |
| 40 | 40 |
| 41 } // namespace | 41 } // namespace |
| 42 | 42 |
| 43 ExtensionTask::ExtensionTask(content::WebContents* web_contents, | 43 ExtensionTask::ExtensionTask(content::WebContents* web_contents, |
| 44 const extensions::Extension* extension, | 44 const extensions::Extension* extension, |
| 45 extensions::ViewType view_type) | 45 extensions::ViewType view_type) |
| 46 : RendererTask(GetExtensionTitle(web_contents, extension, view_type), | 46 : RendererTask(GetExtensionTitle(web_contents, extension, view_type), |
| 47 GetDefaultIcon(), | 47 GetDefaultIcon(), |
| 48 web_contents, | 48 web_contents, |
| 49 web_contents->GetRenderProcessHost()) { | 49 web_contents->GetRenderProcessHost()), |
| 50 view_type_(view_type) { |
| 50 LoadExtensionIcon(extension); | 51 LoadExtensionIcon(extension); |
| 51 } | 52 } |
| 52 | 53 |
| 53 ExtensionTask::~ExtensionTask() { | 54 ExtensionTask::~ExtensionTask() { |
| 54 } | 55 } |
| 55 | 56 |
| 56 void ExtensionTask::UpdateTitle() { | 57 void ExtensionTask::UpdateTitle() { |
| 57 // The title of the extension should not change as a result of title change | 58 // The title of the extension should not change as a result of title change |
| 58 // in its WebContents, so we ignore this. | 59 // in its WebContents, so we ignore this. |
| 59 } | 60 } |
| (...skipping 26 matching lines...) Expand all Loading... |
| 86 if (!browser) | 87 if (!browser) |
| 87 return; | 88 return; |
| 88 | 89 |
| 89 chrome::ShowExtensions(browser, extension->id()); | 90 chrome::ShowExtensions(browser, extension->id()); |
| 90 } | 91 } |
| 91 | 92 |
| 92 Task::Type ExtensionTask::GetType() const { | 93 Task::Type ExtensionTask::GetType() const { |
| 93 return Task::EXTENSION; | 94 return Task::EXTENSION; |
| 94 } | 95 } |
| 95 | 96 |
| 97 int ExtensionTask::GetKeepaliveCount() const { |
| 98 if (view_type_ != extensions::VIEW_TYPE_EXTENSION_BACKGROUND_PAGE) |
| 99 return -1; |
| 100 |
| 101 const extensions::Extension* extension = |
| 102 extensions::ProcessManager::Get(web_contents()->GetBrowserContext()) |
| 103 ->GetExtensionForWebContents(web_contents()); |
| 104 if (!extension) |
| 105 return -1; |
| 106 |
| 107 return extensions::ProcessManager::Get(web_contents()->GetBrowserContext()) |
| 108 ->GetLazyKeepaliveCount(extension); |
| 109 } |
| 110 |
| 96 void ExtensionTask::OnExtensionIconImageChanged(extensions::IconImage* image) { | 111 void ExtensionTask::OnExtensionIconImageChanged(extensions::IconImage* image) { |
| 97 DCHECK_EQ(extension_icon_.get(), image); | 112 DCHECK_EQ(extension_icon_.get(), image); |
| 98 | 113 |
| 99 if (!image->image_skia().isNull()) | 114 if (!image->image_skia().isNull()) |
| 100 set_icon(image->image_skia()); | 115 set_icon(image->image_skia()); |
| 101 } | 116 } |
| 102 | 117 |
| 103 base::string16 ExtensionTask::GetExtensionTitle( | 118 base::string16 ExtensionTask::GetExtensionTitle( |
| 104 content::WebContents* web_contents, | 119 content::WebContents* web_contents, |
| 105 const extensions::Extension* extension, | 120 const extensions::Extension* extension, |
| (...skipping 26 matching lines...) Expand all Loading... |
| 132 extension_misc::EXTENSION_ICON_SMALL, | 147 extension_misc::EXTENSION_ICON_SMALL, |
| 133 icon(), | 148 icon(), |
| 134 this)); | 149 this)); |
| 135 | 150 |
| 136 // Triggers actual image loading with 1x resources. | 151 // Triggers actual image loading with 1x resources. |
| 137 extension_icon_->image_skia().GetRepresentation(1.0f); | 152 extension_icon_->image_skia().GetRepresentation(1.0f); |
| 138 set_icon(extension_icon_->image_skia()); | 153 set_icon(extension_icon_->image_skia()); |
| 139 } | 154 } |
| 140 | 155 |
| 141 } // namespace task_manager | 156 } // namespace task_manager |
| OLD | NEW |