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

Side by Side Diff: chrome/browser/ui/views/toolbar/toolbar_button.cc

Issue 1492423003: Rejigger ThemeService: move exposure of ThemeProvider interface to a (Closed) Base URL: https://chromium.googlesource.com/chromium/src.git@master
Patch Set: respond to comments Created 5 years 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 2013 The Chromium Authors. All rights reserved. 1 // Copyright 2013 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 "chrome/browser/ui/views/toolbar/toolbar_button.h" 5 #include "chrome/browser/ui/views/toolbar/toolbar_button.h"
6 6
7 #include "base/bind.h" 7 #include "base/bind.h"
8 #include "base/location.h" 8 #include "base/location.h"
9 #include "base/single_thread_task_runner.h" 9 #include "base/single_thread_task_runner.h"
10 #include "base/thread_task_runner_handle.h" 10 #include "base/thread_task_runner_handle.h"
11 #include "chrome/browser/profiles/profile.h"
12 #include "chrome/browser/themes/theme_service.h"
13 #include "chrome/browser/themes/theme_service_factory.h"
11 #include "chrome/browser/ui/views/layout_constants.h" 14 #include "chrome/browser/ui/views/layout_constants.h"
12 #include "chrome/browser/ui/views/location_bar/location_bar_view.h" 15 #include "chrome/browser/ui/views/location_bar/location_bar_view.h"
13 #include "ui/accessibility/ax_view_state.h" 16 #include "ui/accessibility/ax_view_state.h"
14 #include "ui/base/l10n/l10n_util.h" 17 #include "ui/base/l10n/l10n_util.h"
15 #include "ui/base/models/menu_model.h" 18 #include "ui/base/models/menu_model.h"
16 #include "ui/base/resource/material_design/material_design_controller.h" 19 #include "ui/base/resource/material_design/material_design_controller.h"
17 #include "ui/base/theme_provider.h" 20 #include "ui/base/theme_provider.h"
18 #include "ui/gfx/display.h" 21 #include "ui/gfx/display.h"
19 #include "ui/gfx/screen.h" 22 #include "ui/gfx/screen.h"
20 #include "ui/strings/grit/ui_strings.h" 23 #include "ui/strings/grit/ui_strings.h"
21 #include "ui/views/animation/ink_drop_animation_controller.h" 24 #include "ui/views/animation/ink_drop_animation_controller.h"
22 #include "ui/views/animation/ink_drop_animation_controller_factory.h" 25 #include "ui/views/animation/ink_drop_animation_controller_factory.h"
23 #include "ui/views/controls/button/label_button_border.h" 26 #include "ui/views/controls/button/label_button_border.h"
24 #include "ui/views/controls/menu/menu_item_view.h" 27 #include "ui/views/controls/menu/menu_item_view.h"
25 #include "ui/views/controls/menu/menu_model_adapter.h" 28 #include "ui/views/controls/menu/menu_model_adapter.h"
26 #include "ui/views/controls/menu/menu_runner.h" 29 #include "ui/views/controls/menu/menu_runner.h"
27 #include "ui/views/widget/widget.h" 30 #include "ui/views/widget/widget.h"
28 31
29 ToolbarButton::ToolbarButton(views::ButtonListener* listener, 32 ToolbarButton::ToolbarButton(Profile* profile,
33 views::ButtonListener* listener,
30 ui::MenuModel* model) 34 ui::MenuModel* model)
31 : views::LabelButton(listener, base::string16()), 35 : views::LabelButton(listener, base::string16()),
36 profile_(profile),
32 model_(model), 37 model_(model),
33 menu_showing_(false), 38 menu_showing_(false),
34 y_position_on_lbuttondown_(0), 39 y_position_on_lbuttondown_(0),
35 ink_drop_animation_controller_( 40 ink_drop_animation_controller_(
36 views::InkDropAnimationControllerFactory:: 41 views::InkDropAnimationControllerFactory::
37 CreateInkDropAnimationController(this)), 42 CreateInkDropAnimationController(this)),
38 show_menu_factory_(this) { 43 show_menu_factory_(this) {
39 set_context_menu_controller(this); 44 set_context_menu_controller(this);
40 45
41 const int kInkDropLargeSize = 32; 46 const int kInkDropLargeSize = 32;
(...skipping 152 matching lines...) Expand 10 before | Expand all | Expand 10 after
194 state->role = ui::AX_ROLE_BUTTON_DROP_DOWN; 199 state->role = ui::AX_ROLE_BUTTON_DROP_DOWN;
195 state->default_action = l10n_util::GetStringUTF16(IDS_APP_ACCACTION_PRESS); 200 state->default_action = l10n_util::GetStringUTF16(IDS_APP_ACCACTION_PRESS);
196 state->AddStateFlag(ui::AX_STATE_HASPOPUP); 201 state->AddStateFlag(ui::AX_STATE_HASPOPUP);
197 } 202 }
198 203
199 scoped_ptr<views::LabelButtonBorder> 204 scoped_ptr<views::LabelButtonBorder>
200 ToolbarButton::CreateDefaultBorder() const { 205 ToolbarButton::CreateDefaultBorder() const {
201 scoped_ptr<views::LabelButtonBorder> border = 206 scoped_ptr<views::LabelButtonBorder> border =
202 views::LabelButton::CreateDefaultBorder(); 207 views::LabelButton::CreateDefaultBorder();
203 208
204 const ui::ThemeProvider* provider = GetThemeProvider(); 209 const ThemeService* theme_service =
205 if (provider && provider->UsingSystemTheme()) 210 ThemeServiceFactory::GetForProfile(profile_);
Peter Kasting 2015/12/09 01:31:59 Nit: Can just inline into next line
Evan Stade 2015/12/09 01:57:06 Done.
211 if (theme_service->UsingSystemTheme())
206 border->set_insets(GetLayoutInsets(TOOLBAR_BUTTON)); 212 border->set_insets(GetLayoutInsets(TOOLBAR_BUTTON));
207 213
208 return border.Pass(); 214 return border.Pass();
209 } 215 }
210 216
211 void ToolbarButton::ShowContextMenuForView(View* source, 217 void ToolbarButton::ShowContextMenuForView(View* source,
212 const gfx::Point& point, 218 const gfx::Point& point,
213 ui::MenuSourceType source_type) { 219 ui::MenuSourceType source_type) {
214 if (!enabled()) 220 if (!enabled())
215 return; 221 return;
(...skipping 130 matching lines...) Expand 10 before | Expand all | Expand 10 after
346 SetState(STATE_NORMAL); 352 SetState(STATE_NORMAL);
347 } 353 }
348 354
349 const char* ToolbarButton::GetClassName() const { 355 const char* ToolbarButton::GetClassName() const {
350 return "ToolbarButton"; 356 return "ToolbarButton";
351 } 357 }
352 358
353 gfx::Point ToolbarButton::CalculateInkDropCenter() const { 359 gfx::Point ToolbarButton::CalculateInkDropCenter() const {
354 return GetLocalBounds().CenterPoint(); 360 return GetLocalBounds().CenterPoint();
355 } 361 }
OLDNEW

Powered by Google App Engine
This is Rietveld 408576698