OLD | NEW |
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" |
(...skipping 143 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
154 | 154 |
155 void ToolbarButton::GetAccessibleState(ui::AXViewState* state) { | 155 void ToolbarButton::GetAccessibleState(ui::AXViewState* state) { |
156 CustomButton::GetAccessibleState(state); | 156 CustomButton::GetAccessibleState(state); |
157 state->role = ui::AX_ROLE_BUTTON_DROP_DOWN; | 157 state->role = ui::AX_ROLE_BUTTON_DROP_DOWN; |
158 state->default_action = l10n_util::GetStringUTF16(IDS_APP_ACCACTION_PRESS); | 158 state->default_action = l10n_util::GetStringUTF16(IDS_APP_ACCACTION_PRESS); |
159 state->AddStateFlag(ui::AX_STATE_HASPOPUP); | 159 state->AddStateFlag(ui::AX_STATE_HASPOPUP); |
160 } | 160 } |
161 | 161 |
162 scoped_ptr<views::LabelButtonBorder> | 162 scoped_ptr<views::LabelButtonBorder> |
163 ToolbarButton::CreateDefaultBorder() const { | 163 ToolbarButton::CreateDefaultBorder() const { |
164 scoped_ptr<views::LabelButtonBorder> border; | 164 scoped_ptr<views::LabelButtonBorder> border = |
165 if (ui::MaterialDesignController::IsModeMaterial()) { | 165 views::LabelButton::CreateDefaultBorder(); |
166 #if defined(OS_CHROMEOS) | |
167 border.reset(new views::LabelButtonBorder()); | |
168 border->set_insets(views::LabelButtonAssetBorder::GetDefaultInsetsForStyle( | |
169 Button::STYLE_TEXTBUTTON)); | |
170 #else | |
171 scoped_ptr<views::LabelButtonAssetBorder> asset_border( | |
172 new views::LabelButtonAssetBorder(Button::STYLE_TEXTBUTTON)); | |
173 // The material design spec does not include a visual effect for the | |
174 // STATE_HOVERED button state so we have to remove the default one added by | |
175 // LabelButtonAssetBorder. | |
176 asset_border->SetPainter(false, Button::STATE_HOVERED, nullptr); | |
177 border = asset_border.Pass(); | |
178 #endif | |
179 } else { | |
180 border.reset(new views::LabelButtonAssetBorder(Button::STYLE_TEXTBUTTON)); | |
181 } | |
182 | 166 |
183 ui::ThemeProvider* provider = GetThemeProvider(); | 167 ui::ThemeProvider* provider = GetThemeProvider(); |
184 if (provider && provider->UsingSystemTheme()) { | 168 if (provider && provider->UsingSystemTheme()) { |
185 // Theme provided insets. | 169 // Theme provided insets. |
186 int inset = provider->GetDisplayProperty( | 170 int inset = provider->GetDisplayProperty( |
187 ThemeProperties::PROPERTY_TOOLBAR_BUTTON_BORDER_INSET); | 171 ThemeProperties::PROPERTY_TOOLBAR_BUTTON_BORDER_INSET); |
188 border->set_insets(gfx::Insets(inset, inset, inset, inset)); | 172 border->set_insets(gfx::Insets(inset, inset, inset, inset)); |
189 } | 173 } |
190 | 174 |
191 return border.Pass(); | 175 return border.Pass(); |
(...skipping 101 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
293 SetMouseHandler(NULL); | 277 SetMouseHandler(NULL); |
294 | 278 |
295 // Set the state back to normal after the drop down menu is closed. | 279 // Set the state back to normal after the drop down menu is closed. |
296 if (state_ != STATE_DISABLED) | 280 if (state_ != STATE_DISABLED) |
297 SetState(STATE_NORMAL); | 281 SetState(STATE_NORMAL); |
298 } | 282 } |
299 | 283 |
300 const char* ToolbarButton::GetClassName() const { | 284 const char* ToolbarButton::GetClassName() const { |
301 return "ToolbarButton"; | 285 return "ToolbarButton"; |
302 } | 286 } |
OLD | NEW |