Chromium Code Reviews
chromiumcodereview-hr@appspot.gserviceaccount.com (chromiumcodereview-hr) | Please choose your nickname with Settings | Help | Chromium Project | Gerrit Changes | Sign out
(738)

Side by Side Diff: chrome/browser/task_management/providers/web_contents/subframe_task.cc

Issue 2012623002: Don't display chrome-extension URLs for subframes in the TaskManager (Closed) Base URL: https://chromium.googlesource.com/chromium/src.git@activate_extension
Patch Set: Subframe. Created 4 years, 7 months ago
Use n/p to move between diff chunks; N/P to move between comments. Draft comments are only viewable by you.
Jump to:
View unified diff | Download patch
« no previous file with comments | « no previous file | no next file » | no next file with comments »
Toggle Intra-line Diffs ('i') | Expand Comments ('e') | Collapse Comments ('c') | Show Comments Hide Comments ('s')
OLDNEW
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/subframe_task.h" 5 #include "chrome/browser/task_management/providers/web_contents/subframe_task.h"
6 6
7 #include "base/strings/utf_string_conversions.h" 7 #include "base/strings/utf_string_conversions.h"
8 #include "chrome/grit/generated_resources.h" 8 #include "chrome/grit/generated_resources.h"
9 #include "content/public/browser/browser_context.h" 9 #include "content/public/browser/browser_context.h"
10 #include "content/public/browser/render_frame_host.h" 10 #include "content/public/browser/render_frame_host.h"
11 #include "content/public/browser/render_process_host.h" 11 #include "content/public/browser/render_process_host.h"
12 #include "content/public/browser/site_instance.h" 12 #include "content/public/browser/site_instance.h"
13 #include "content/public/browser/web_contents.h" 13 #include "content/public/browser/web_contents.h"
14 #include "extensions/browser/extension_registry.h"
15 #include "extensions/common/constants.h"
16 #include "extensions/common/extension.h"
17 #include "extensions/common/extension_set.h"
14 #include "ui/base/l10n/l10n_util.h" 18 #include "ui/base/l10n/l10n_util.h"
15 19
16 namespace task_management { 20 namespace task_management {
17 21
18 namespace { 22 namespace {
19 23
20 base::string16 AdjustTitle(const content::SiteInstance* site_instance) { 24 base::string16 AdjustTitle(const content::SiteInstance* site_instance) {
21 DCHECK(site_instance); 25 DCHECK(site_instance);
26
27 // By default, subframe rows display the site, like this:
28 // "Subframe: http://example.com/"
29 const GURL& site_url = site_instance->GetSiteURL();
30 std::string name = site_url.spec();
31
32 // If |site_url| wraps a chrome extension id, we can display the extension
33 // name instead, which is more human-readable.
34 if (site_url.SchemeIs(extensions::kExtensionScheme)) {
35 const extensions::Extension* extension =
36 extensions::ExtensionRegistry::Get(site_instance->GetBrowserContext())
37 ->enabled_extensions()
38 .GetExtensionOrAppByURL(site_url);
39 if (extension)
40 name = extension->name();
41 }
42
22 int message_id = site_instance->GetBrowserContext()->IsOffTheRecord() ? 43 int message_id = site_instance->GetBrowserContext()->IsOffTheRecord() ?
23 IDS_TASK_MANAGER_SUBFRAME_INCOGNITO_PREFIX : 44 IDS_TASK_MANAGER_SUBFRAME_INCOGNITO_PREFIX :
24 IDS_TASK_MANAGER_SUBFRAME_PREFIX; 45 IDS_TASK_MANAGER_SUBFRAME_PREFIX;
25 46 return l10n_util::GetStringFUTF16(message_id, base::UTF8ToUTF16(name));
26 return l10n_util::GetStringFUTF16(message_id, base::UTF8ToUTF16(
27 site_instance->GetSiteURL().spec()));
28 } 47 }
29 48
30 } // namespace 49 } // namespace
31 50
32 SubframeTask::SubframeTask(content::RenderFrameHost* render_frame_host, 51 SubframeTask::SubframeTask(content::RenderFrameHost* render_frame_host,
33 content::WebContents* web_contents, 52 content::WebContents* web_contents,
34 RendererTask* main_task) 53 RendererTask* main_task)
35 : RendererTask(AdjustTitle(render_frame_host->GetSiteInstance()), 54 : RendererTask(AdjustTitle(render_frame_host->GetSiteInstance()),
36 nullptr, 55 nullptr,
37 web_contents, 56 web_contents,
(...skipping 16 matching lines...) Expand all
54 // This will be called when the favicon changes on the WebContents's main 73 // This will be called when the favicon changes on the WebContents's main
55 // frame, but this Task represents other frames, so we don't care. 74 // frame, but this Task represents other frames, so we don't care.
56 } 75 }
57 76
58 void SubframeTask::Activate() { 77 void SubframeTask::Activate() {
59 // Activate the root task. 78 // Activate the root task.
60 main_task_->Activate(); 79 main_task_->Activate();
61 } 80 }
62 81
63 } // namespace task_management 82 } // namespace task_management
OLDNEW
« no previous file with comments | « no previous file | no next file » | no next file with comments »

Powered by Google App Engine
This is Rietveld 408576698