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

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

Issue 2934513004: Changed static variable flag to be a bool in the anon namespace. (Closed)
Patch Set: Created 3 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
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/search_box_view.h" 5 #include "ui/app_list/views/search_box_view.h"
6 6
7 #include <algorithm> 7 #include <algorithm>
8 8
9 #include "base/macros.h" 9 #include "base/macros.h"
10 #include "base/memory/ptr_util.h" 10 #include "base/memory/ptr_util.h"
(...skipping 35 matching lines...) Expand 10 before | Expand all | Expand 10 after
46 const int kInnerPadding = 24; 46 const int kInnerPadding = 24;
47 const int kPreferredWidth = 360; 47 const int kPreferredWidth = 360;
48 const int kPreferredWidthFullscreen = 544; 48 const int kPreferredWidthFullscreen = 544;
49 const int kPreferredHeight = 48; 49 const int kPreferredHeight = 48;
50 50
51 const SkColor kHintTextColor = SkColorSetRGB(0xA0, 0xA0, 0xA0); 51 const SkColor kHintTextColor = SkColorSetRGB(0xA0, 0xA0, 0xA0);
52 52
53 const int kBackgroundBorderCornerRadius = 2; 53 const int kBackgroundBorderCornerRadius = 2;
54 const int kBackgroundBorderCornerRadiusFullscreen = 20; 54 const int kBackgroundBorderCornerRadiusFullscreen = 20;
55 55
56 bool IsFullscreenAppListEnabled() { 56 // The switch that is checked to determine if the fullscreen app list feature is
57 // enabled.
58 bool is_fullscreen_app_list_enabled;
59
60 void IsFullscreenAppListEnabled() {
57 // Cache this value to avoid repeated lookup. 61 // Cache this value to avoid repeated lookup.
58 static bool cached_value = features::IsFullscreenAppListEnabled(); 62 is_fullscreen_app_list_enabled = features::IsFullscreenAppListEnabled();
59 return cached_value;
60 } 63 }
61 64
62 // A background that paints a solid white rounded rect with a thin grey border. 65 // A background that paints a solid white rounded rect with a thin grey border.
63 class SearchBoxBackground : public views::Background { 66 class SearchBoxBackground : public views::Background {
64 public: 67 public:
65 SearchBoxBackground() 68 SearchBoxBackground()
66 : background_border_corner_radius_( 69 : background_border_corner_radius_(
67 IsFullscreenAppListEnabled() 70 is_fullscreen_app_list_enabled
68 ? kBackgroundBorderCornerRadiusFullscreen 71 ? kBackgroundBorderCornerRadiusFullscreen
69 : kBackgroundBorderCornerRadius) {} 72 : kBackgroundBorderCornerRadius) {}
70 ~SearchBoxBackground() override {} 73 ~SearchBoxBackground() override {}
71 74
72 private: 75 private:
73 // views::Background overrides: 76 // views::Background overrides:
74 void Paint(gfx::Canvas* canvas, views::View* view) const override { 77 void Paint(gfx::Canvas* canvas, views::View* view) const override {
75 gfx::Rect bounds = view->GetContentsBounds(); 78 gfx::Rect bounds = view->GetContentsBounds();
76 79
77 cc::PaintFlags flags; 80 cc::PaintFlags flags;
(...skipping 58 matching lines...) Expand 10 before | Expand all | Expand 10 after
136 : delegate_(delegate), 139 : delegate_(delegate),
137 view_delegate_(view_delegate), 140 view_delegate_(view_delegate),
138 model_(NULL), 141 model_(NULL),
139 content_container_(new views::View), 142 content_container_(new views::View),
140 back_button_(NULL), 143 back_button_(NULL),
141 speech_button_(NULL), 144 speech_button_(NULL),
142 search_box_(new views::Textfield), 145 search_box_(new views::Textfield),
143 contents_view_(NULL), 146 contents_view_(NULL),
144 app_list_view_(app_list_view), 147 app_list_view_(app_list_view),
145 focused_view_(FOCUS_SEARCH_BOX) { 148 focused_view_(FOCUS_SEARCH_BOX) {
149 IsFullscreenAppListEnabled();
146 SetLayoutManager(new views::FillLayout); 150 SetLayoutManager(new views::FillLayout);
147 SetPreferredSize(gfx::Size(IsFullscreenAppListEnabled() 151 SetPreferredSize(gfx::Size(is_fullscreen_app_list_enabled
148 ? kPreferredWidthFullscreen 152 ? kPreferredWidthFullscreen
149 : kPreferredWidth, 153 : kPreferredWidth,
150 kPreferredHeight)); 154 kPreferredHeight));
151 AddChildView(content_container_); 155 AddChildView(content_container_);
152 156
153 SetShadow(GetShadowForZHeight(2)); 157 SetShadow(GetShadowForZHeight(2));
154 back_button_ = new SearchBoxImageButton(this); 158 back_button_ = new SearchBoxImageButton(this);
155 ui::ResourceBundle& rb = ui::ResourceBundle::GetSharedInstance(); 159 ui::ResourceBundle& rb = ui::ResourceBundle::GetSharedInstance();
156 back_button_->SetImage(views::ImageButton::STATE_NORMAL, 160 back_button_->SetImage(views::ImageButton::STATE_NORMAL,
157 rb.GetImageSkiaNamed(IDR_APP_LIST_FOLDER_BACK_NORMAL)); 161 rb.GetImageSkiaNamed(IDR_APP_LIST_FOLDER_BACK_NORMAL));
(...skipping 181 matching lines...) Expand 10 before | Expand all | Expand 10 after
339 DCHECK(delegate_); 343 DCHECK(delegate_);
340 delegate_->QueryChanged(this); 344 delegate_->QueryChanged(this);
341 } 345 }
342 346
343 void SearchBoxView::ContentsChanged(views::Textfield* sender, 347 void SearchBoxView::ContentsChanged(views::Textfield* sender,
344 const base::string16& new_contents) { 348 const base::string16& new_contents) {
345 UpdateModel(); 349 UpdateModel();
346 view_delegate_->AutoLaunchCanceled(); 350 view_delegate_->AutoLaunchCanceled();
347 NotifyQueryChanged(); 351 NotifyQueryChanged();
348 352
349 if (IsFullscreenAppListEnabled() && !app_list_view_->is_fullscreen()) { 353 if (is_fullscreen_app_list_enabled && !app_list_view_->is_fullscreen()) {
350 // If the app list is in the peeking state, switch it to fullscreen. 354 // If the app list is in the peeking state, switch it to fullscreen.
351 app_list_view_->SetState(AppListView::FULLSCREEN); 355 app_list_view_->SetState(AppListView::FULLSCREEN);
352 } 356 }
353 } 357 }
354 358
355 bool SearchBoxView::HandleKeyEvent(views::Textfield* sender, 359 bool SearchBoxView::HandleKeyEvent(views::Textfield* sender,
356 const ui::KeyEvent& key_event) { 360 const ui::KeyEvent& key_event) {
357 if (key_event.type() == ui::ET_KEY_PRESSED) { 361 if (key_event.type() == ui::ET_KEY_PRESSED) {
358 if (key_event.key_code() == ui::VKEY_TAB && 362 if (key_event.key_code() == ui::VKEY_TAB &&
359 focused_view_ != FOCUS_CONTENTS_VIEW && 363 focused_view_ != FOCUS_CONTENTS_VIEW &&
(...skipping 98 matching lines...) Expand 10 before | Expand all | Expand 10 after
458 NotifyQueryChanged(); 462 NotifyQueryChanged();
459 } 463 }
460 464
461 void SearchBoxView::OnSpeechRecognitionStateChanged( 465 void SearchBoxView::OnSpeechRecognitionStateChanged(
462 SpeechRecognitionState new_state) { 466 SpeechRecognitionState new_state) {
463 SpeechRecognitionButtonPropChanged(); 467 SpeechRecognitionButtonPropChanged();
464 SchedulePaint(); 468 SchedulePaint();
465 } 469 }
466 470
467 } // namespace app_list 471 } // namespace app_list
OLDNEW
« ui/app_list/views/app_list_view.cc ('K') | « ui/app_list/views/app_list_view.cc ('k') | no next file » | no next file with comments »

Powered by Google App Engine
This is Rietveld 408576698