Chromium Code Reviews| 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_management/providers/web_contents/extension_task.h " | 5 #include "chrome/browser/task_management/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" | |
| 9 #include "chrome/browser/ui/browser.h" | |
| 10 #include "chrome/browser/ui/browser_finder.h" | |
| 11 #include "chrome/browser/ui/chrome_pages.h" | |
| 8 #include "content/public/browser/browser_context.h" | 12 #include "content/public/browser/browser_context.h" |
| 9 #include "content/public/browser/web_contents.h" | 13 #include "content/public/browser/web_contents.h" |
| 10 #include "extensions/browser/view_type_utils.h" | 14 #include "extensions/browser/view_type_utils.h" |
| 11 #include "extensions/common/constants.h" | 15 #include "extensions/common/constants.h" |
| 12 #include "extensions/common/extension.h" | 16 #include "extensions/common/extension.h" |
| 13 #include "extensions/common/manifest_handlers/icons_handler.h" | 17 #include "extensions/common/manifest_handlers/icons_handler.h" |
| 14 #include "extensions/common/view_type.h" | 18 #include "extensions/common/view_type.h" |
| 15 #include "grit/theme_resources.h" | 19 #include "grit/theme_resources.h" |
| 16 #include "ui/base/resource/resource_bundle.h" | 20 #include "ui/base/resource/resource_bundle.h" |
| 17 | 21 |
| (...skipping 16 matching lines...) Expand all Loading... | |
| 34 } | 38 } |
| 35 | 39 |
| 36 } // namespace | 40 } // namespace |
| 37 | 41 |
| 38 ExtensionTask::ExtensionTask(content::WebContents* web_contents, | 42 ExtensionTask::ExtensionTask(content::WebContents* web_contents, |
| 39 const extensions::Extension* extension, | 43 const extensions::Extension* extension, |
| 40 extensions::ViewType view_type) | 44 extensions::ViewType view_type) |
| 41 : RendererTask(GetExtensionTitle(web_contents, extension, view_type), | 45 : RendererTask(GetExtensionTitle(web_contents, extension, view_type), |
| 42 GetDefaultIcon(), | 46 GetDefaultIcon(), |
| 43 web_contents, | 47 web_contents, |
| 44 web_contents->GetRenderProcessHost()) { | 48 web_contents->GetRenderProcessHost()), |
| 49 extension_id_(extension->id()) { | |
|
afakhry
2016/05/25 18:50:59
I applied this locally and flashed it on a chromeo
ncarter (slow)
2016/05/25 19:59:09
Yuck. Thanks for figuring that out.
| |
| 45 LoadExtensionIcon(extension); | 50 LoadExtensionIcon(extension); |
| 46 } | 51 } |
| 47 | 52 |
| 48 ExtensionTask::~ExtensionTask() { | 53 ExtensionTask::~ExtensionTask() { |
| 49 } | 54 } |
| 50 | 55 |
| 51 void ExtensionTask::UpdateTitle() { | 56 void ExtensionTask::UpdateTitle() { |
| 52 // The title of the extension should not change as a result of title change | 57 // The title of the extension should not change as a result of title change |
| 53 // in its WebContents, so we ignore this. | 58 // in its WebContents, so we ignore this. |
| 54 } | 59 } |
| 55 | 60 |
| 56 void ExtensionTask::UpdateFavicon() { | 61 void ExtensionTask::UpdateFavicon() { |
| 57 // We don't care about the favicon of the WebContents but rather of the | 62 // We don't care about the favicon of the WebContents but rather of the |
| 58 // extension. | 63 // extension. |
| 59 } | 64 } |
| 60 | 65 |
| 66 void ExtensionTask::Activate() { | |
| 67 // TODO(nick): For extensions::VIEW_TYPE_APP_WINDOW, and maybe others, there | |
| 68 // may actually be a window we could focus. Special case those here as needed. | |
| 69 Browser* browser = chrome::FindTabbedBrowser( | |
| 70 Profile::FromBrowserContext(web_contents()->GetBrowserContext()), true); | |
| 71 | |
| 72 // If an existing browser isn't found, don't create a new one. | |
| 73 if (!browser) | |
| 74 return; | |
| 75 | |
| 76 chrome::ShowExtensions(browser, extension_id_); | |
| 77 } | |
| 78 | |
| 61 Task::Type ExtensionTask::GetType() const { | 79 Task::Type ExtensionTask::GetType() const { |
| 62 return Task::EXTENSION; | 80 return Task::EXTENSION; |
| 63 } | 81 } |
| 64 | 82 |
| 65 void ExtensionTask::OnExtensionIconImageChanged(extensions::IconImage* image) { | 83 void ExtensionTask::OnExtensionIconImageChanged(extensions::IconImage* image) { |
| 66 DCHECK_EQ(extension_icon_.get(), image); | 84 DCHECK_EQ(extension_icon_.get(), image); |
| 67 | 85 |
| 68 if (!image->image_skia().isNull()) | 86 if (!image->image_skia().isNull()) |
| 69 set_icon(image->image_skia()); | 87 set_icon(image->image_skia()); |
| 70 } | 88 } |
| (...skipping 30 matching lines...) Expand all Loading... | |
| 101 extension_misc::EXTENSION_ICON_SMALL, | 119 extension_misc::EXTENSION_ICON_SMALL, |
| 102 icon(), | 120 icon(), |
| 103 this)); | 121 this)); |
| 104 | 122 |
| 105 // Triggers actual image loading with 1x resources. | 123 // Triggers actual image loading with 1x resources. |
| 106 extension_icon_->image_skia().GetRepresentation(1.0f); | 124 extension_icon_->image_skia().GetRepresentation(1.0f); |
| 107 set_icon(extension_icon_->image_skia()); | 125 set_icon(extension_icon_->image_skia()); |
| 108 } | 126 } |
| 109 | 127 |
| 110 } // namespace task_management | 128 } // namespace task_management |
| OLD | NEW |