Chromium Code Reviews| 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 109 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... | |
| 159 } | 162 } |
| 160 | 163 |
| 161 void AppListView::UpdateBounds() { | 164 void AppListView::UpdateBounds() { |
| 162 SizeToContents(); | 165 SizeToContents(); |
| 163 } | 166 } |
| 164 | 167 |
| 165 gfx::Size AppListView::GetPreferredSize() { | 168 gfx::Size AppListView::GetPreferredSize() { |
| 166 return app_list_main_view_->GetPreferredSize(); | 169 return app_list_main_view_->GetPreferredSize(); |
| 167 } | 170 } |
| 168 | 171 |
| 172 void AppListView::Paint(gfx::Canvas* canvas) { | |
| 173 views::BubbleDelegateView::Paint(canvas); | |
| 174 if (!g_next_paint_callback.is_null()) { | |
| 175 g_next_paint_callback.Run(); | |
| 176 g_next_paint_callback = base::Closure(); | |
|
benwells
2013/08/21 04:54:09
Should this be g_next_paint_callback.Reset()?
koz (OOO until 15th September)
2013/08/21 06:54:32
Done.
| |
| 177 } | |
| 178 } | |
| 179 | |
| 169 bool AppListView::ShouldHandleSystemCommands() const { | 180 bool AppListView::ShouldHandleSystemCommands() const { |
| 170 return true; | 181 return true; |
| 171 } | 182 } |
| 172 | 183 |
| 173 void AppListView::Prerender() { | 184 void AppListView::Prerender() { |
| 174 app_list_main_view_->Prerender(); | 185 app_list_main_view_->Prerender(); |
| 175 } | 186 } |
| 176 | 187 |
| 177 void AppListView::OnSigninStatusChanged() { | 188 void AppListView::OnSigninStatusChanged() { |
| 178 const bool needs_signin = | 189 const bool needs_signin = |
| 179 GetSigninDelegate() && GetSigninDelegate()->NeedSignin(); | 190 GetSigninDelegate() && GetSigninDelegate()->NeedSignin(); |
| 180 | 191 |
| 181 signin_view_->SetVisible(needs_signin); | 192 signin_view_->SetVisible(needs_signin); |
| 182 app_list_main_view_->SetVisible(!needs_signin); | 193 app_list_main_view_->SetVisible(!needs_signin); |
| 183 app_list_main_view_->search_box_view()->InvalidateMenu(); | 194 app_list_main_view_->search_box_view()->InvalidateMenu(); |
| 184 } | 195 } |
| 185 | 196 |
| 197 // static | |
| 198 void AppListView::SetAppListNextPaintCallback(const base::Closure& callback) { | |
| 199 g_next_paint_callback = callback; | |
| 200 } | |
| 201 | |
| 186 #if defined(OS_WIN) | 202 #if defined(OS_WIN) |
| 187 HWND AppListView::GetHWND() const { | 203 HWND AppListView::GetHWND() const { |
| 188 #if defined(USE_AURA) | 204 #if defined(USE_AURA) |
| 189 gfx::NativeWindow window = | 205 gfx::NativeWindow window = |
| 190 GetWidget()->GetTopLevelWidget()->GetNativeWindow(); | 206 GetWidget()->GetTopLevelWidget()->GetNativeWindow(); |
| 191 return window->GetRootWindow()->GetAcceleratedWidget(); | 207 return window->GetRootWindow()->GetAcceleratedWidget(); |
| 192 #else | 208 #else |
| 193 return GetWidget()->GetTopLevelWidget()->GetNativeWindow(); | 209 return GetWidget()->GetTopLevelWidget()->GetNativeWindow(); |
| 194 #endif | 210 #endif |
| 195 } | 211 } |
| (...skipping 74 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... | |
| 270 | 286 |
| 271 void AppListView::OnSigninSuccess() { | 287 void AppListView::OnSigninSuccess() { |
| 272 OnSigninStatusChanged(); | 288 OnSigninStatusChanged(); |
| 273 } | 289 } |
| 274 | 290 |
| 275 SigninDelegate* AppListView::GetSigninDelegate() { | 291 SigninDelegate* AppListView::GetSigninDelegate() { |
| 276 return delegate_ ? delegate_->GetSigninDelegate() : NULL; | 292 return delegate_ ? delegate_->GetSigninDelegate() : NULL; |
| 277 } | 293 } |
| 278 | 294 |
| 279 } // namespace app_list | 295 } // namespace app_list |
| OLD | NEW |