| OLD | NEW |
| 1 // Copyright (c) 2012 The Chromium Authors. All rights reserved. | 1 // Copyright (c) 2012 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 "ui/app_list/views/app_list_view.h" | 5 #include "ui/app_list/views/app_list_view.h" |
| 6 | 6 |
| 7 #include "base/callback.h" |
| 7 #include "base/command_line.h" | 8 #include "base/command_line.h" |
| 8 #include "base/strings/string_util.h" | 9 #include "base/strings/string_util.h" |
| 9 #include "ui/app_list/app_list_constants.h" | 10 #include "ui/app_list/app_list_constants.h" |
| 10 #include "ui/app_list/app_list_model.h" | 11 #include "ui/app_list/app_list_model.h" |
| 11 #include "ui/app_list/app_list_view_delegate.h" | 12 #include "ui/app_list/app_list_view_delegate.h" |
| 12 #include "ui/app_list/pagination_model.h" | 13 #include "ui/app_list/pagination_model.h" |
| 13 #include "ui/app_list/signin_delegate.h" | 14 #include "ui/app_list/signin_delegate.h" |
| 14 #include "ui/app_list/views/app_list_background.h" | 15 #include "ui/app_list/views/app_list_background.h" |
| 15 #include "ui/app_list/views/app_list_main_view.h" | 16 #include "ui/app_list/views/app_list_main_view.h" |
| 16 #include "ui/app_list/views/search_box_view.h" | 17 #include "ui/app_list/views/search_box_view.h" |
| (...skipping 13 matching lines...) Expand all Loading... |
| 30 #include "ui/aura/root_window.h" | 31 #include "ui/aura/root_window.h" |
| 31 #if defined(OS_WIN) | 32 #if defined(OS_WIN) |
| 32 #include "ui/base/win/shell.h" | 33 #include "ui/base/win/shell.h" |
| 33 #endif | 34 #endif |
| 34 #endif | 35 #endif |
| 35 | 36 |
| 36 namespace app_list { | 37 namespace app_list { |
| 37 | 38 |
| 38 namespace { | 39 namespace { |
| 39 | 40 |
| 41 base::Closure g_next_paint_callback; |
| 42 |
| 40 // The distance between the arrow tip and edge of the anchor view. | 43 // The distance between the arrow tip and edge of the anchor view. |
| 41 const int kArrowOffset = 10; | 44 const int kArrowOffset = 10; |
| 42 | 45 |
| 43 } // namespace | 46 } // namespace |
| 44 | 47 |
| 45 //////////////////////////////////////////////////////////////////////////////// | 48 //////////////////////////////////////////////////////////////////////////////// |
| 46 // AppListView: | 49 // AppListView: |
| 47 | 50 |
| 48 AppListView::AppListView(AppListViewDelegate* delegate) | 51 AppListView::AppListView(AppListViewDelegate* delegate) |
| 49 : model_(new AppListModel), | 52 : model_(new AppListModel), |
| (...skipping 106 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 156 } | 159 } |
| 157 | 160 |
| 158 void AppListView::UpdateBounds() { | 161 void AppListView::UpdateBounds() { |
| 159 SizeToContents(); | 162 SizeToContents(); |
| 160 } | 163 } |
| 161 | 164 |
| 162 gfx::Size AppListView::GetPreferredSize() { | 165 gfx::Size AppListView::GetPreferredSize() { |
| 163 return app_list_main_view_->GetPreferredSize(); | 166 return app_list_main_view_->GetPreferredSize(); |
| 164 } | 167 } |
| 165 | 168 |
| 169 void AppListView::Paint(gfx::Canvas* canvas) { |
| 170 views::BubbleDelegateView::Paint(canvas); |
| 171 if (!g_next_paint_callback.is_null()) { |
| 172 g_next_paint_callback.Run(); |
| 173 g_next_paint_callback.Reset(); |
| 174 } |
| 175 } |
| 176 |
| 166 bool AppListView::ShouldHandleSystemCommands() const { | 177 bool AppListView::ShouldHandleSystemCommands() const { |
| 167 return true; | 178 return true; |
| 168 } | 179 } |
| 169 | 180 |
| 170 void AppListView::Prerender() { | 181 void AppListView::Prerender() { |
| 171 app_list_main_view_->Prerender(); | 182 app_list_main_view_->Prerender(); |
| 172 } | 183 } |
| 173 | 184 |
| 174 void AppListView::OnSigninStatusChanged() { | 185 void AppListView::OnSigninStatusChanged() { |
| 175 signin_view_->SetVisible(!model_->signed_in()); | 186 signin_view_->SetVisible(!model_->signed_in()); |
| 176 app_list_main_view_->SetVisible(model_->signed_in()); | 187 app_list_main_view_->SetVisible(model_->signed_in()); |
| 177 app_list_main_view_->search_box_view()->InvalidateMenu(); | 188 app_list_main_view_->search_box_view()->InvalidateMenu(); |
| 178 } | 189 } |
| 179 | 190 |
| 180 void AppListView::AddObserver(Observer* observer) { | 191 void AppListView::AddObserver(Observer* observer) { |
| 181 observers_.AddObserver(observer); | 192 observers_.AddObserver(observer); |
| 182 } | 193 } |
| 183 | 194 |
| 184 void AppListView::RemoveObserver(Observer* observer) { | 195 void AppListView::RemoveObserver(Observer* observer) { |
| 185 observers_.RemoveObserver(observer); | 196 observers_.RemoveObserver(observer); |
| 186 } | 197 } |
| 187 | 198 |
| 199 // static |
| 200 void AppListView::SetNextPaintCallback(const base::Closure& callback) { |
| 201 g_next_paint_callback = callback; |
| 202 } |
| 203 |
| 188 #if defined(OS_WIN) | 204 #if defined(OS_WIN) |
| 189 HWND AppListView::GetHWND() const { | 205 HWND AppListView::GetHWND() const { |
| 190 #if defined(USE_AURA) | 206 #if defined(USE_AURA) |
| 191 gfx::NativeWindow window = | 207 gfx::NativeWindow window = |
| 192 GetWidget()->GetTopLevelWidget()->GetNativeWindow(); | 208 GetWidget()->GetTopLevelWidget()->GetNativeWindow(); |
| 193 return window->GetRootWindow()->GetAcceleratedWidget(); | 209 return window->GetRootWindow()->GetAcceleratedWidget(); |
| 194 #else | 210 #else |
| 195 return GetWidget()->GetTopLevelWidget()->GetNativeWindow(); | 211 return GetWidget()->GetTopLevelWidget()->GetNativeWindow(); |
| 196 #endif | 212 #endif |
| 197 } | 213 } |
| (...skipping 79 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 277 | 293 |
| 278 void AppListView::OnAppListModelSigninStatusChanged() { | 294 void AppListView::OnAppListModelSigninStatusChanged() { |
| 279 OnSigninStatusChanged(); | 295 OnSigninStatusChanged(); |
| 280 } | 296 } |
| 281 | 297 |
| 282 void AppListView::OnAppListModelCurrentUserChanged() { | 298 void AppListView::OnAppListModelCurrentUserChanged() { |
| 283 OnSigninStatusChanged(); | 299 OnSigninStatusChanged(); |
| 284 } | 300 } |
| 285 | 301 |
| 286 } // namespace app_list | 302 } // namespace app_list |
| OLD | NEW |