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

Side by Side Diff: chrome/browser/ui/ash/launcher/arc_app_window.cc

Issue 2894443002: arc: Set custom icon in shelf for ARC apps. (Closed)
Patch Set: rebase Created 3 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
OLDNEW
(Empty)
1 // Copyright 2017 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/ui/ash/launcher/arc_app_window.h"
6
7 #include "base/strings/utf_string_conversions.h"
8 #include "chrome/browser/ui/app_list/arc/arc_app_icon.h"
9 #include "chrome/browser/ui/app_list/arc/arc_app_utils.h"
10 #include "chrome/browser/ui/ash/launcher/arc_app_window_launcher_controller.h"
11 #include "chrome/browser/ui/ash/launcher/arc_app_window_launcher_item_controller .h"
12 #include "components/exo/shell_surface.h"
13 #include "extensions/common/constants.h"
14 #include "ui/aura/window.h"
15 #include "ui/gfx/codec/png_codec.h"
16 #include "ui/gfx/image/image_skia_operations.h"
17 #include "ui/views/widget/widget.h"
18
19 ArcAppWindow::ArcAppWindow(int task_id,
20 const arc::ArcAppShelfId& app_shelf_id,
21 views::Widget* widget,
22 ArcAppWindowLauncherController* owner)
23 : task_id_(task_id),
24 app_shelf_id_(app_shelf_id),
25 widget_(widget),
26 owner_(owner) {}
27
28 ArcAppWindow::~ArcAppWindow() {
29 ImageDecoder::Cancel(this);
30 }
31
32 void ArcAppWindow::SetController(
33 ArcAppWindowLauncherItemController* controller) {
34 DCHECK(!controller_ || !controller);
35 controller_ = controller;
36 if (controller_)
37 controller_->UpdateLauncherItem();
38 }
39
40 void ArcAppWindow::SetFullscreenMode(FullScreenMode mode) {
41 DCHECK(mode != FullScreenMode::NOT_DEFINED);
42 fullscreen_mode_ = mode;
43 }
44
45 void ArcAppWindow::SetDescription(
46 const std::string& title,
47 const std::vector<uint8_t>& unsafe_icon_data_png) {
48 if (!title.empty())
49 GetNativeWindow()->SetTitle(base::UTF8ToUTF16(title));
50 ImageDecoder::Cancel(this);
51 if (unsafe_icon_data_png.empty()) {
52 ResetIcon();
53 return;
54 }
55
56 if (ArcAppIcon::IsSafeDecodingDisabledForTesting()) {
57 SkBitmap bitmap;
58 if (gfx::PNGCodec::Decode(&unsafe_icon_data_png[0],
59 unsafe_icon_data_png.size(), &bitmap)) {
60 OnImageDecoded(bitmap);
61 } else {
62 OnDecodeImageFailed();
63 }
64 } else {
65 ImageDecoder::Start(this, unsafe_icon_data_png);
66 }
67 }
68
69 bool ArcAppWindow::IsActive() const {
70 return widget_->IsActive() && owner_->active_task_id() == task_id_;
71 }
72
73 bool ArcAppWindow::IsMaximized() const {
74 NOTREACHED();
75 return false;
76 }
77
78 bool ArcAppWindow::IsMinimized() const {
79 NOTREACHED();
80 return false;
81 }
82
83 bool ArcAppWindow::IsFullscreen() const {
84 NOTREACHED();
85 return false;
86 }
87
88 gfx::NativeWindow ArcAppWindow::GetNativeWindow() const {
89 return widget_->GetNativeWindow();
90 }
91
92 gfx::Rect ArcAppWindow::GetRestoredBounds() const {
93 NOTREACHED();
94 return gfx::Rect();
95 }
96
97 ui::WindowShowState ArcAppWindow::GetRestoredState() const {
98 NOTREACHED();
99 return ui::SHOW_STATE_NORMAL;
100 }
101
102 gfx::Rect ArcAppWindow::GetBounds() const {
103 NOTREACHED();
104 return gfx::Rect();
105 }
106
107 void ArcAppWindow::Show() {
108 widget_->Show();
109 }
110
111 void ArcAppWindow::ShowInactive() {
112 NOTREACHED();
113 }
114
115 void ArcAppWindow::Hide() {
116 NOTREACHED();
117 }
118
119 void ArcAppWindow::Close() {
120 arc::CloseTask(task_id_);
121 }
122
123 void ArcAppWindow::Activate() {
124 widget_->Activate();
125 }
126
127 void ArcAppWindow::Deactivate() {
128 NOTREACHED();
129 }
130
131 void ArcAppWindow::Maximize() {
132 NOTREACHED();
133 }
134
135 void ArcAppWindow::Minimize() {
136 widget_->Minimize();
137 }
138
139 void ArcAppWindow::Restore() {
140 NOTREACHED();
141 }
142
143 void ArcAppWindow::SetBounds(const gfx::Rect& bounds) {
144 NOTREACHED();
145 }
146
147 void ArcAppWindow::FlashFrame(bool flash) {
148 NOTREACHED();
149 }
150
151 bool ArcAppWindow::IsAlwaysOnTop() const {
152 NOTREACHED();
153 return false;
154 }
155
156 void ArcAppWindow::SetAlwaysOnTop(bool always_on_top) {
157 NOTREACHED();
158 }
159
160 void ArcAppWindow::ResetIcon() {
161 if (icon_.isNull())
162 return;
163 icon_ = gfx::ImageSkia();
164 if (controller_)
165 controller_->UpdateLauncherItem();
166 }
167
168 void ArcAppWindow::OnImageDecoded(const SkBitmap& decoded_image) {
169 // TODO(khmel): Use aura::Window property http://crbug.com/724292
170 icon_ = gfx::ImageSkiaOperations::CreateResizedImage(
171 gfx::ImageSkia(gfx::ImageSkiaRep(decoded_image, 1.0f)),
172 skia::ImageOperations::RESIZE_BEST,
173 gfx::Size(extension_misc::EXTENSION_ICON_SMALL,
174 extension_misc::EXTENSION_ICON_SMALL));
175 if (controller_)
176 controller_->UpdateLauncherItem();
177 }
OLDNEW
« no previous file with comments | « chrome/browser/ui/ash/launcher/arc_app_window.h ('k') | chrome/browser/ui/ash/launcher/arc_app_window_launcher_controller.h » ('j') | no next file with comments »

Powered by Google App Engine
This is Rietveld 408576698