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

Side by Side Diff: ui/app_list/views/app_list_view.cc

Issue 302803002: Refactor app list so AppsGridView owns the PaginationModel. (Closed) Base URL: svn://svn.chromium.org/chrome/trunk/src
Patch Set: Respond to review comments (tapted and xiyuan). Created 6 years, 6 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 | Annotate | Revision Log
OLDNEW
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 <algorithm> 7 #include <algorithm>
8 8
9 #include "base/command_line.h" 9 #include "base/command_line.h"
10 #include "base/strings/string_util.h" 10 #include "base/strings/string_util.h"
11 #include "base/win/windows_version.h" 11 #include "base/win/windows_version.h"
12 #include "ui/app_list/app_list_constants.h" 12 #include "ui/app_list/app_list_constants.h"
13 #include "ui/app_list/app_list_model.h" 13 #include "ui/app_list/app_list_model.h"
14 #include "ui/app_list/app_list_view_delegate.h" 14 #include "ui/app_list/app_list_view_delegate.h"
15 #include "ui/app_list/pagination_model.h"
16 #include "ui/app_list/signin_delegate.h" 15 #include "ui/app_list/signin_delegate.h"
17 #include "ui/app_list/speech_ui_model.h" 16 #include "ui/app_list/speech_ui_model.h"
18 #include "ui/app_list/views/app_list_background.h" 17 #include "ui/app_list/views/app_list_background.h"
19 #include "ui/app_list/views/app_list_folder_view.h" 18 #include "ui/app_list/views/app_list_folder_view.h"
20 #include "ui/app_list/views/app_list_main_view.h" 19 #include "ui/app_list/views/app_list_main_view.h"
21 #include "ui/app_list/views/app_list_view_observer.h" 20 #include "ui/app_list/views/app_list_view_observer.h"
22 #include "ui/app_list/views/apps_container_view.h" 21 #include "ui/app_list/views/apps_container_view.h"
23 #include "ui/app_list/views/contents_view.h" 22 #include "ui/app_list/views/contents_view.h"
24 #include "ui/app_list/views/search_box_view.h" 23 #include "ui/app_list/views/search_box_view.h"
25 #include "ui/app_list/views/signin_view.h" 24 #include "ui/app_list/views/signin_view.h"
(...skipping 135 matching lines...) Expand 10 before | Expand all | Expand 10 after
161 AppListView::~AppListView() { 160 AppListView::~AppListView() {
162 delegate_->GetSpeechUI()->RemoveObserver(this); 161 delegate_->GetSpeechUI()->RemoveObserver(this);
163 delegate_->RemoveObserver(this); 162 delegate_->RemoveObserver(this);
164 animation_observer_.reset(); 163 animation_observer_.reset();
165 // Remove child views first to ensure no remaining dependencies on delegate_. 164 // Remove child views first to ensure no remaining dependencies on delegate_.
166 RemoveAllChildViews(true); 165 RemoveAllChildViews(true);
167 } 166 }
168 167
169 void AppListView::InitAsBubbleAttachedToAnchor( 168 void AppListView::InitAsBubbleAttachedToAnchor(
170 gfx::NativeView parent, 169 gfx::NativeView parent,
171 PaginationModel* pagination_model,
172 views::View* anchor, 170 views::View* anchor,
173 const gfx::Vector2d& anchor_offset, 171 const gfx::Vector2d& anchor_offset,
174 views::BubbleBorder::Arrow arrow, 172 views::BubbleBorder::Arrow arrow,
175 bool border_accepts_events) { 173 bool border_accepts_events) {
176 SetAnchorView(anchor); 174 SetAnchorView(anchor);
177 InitAsBubbleInternal( 175 InitAsBubbleInternal(parent, arrow, border_accepts_events, anchor_offset);
178 parent, pagination_model, arrow, border_accepts_events, anchor_offset);
179 } 176 }
180 177
181 void AppListView::InitAsBubbleAtFixedLocation( 178 void AppListView::InitAsBubbleAtFixedLocation(
182 gfx::NativeView parent, 179 gfx::NativeView parent,
183 PaginationModel* pagination_model,
184 const gfx::Point& anchor_point_in_screen, 180 const gfx::Point& anchor_point_in_screen,
185 views::BubbleBorder::Arrow arrow, 181 views::BubbleBorder::Arrow arrow,
186 bool border_accepts_events) { 182 bool border_accepts_events) {
187 SetAnchorView(NULL); 183 SetAnchorView(NULL);
188 SetAnchorRect(gfx::Rect(anchor_point_in_screen, gfx::Size())); 184 SetAnchorRect(gfx::Rect(anchor_point_in_screen, gfx::Size()));
189 InitAsBubbleInternal( 185 InitAsBubbleInternal(parent, arrow, border_accepts_events, gfx::Vector2d());
190 parent, pagination_model, arrow, border_accepts_events, gfx::Vector2d());
191 } 186 }
192 187
193 void AppListView::SetBubbleArrow(views::BubbleBorder::Arrow arrow) { 188 void AppListView::SetBubbleArrow(views::BubbleBorder::Arrow arrow) {
194 GetBubbleFrameView()->bubble_border()->set_arrow(arrow); 189 GetBubbleFrameView()->bubble_border()->set_arrow(arrow);
195 SizeToContents(); // Recalcuates with new border. 190 SizeToContents(); // Recalcuates with new border.
196 GetBubbleFrameView()->SchedulePaint(); 191 GetBubbleFrameView()->SchedulePaint();
197 } 192 }
198 193
199 void AppListView::SetAnchorPoint(const gfx::Point& anchor_point) { 194 void AppListView::SetAnchorPoint(const gfx::Point& anchor_point) {
200 SetAnchorRect(gfx::Rect(anchor_point, gfx::Size())); 195 SetAnchorRect(gfx::Rect(anchor_point, gfx::Size()));
(...skipping 85 matching lines...) Expand 10 before | Expand all | Expand 10 after
286 #if defined(USE_AURA) 281 #if defined(USE_AURA)
287 gfx::NativeWindow window = 282 gfx::NativeWindow window =
288 GetWidget()->GetTopLevelWidget()->GetNativeWindow(); 283 GetWidget()->GetTopLevelWidget()->GetNativeWindow();
289 return window->GetHost()->GetAcceleratedWidget(); 284 return window->GetHost()->GetAcceleratedWidget();
290 #else 285 #else
291 return GetWidget()->GetTopLevelWidget()->GetNativeWindow(); 286 return GetWidget()->GetTopLevelWidget()->GetNativeWindow();
292 #endif 287 #endif
293 } 288 }
294 #endif 289 #endif
295 290
291 PaginationModel* AppListView::GetAppsPaginationModel() {
292 return app_list_main_view_->contents_view()
293 ->apps_container_view()
294 ->apps_grid_view()
295 ->pagination_model();
xiyuan 2014/06/02 17:02:08 This repeats many times. Why not moving relevant G
Matt Giuca 2014/06/03 01:52:36 I really don't want to expose GetAppsPaginationMod
296 }
297
296 void AppListView::InitAsBubbleInternal(gfx::NativeView parent, 298 void AppListView::InitAsBubbleInternal(gfx::NativeView parent,
297 PaginationModel* pagination_model,
298 views::BubbleBorder::Arrow arrow, 299 views::BubbleBorder::Arrow arrow,
299 bool border_accepts_events, 300 bool border_accepts_events,
300 const gfx::Vector2d& anchor_offset) { 301 const gfx::Vector2d& anchor_offset) {
301 app_list_main_view_ = new AppListMainView(delegate_.get(), 302 app_list_main_view_ = new AppListMainView(delegate_.get(), parent);
302 pagination_model,
303 parent);
304 AddChildView(app_list_main_view_); 303 AddChildView(app_list_main_view_);
305 #if defined(USE_AURA) 304 #if defined(USE_AURA)
306 app_list_main_view_->SetPaintToLayer(true); 305 app_list_main_view_->SetPaintToLayer(true);
307 app_list_main_view_->SetFillsBoundsOpaquely(false); 306 app_list_main_view_->SetFillsBoundsOpaquely(false);
308 app_list_main_view_->layer()->SetMasksToBounds(true); 307 app_list_main_view_->layer()->SetMasksToBounds(true);
309 #endif 308 #endif
310 309
311 signin_view_ = 310 signin_view_ =
312 new SigninView(delegate_->GetSigninDelegate(), 311 new SigninView(delegate_->GetSigninDelegate(),
313 app_list_main_view_->GetPreferredSize().width()); 312 app_list_main_view_->GetPreferredSize().width());
(...skipping 248 matching lines...) Expand 10 before | Expand all | Expand 10 after
562 #else 561 #else
563 speech_view_->SetVisible(recognizing); 562 speech_view_->SetVisible(recognizing);
564 app_list_main_view_->SetVisible(!recognizing); 563 app_list_main_view_->SetVisible(!recognizing);
565 564
566 // Needs to schedule paint of AppListView itself, to repaint the background. 565 // Needs to schedule paint of AppListView itself, to repaint the background.
567 GetBubbleFrameView()->SchedulePaint(); 566 GetBubbleFrameView()->SchedulePaint();
568 #endif 567 #endif
569 } 568 }
570 569
571 } // namespace app_list 570 } // namespace app_list
OLDNEW

Powered by Google App Engine
This is Rietveld 408576698