| 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/web_contents_tags.h" | 5 #include "chrome/browser/task_manager/web_contents_tags.h" |
| 6 | 6 |
| 7 #include "chrome/browser/task_manager/providers/web_contents/background_contents
_tag.h" | 7 #include "chrome/browser/task_manager/providers/web_contents/background_contents
_tag.h" |
| 8 #include "chrome/browser/task_manager/providers/web_contents/devtools_tag.h" | 8 #include "chrome/browser/task_manager/providers/web_contents/devtools_tag.h" |
| 9 #include "chrome/browser/task_manager/providers/web_contents/extension_tag.h" | 9 #include "chrome/browser/task_manager/providers/web_contents/extension_tag.h" |
| 10 #include "chrome/browser/task_manager/providers/web_contents/guest_tag.h" | 10 #include "chrome/browser/task_manager/providers/web_contents/guest_tag.h" |
| 11 #include "chrome/browser/task_manager/providers/web_contents/panel_tag.h" | |
| 12 #include "chrome/browser/task_manager/providers/web_contents/prerender_tag.h" | 11 #include "chrome/browser/task_manager/providers/web_contents/prerender_tag.h" |
| 13 #include "chrome/browser/task_manager/providers/web_contents/printing_tag.h" | 12 #include "chrome/browser/task_manager/providers/web_contents/printing_tag.h" |
| 14 #include "chrome/browser/task_manager/providers/web_contents/tab_contents_tag.h" | 13 #include "chrome/browser/task_manager/providers/web_contents/tab_contents_tag.h" |
| 15 #include "chrome/browser/task_manager/providers/web_contents/web_contents_tags_m
anager.h" | 14 #include "chrome/browser/task_manager/providers/web_contents/web_contents_tags_m
anager.h" |
| 16 #include "components/guest_view/browser/guest_view_base.h" | 15 #include "components/guest_view/browser/guest_view_base.h" |
| 17 #include "content/public/browser/web_contents.h" | 16 #include "content/public/browser/web_contents.h" |
| 18 #include "extensions/browser/view_type_utils.h" | 17 #include "extensions/browser/view_type_utils.h" |
| 19 | 18 |
| 20 #if defined(ENABLE_EXTENSIONS) | 19 #if defined(ENABLE_EXTENSIONS) |
| 21 #include "chrome/browser/ui/panels/panel.h" | |
| 22 #include "extensions/browser/process_manager.h" | 20 #include "extensions/browser/process_manager.h" |
| 23 #endif | 21 #endif |
| 24 | 22 |
| 25 namespace task_manager { | 23 namespace task_manager { |
| 26 | 24 |
| 27 #if defined(ENABLE_TASK_MANAGER) | 25 #if defined(ENABLE_TASK_MANAGER) |
| 28 namespace { | 26 namespace { |
| 29 | 27 |
| 30 // Adds the |tag| to |contents|. It also adds the |tag| to the | 28 // Adds the |tag| to |contents|. It also adds the |tag| to the |
| 31 // |WebContentsTagsManager|. | 29 // |WebContentsTagsManager|. |
| (...skipping 12 matching lines...) Expand all Loading... |
| 44 | 42 |
| 45 bool IsExtensionWebContents(content::WebContents* contents) { | 43 bool IsExtensionWebContents(content::WebContents* contents) { |
| 46 DCHECK(contents); | 44 DCHECK(contents); |
| 47 | 45 |
| 48 if (guest_view::GuestViewBase::IsGuest(contents)) | 46 if (guest_view::GuestViewBase::IsGuest(contents)) |
| 49 return false; | 47 return false; |
| 50 | 48 |
| 51 extensions::ViewType view_type = extensions::GetViewType(contents); | 49 extensions::ViewType view_type = extensions::GetViewType(contents); |
| 52 return (view_type != extensions::VIEW_TYPE_INVALID && | 50 return (view_type != extensions::VIEW_TYPE_INVALID && |
| 53 view_type != extensions::VIEW_TYPE_TAB_CONTENTS && | 51 view_type != extensions::VIEW_TYPE_TAB_CONTENTS && |
| 54 view_type != extensions::VIEW_TYPE_BACKGROUND_CONTENTS && | 52 view_type != extensions::VIEW_TYPE_BACKGROUND_CONTENTS); |
| 55 view_type != extensions::VIEW_TYPE_PANEL); | |
| 56 } | 53 } |
| 57 | 54 |
| 58 #endif // defined(ENABLE_EXTENSIONS) | 55 #endif // defined(ENABLE_EXTENSIONS) |
| 59 | 56 |
| 60 } // namespace | 57 } // namespace |
| 61 #endif // defined(ENABLE_TASK_MANAGER) | 58 #endif // defined(ENABLE_TASK_MANAGER) |
| 62 | 59 |
| 63 // static | 60 // static |
| 64 void WebContentsTags::CreateForBackgroundContents( | 61 void WebContentsTags::CreateForBackgroundContents( |
| 65 content::WebContents* web_contents, | 62 content::WebContents* web_contents, |
| (...skipping 37 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 103 #if defined(ENABLE_TASK_MANAGER) | 100 #if defined(ENABLE_TASK_MANAGER) |
| 104 if (!WebContentsTag::FromWebContents(web_contents)) { | 101 if (!WebContentsTag::FromWebContents(web_contents)) { |
| 105 TagWebContents(web_contents, | 102 TagWebContents(web_contents, |
| 106 new TabContentsTag(web_contents), | 103 new TabContentsTag(web_contents), |
| 107 WebContentsTag::kTagKey); | 104 WebContentsTag::kTagKey); |
| 108 } | 105 } |
| 109 #endif // defined(ENABLE_TASK_MANAGER) | 106 #endif // defined(ENABLE_TASK_MANAGER) |
| 110 } | 107 } |
| 111 | 108 |
| 112 // static | 109 // static |
| 113 void WebContentsTags::CreateForPanel(content::WebContents* web_contents, | |
| 114 Panel* panel) { | |
| 115 #if defined(ENABLE_TASK_MANAGER) && defined(ENABLE_EXTENSIONS) | |
| 116 DCHECK(panel); | |
| 117 DCHECK_EQ(web_contents, panel->GetWebContents()); | |
| 118 | |
| 119 if (!WebContentsTag::FromWebContents(web_contents)) { | |
| 120 TagWebContents(web_contents, | |
| 121 new PanelTag(web_contents, panel), | |
| 122 WebContentsTag::kTagKey); | |
| 123 } | |
| 124 #endif // defined(ENABLE_TASK_MANAGER) && defined(ENABLE_EXTENSIONS) | |
| 125 } | |
| 126 | |
| 127 // static | |
| 128 void WebContentsTags::CreateForPrintingContents( | 110 void WebContentsTags::CreateForPrintingContents( |
| 129 content::WebContents* web_contents) { | 111 content::WebContents* web_contents) { |
| 130 #if defined(ENABLE_TASK_MANAGER) && defined(ENABLE_PRINT_PREVIEW) | 112 #if defined(ENABLE_TASK_MANAGER) && defined(ENABLE_PRINT_PREVIEW) |
| 131 if (!WebContentsTag::FromWebContents(web_contents)) { | 113 if (!WebContentsTag::FromWebContents(web_contents)) { |
| 132 TagWebContents(web_contents, | 114 TagWebContents(web_contents, |
| 133 new PrintingTag(web_contents), | 115 new PrintingTag(web_contents), |
| 134 WebContentsTag::kTagKey); | 116 WebContentsTag::kTagKey); |
| 135 } | 117 } |
| 136 #endif // defined(ENABLE_TASK_MANAGER) && defined(ENABLE_PRINT_PREVIEW) | 118 #endif // defined(ENABLE_TASK_MANAGER) && defined(ENABLE_PRINT_PREVIEW) |
| 137 } | 119 } |
| (...skipping 29 matching lines...) Expand all Loading... |
| 167 void WebContentsTags::ClearTag(content::WebContents* web_contents) { | 149 void WebContentsTags::ClearTag(content::WebContents* web_contents) { |
| 168 #if defined(ENABLE_TASK_MANAGER) | 150 #if defined(ENABLE_TASK_MANAGER) |
| 169 const WebContentsTag* tag = WebContentsTag::FromWebContents(web_contents); | 151 const WebContentsTag* tag = WebContentsTag::FromWebContents(web_contents); |
| 170 WebContentsTagsManager::GetInstance()->ClearFromProvider(tag); | 152 WebContentsTagsManager::GetInstance()->ClearFromProvider(tag); |
| 171 web_contents->RemoveUserData(WebContentsTag::kTagKey); | 153 web_contents->RemoveUserData(WebContentsTag::kTagKey); |
| 172 #endif // defined(ENABLE_TASK_MANAGER) | 154 #endif // defined(ENABLE_TASK_MANAGER) |
| 173 } | 155 } |
| 174 | 156 |
| 175 } // namespace task_manager | 157 } // namespace task_manager |
| 176 | 158 |
| OLD | NEW |