Chromium Code Reviews| Index: chrome/browser/task_management/providers/web_contents/extension_task.cc |
| diff --git a/chrome/browser/task_management/providers/web_contents/extension_task.cc b/chrome/browser/task_management/providers/web_contents/extension_task.cc |
| new file mode 100644 |
| index 0000000000000000000000000000000000000000..ae39da90c0b75d39d397bc024d480763adddff3d |
| --- /dev/null |
| +++ b/chrome/browser/task_management/providers/web_contents/extension_task.cc |
| @@ -0,0 +1,79 @@ |
| +// Copyright 2015 The Chromium Authors. All rights reserved. |
| +// Use of this source code is governed by a BSD-style license that can be |
| +// found in the LICENSE file. |
| + |
| +#include "chrome/browser/task_management/providers/web_contents/extension_task.h" |
| + |
| +#include "base/strings/utf_string_conversions.h" |
| +#include "content/public/browser/browser_context.h" |
| +#include "content/public/browser/web_contents.h" |
| +#include "extensions/browser/view_type_utils.h" |
| +#include "extensions/common/extension.h" |
| +#include "extensions/common/view_type.h" |
| +#include "grit/theme_resources.h" |
| +#include "ui/base/resource/resource_bundle.h" |
| + |
| +namespace task_management { |
| + |
| +namespace { |
| + |
| +gfx::ImageSkia* g_default_icon = nullptr; |
| + |
| +gfx::ImageSkia* GetDefaultIcon() { |
| + if (!g_default_icon && ResourceBundle::HasSharedInstance()) { |
|
Devlin
2015/08/04 16:05:07
When would HasSharedInstance() fail? And, if it *
afakhry
2015/08/04 18:31:08
This happened to me once in the past. I opened the
Devlin
2015/08/04 20:22:40
This doesn't really answer the question of "What i
afakhry
2015/08/05 17:20:07
This should never happen. If it does, that's an in
Devlin
2015/08/06 17:43:44
This is probably edge case of edge case, but I dis
afakhry
2015/08/06 18:01:27
I changed it to return nullptr whenever !ResourceB
|
| + g_default_icon = ResourceBundle::GetSharedInstance().GetImageSkiaNamed( |
| + IDR_PLUGINS_FAVICON); |
|
Devlin
2015/08/04 16:05:07
Why use plugins, instead of extensions?
afakhry
2015/08/04 18:31:08
Indeed there's an IDR_EXTENSIONS_FAVICON not sure
ncarter (slow)
2015/08/04 18:55:19
We ought to switch to IDR_EXTENSIONS_FAVICON here.
afakhry
2015/08/05 17:20:07
Done.
|
| + } |
| + |
| + return g_default_icon; |
| +} |
| + |
| +} // namespace |
| + |
| +ExtensionTask::ExtensionTask(content::WebContents* web_contents, |
| + const extensions::Extension* extension) |
| + : RendererTask(GetExtensionTitle(web_contents, extension), |
| + GetDefaultIcon(), |
| + web_contents) { |
| +} |
| + |
| +ExtensionTask::~ExtensionTask() { |
| +} |
| + |
| +void ExtensionTask::OnTitleChanged(content::NavigationEntry* entry) { |
| + // The title of the extension should not change as a result of title change |
| + // in its WebContents, so we ignore this. |
| +} |
| + |
| +void ExtensionTask::OnFaviconChanged() { |
| + // We never change the favicon of the extension, we always use the default |
|
Devlin
2015/08/04 16:05:07
Probably out of scope for this change, but why don
afakhry
2015/08/04 18:31:08
I agree. What do you think, Nick?
Devlin, Can we
Devlin
2015/08/04 20:22:40
Sure, indirectly (more like the browser context).
afakhry
2015/08/05 17:20:07
Let me see if I can do that in a follow-up patch.
|
| + // one. |
| +} |
| + |
| +Task::Type ExtensionTask::GetType() const { |
| + return Task::EXTENSION; |
| +} |
| + |
| +base::string16 ExtensionTask::GetExtensionTitle( |
| + content::WebContents* web_contents, |
| + const extensions::Extension* extension) const { |
| + DCHECK(web_contents); |
| + DCHECK(extension); |
| + |
| + base::string16 title = base::UTF8ToUTF16(extension->name()); |
| + |
| + DCHECK(!title.empty()); |
| + |
| + extensions::ViewType view_type = extensions::GetViewType(web_contents); |
| + bool is_background = |
| + (view_type == extensions::VIEW_TYPE_EXTENSION_BACKGROUND_PAGE); |
|
Devlin
2015/08/04 16:05:07
nitty nit: Can we inline this a bit, to be
bool is
afakhry
2015/08/04 18:31:08
Done.
|
| + |
| + return RendererTask::PrefixRendererTitle( |
| + title, |
| + extension->is_app(), |
| + true, // is_extension |
| + web_contents->GetBrowserContext()->IsOffTheRecord(), |
| + is_background); |
| +} |
| + |
| +} // namespace task_management |