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

Side by Side Diff: chrome/browser/task_manager/providers/web_contents/panel_task.cc

Issue 2263863002: Remove implementation of Panels on OSes other than ChromeOS. (Closed) Base URL: https://chromium.googlesource.com/chromium/src.git@master
Patch Set: CR feedback Created 4 years, 4 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
OLDNEW
(Empty)
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
3 // found in the LICENSE file.
4
5 #include "chrome/browser/task_manager/providers/web_contents/panel_task.h"
6
7 #include "base/i18n/rtl.h"
8 #include "chrome/browser/profiles/profile.h"
9 #include "chrome/browser/ui/panels/panel.h"
10 #include "content/public/browser/web_contents.h"
11 #include "extensions/browser/extension_registry.h"
12 #include "ui/gfx/image/image_skia.h"
13
14 namespace task_manager {
15
16 namespace {
17
18 const gfx::ImageSkia* GetPanelIcon(Panel* panel) {
19 const gfx::Image icon = panel->GetCurrentPageIcon();
20 return !icon.IsEmpty() ? icon.ToImageSkia() : nullptr;
21 }
22
23 } // namespace
24
25 PanelTask::PanelTask(Panel* panel, content::WebContents* web_contents)
26 : RendererTask(GetCurrentPanelTitle(panel),
27 GetPanelIcon(panel),
28 web_contents,
29 web_contents->GetRenderProcessHost()),
30 panel_(panel) {
31 }
32
33 PanelTask::~PanelTask() {
34 }
35
36 void PanelTask::UpdateTitle() {
37 set_title(GetCurrentPanelTitle(panel_));
38 }
39
40 void PanelTask::UpdateFavicon() {
41 const gfx::ImageSkia* icon = GetPanelIcon(panel_);
42 set_icon(icon ? *icon : gfx::ImageSkia());
43 }
44
45 Task::Type PanelTask::GetType() const {
46 return Task::EXTENSION;
47 }
48
49 base::string16 PanelTask::GetCurrentPanelTitle(Panel* panel) const {
50 base::string16 title = panel->GetWindowTitle();
51 base::i18n::AdjustStringForLocaleDirection(&title);
52
53 extensions::ExtensionRegistry* registry =
54 extensions::ExtensionRegistry::Get(panel->profile());
55 const extensions::Extension* extension =
56 registry->enabled_extensions().GetByID(panel->extension_id());
57
58 const bool is_app = extension && extension->is_app();
59 const bool is_incognito = panel->profile()->IsOffTheRecord();
60
61 return PrefixRendererTitle(title,
62 is_app,
63 true, // is_extension.
64 is_incognito,
65 false); // is_background.
66 }
67
68 } // namespace task_manager
OLDNEW

Powered by Google App Engine
This is Rietveld 408576698