OLD | NEW |
1 // Copyright 2014 The Chromium Authors. All rights reserved. | 1 // Copyright 2014 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 "athena/activity/activity_frame_view.h" | 5 #include "athena/activity/activity_frame_view.h" |
6 | 6 |
7 #include "athena/activity/public/activity_view_model.h" | 7 #include "athena/activity/public/activity_view_model.h" |
8 #include "athena/wm/public/window_manager.h" | 8 #include "athena/wm/public/window_manager.h" |
9 #include "ui/base/hit_test.h" | 9 #include "ui/base/hit_test.h" |
10 #include "ui/gfx/canvas.h" | 10 #include "ui/gfx/canvas.h" |
(...skipping 41 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
52 icon_(new views::ImageView), | 52 icon_(new views::ImageView), |
53 in_overview_(false) { | 53 in_overview_(false) { |
54 title_->SetEnabledColor(SkColorSetA(SK_ColorBLACK, 0xe5)); | 54 title_->SetEnabledColor(SkColorSetA(SK_ColorBLACK, 0xe5)); |
55 | 55 |
56 AddChildView(title_); | 56 AddChildView(title_); |
57 AddChildView(icon_); | 57 AddChildView(icon_); |
58 | 58 |
59 UpdateWindowTitle(); | 59 UpdateWindowTitle(); |
60 UpdateWindowIcon(); | 60 UpdateWindowIcon(); |
61 | 61 |
| 62 view_model_->SetActivityView(this); |
| 63 |
62 WindowManager::Get()->AddObserver(this); | 64 WindowManager::Get()->AddObserver(this); |
63 } | 65 } |
64 | 66 |
65 ActivityFrameView::~ActivityFrameView() { | 67 ActivityFrameView::~ActivityFrameView() { |
66 WindowManager::Get()->RemoveObserver(this); | 68 WindowManager::Get()->RemoveObserver(this); |
| 69 |
| 70 // |view_model_| is already destroyed at this time. So do not attempt to reset |
| 71 // the activity-view by calling SetActivityView(nullptr); |
| 72 // http://crbug.com/427113 |
67 } | 73 } |
68 | 74 |
69 gfx::Rect ActivityFrameView::GetBoundsForClientView() const { | 75 gfx::Rect ActivityFrameView::GetBoundsForClientView() const { |
70 gfx::Rect client_bounds = bounds(); | 76 gfx::Rect client_bounds = bounds(); |
71 client_bounds.Inset(NonClientBorderInsets()); | 77 client_bounds.Inset(NonClientBorderInsets()); |
72 return client_bounds; | 78 return client_bounds; |
73 } | 79 } |
74 | 80 |
75 gfx::Rect ActivityFrameView::GetWindowBoundsForClientBounds( | 81 gfx::Rect ActivityFrameView::GetWindowBoundsForClientBounds( |
76 const gfx::Rect& client_bounds) const { | 82 const gfx::Rect& client_bounds) const { |
(...skipping 85 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
162 void ActivityFrameView::OnPaintBackground(gfx::Canvas* canvas) { | 168 void ActivityFrameView::OnPaintBackground(gfx::Canvas* canvas) { |
163 View::OnPaintBackground(canvas); | 169 View::OnPaintBackground(canvas); |
164 | 170 |
165 // Paint a border around the client view. | 171 // Paint a border around the client view. |
166 gfx::Rect border_bounds = GetLocalBounds(); | 172 gfx::Rect border_bounds = GetLocalBounds(); |
167 border_bounds.Inset(NonClientBorderInsets()); | 173 border_bounds.Inset(NonClientBorderInsets()); |
168 border_bounds.Inset(-1, -1, 0, 0); | 174 border_bounds.Inset(-1, -1, 0, 0); |
169 canvas->DrawRect(border_bounds, SkColorSetA(SK_ColorGRAY, 0x7f)); | 175 canvas->DrawRect(border_bounds, SkColorSetA(SK_ColorGRAY, 0x7f)); |
170 } | 176 } |
171 | 177 |
| 178 void ActivityFrameView::UpdateTitle() { |
| 179 UpdateWindowTitle(); |
| 180 } |
| 181 |
| 182 void ActivityFrameView::UpdateIcon() { |
| 183 UpdateWindowIcon(); |
| 184 } |
| 185 |
| 186 void ActivityFrameView::UpdateRepresentativeColor() { |
| 187 UpdateWindowTitle(); |
| 188 } |
| 189 |
172 void ActivityFrameView::OnOverviewModeEnter() { | 190 void ActivityFrameView::OnOverviewModeEnter() { |
173 view_model_->PrepareContentsForOverview(); | 191 view_model_->PrepareContentsForOverview(); |
174 in_overview_ = true; | 192 in_overview_ = true; |
175 InvalidateLayout(); | 193 InvalidateLayout(); |
176 frame_->client_view()->InvalidateLayout(); | 194 frame_->client_view()->InvalidateLayout(); |
177 frame_->GetRootView()->Layout(); | 195 frame_->GetRootView()->Layout(); |
178 SchedulePaint(); | 196 SchedulePaint(); |
179 } | 197 } |
180 | 198 |
181 void ActivityFrameView::OnOverviewModeExit() { | 199 void ActivityFrameView::OnOverviewModeExit() { |
(...skipping 23 matching lines...) Expand all Loading... |
205 return in_overview_ ? kOverviewBorderThickness : 0; | 223 return in_overview_ ? kOverviewBorderThickness : 0; |
206 } | 224 } |
207 | 225 |
208 int ActivityFrameView::NonClientTopBorderHeight() const { | 226 int ActivityFrameView::NonClientTopBorderHeight() const { |
209 if (frame_->IsFullscreen() || !view_model_->UsesFrame()) | 227 if (frame_->IsFullscreen() || !view_model_->UsesFrame()) |
210 return in_overview_ ? kOverviewShortTitleHeight : 0; | 228 return in_overview_ ? kOverviewShortTitleHeight : 0; |
211 return in_overview_ ? kOverviewTitleHeight : kDefaultTitleHeight; | 229 return in_overview_ ? kOverviewTitleHeight : kDefaultTitleHeight; |
212 } | 230 } |
213 | 231 |
214 } // namespace athena | 232 } // namespace athena |
OLD | NEW |