| 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" |
| 14 #include "extensions/browser/process_manager.h" |
| 10 #include "extensions/browser/view_type_utils.h" | 15 #include "extensions/browser/view_type_utils.h" |
| 11 #include "extensions/common/constants.h" | 16 #include "extensions/common/constants.h" |
| 12 #include "extensions/common/extension.h" | 17 #include "extensions/common/extension.h" |
| 13 #include "extensions/common/manifest_handlers/icons_handler.h" | 18 #include "extensions/common/manifest_handlers/icons_handler.h" |
| 14 #include "extensions/common/view_type.h" | 19 #include "extensions/common/view_type.h" |
| 15 #include "grit/theme_resources.h" | 20 #include "grit/theme_resources.h" |
| 16 #include "ui/base/resource/resource_bundle.h" | 21 #include "ui/base/resource/resource_bundle.h" |
| 17 | 22 |
| 18 namespace task_management { | 23 namespace task_management { |
| 19 | 24 |
| (...skipping 31 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 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 // This task represents the extension view of (for example) a background page |
| 68 // or browser action button, so there is no top-level window to bring to the |
| 69 // front. Instead, when this task is double-clicked, we bring up the |
| 70 // chrome://extensions page in a tab, and highlight the details for this |
| 71 // extension. |
| 72 // |
| 73 // TODO(nick): For extensions::VIEW_TYPE_APP_WINDOW, and maybe others, there |
| 74 // may actually be a window we could focus. Special case those here as needed. |
| 75 const extensions::Extension* extension = |
| 76 extensions::ProcessManager::Get(web_contents()->GetBrowserContext()) |
| 77 ->GetExtensionForWebContents(web_contents()); |
| 78 |
| 79 if (!extension) |
| 80 return; |
| 81 |
| 82 Browser* browser = chrome::FindTabbedBrowser( |
| 83 Profile::FromBrowserContext(web_contents()->GetBrowserContext()), true); |
| 84 |
| 85 // If an existing browser isn't found, don't create a new one. |
| 86 if (!browser) |
| 87 return; |
| 88 |
| 89 chrome::ShowExtensions(browser, extension->id()); |
| 90 } |
| 91 |
| 61 Task::Type ExtensionTask::GetType() const { | 92 Task::Type ExtensionTask::GetType() const { |
| 62 return Task::EXTENSION; | 93 return Task::EXTENSION; |
| 63 } | 94 } |
| 64 | 95 |
| 65 void ExtensionTask::OnExtensionIconImageChanged(extensions::IconImage* image) { | 96 void ExtensionTask::OnExtensionIconImageChanged(extensions::IconImage* image) { |
| 66 DCHECK_EQ(extension_icon_.get(), image); | 97 DCHECK_EQ(extension_icon_.get(), image); |
| 67 | 98 |
| 68 if (!image->image_skia().isNull()) | 99 if (!image->image_skia().isNull()) |
| 69 set_icon(image->image_skia()); | 100 set_icon(image->image_skia()); |
| 70 } | 101 } |
| (...skipping 30 matching lines...) Expand all Loading... |
| 101 extension_misc::EXTENSION_ICON_SMALL, | 132 extension_misc::EXTENSION_ICON_SMALL, |
| 102 icon(), | 133 icon(), |
| 103 this)); | 134 this)); |
| 104 | 135 |
| 105 // Triggers actual image loading with 1x resources. | 136 // Triggers actual image loading with 1x resources. |
| 106 extension_icon_->image_skia().GetRepresentation(1.0f); | 137 extension_icon_->image_skia().GetRepresentation(1.0f); |
| 107 set_icon(extension_icon_->image_skia()); | 138 set_icon(extension_icon_->image_skia()); |
| 108 } | 139 } |
| 109 | 140 |
| 110 } // namespace task_management | 141 } // namespace task_management |
| OLD | NEW |