| 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/app_menu.h" | 5 #include "chrome/browser/ui/views/toolbar/app_menu.h" |
| 6 | 6 |
| 7 #include <stdint.h> | 7 #include <stdint.h> |
| 8 | 8 |
| 9 #include <algorithm> | 9 #include <algorithm> |
| 10 #include <cmath> | 10 #include <cmath> |
| (...skipping 27 matching lines...) Expand all Loading... |
| 38 #include "content/public/browser/host_zoom_map.h" | 38 #include "content/public/browser/host_zoom_map.h" |
| 39 #include "content/public/browser/notification_observer.h" | 39 #include "content/public/browser/notification_observer.h" |
| 40 #include "content/public/browser/notification_registrar.h" | 40 #include "content/public/browser/notification_registrar.h" |
| 41 #include "content/public/browser/notification_source.h" | 41 #include "content/public/browser/notification_source.h" |
| 42 #include "content/public/browser/notification_types.h" | 42 #include "content/public/browser/notification_types.h" |
| 43 #include "content/public/browser/user_metrics.h" | 43 #include "content/public/browser/user_metrics.h" |
| 44 #include "content/public/browser/web_contents.h" | 44 #include "content/public/browser/web_contents.h" |
| 45 #include "extensions/common/feature_switch.h" | 45 #include "extensions/common/feature_switch.h" |
| 46 #include "third_party/skia/include/core/SkCanvas.h" | 46 #include "third_party/skia/include/core/SkCanvas.h" |
| 47 #include "third_party/skia/include/core/SkPaint.h" | 47 #include "third_party/skia/include/core/SkPaint.h" |
| 48 #include "ui/accessibility/ax_view_state.h" | 48 #include "ui/accessibility/ax_node_data.h" |
| 49 #include "ui/base/l10n/l10n_util.h" | 49 #include "ui/base/l10n/l10n_util.h" |
| 50 #include "ui/base/layout.h" | 50 #include "ui/base/layout.h" |
| 51 #include "ui/base/resource/resource_bundle.h" | 51 #include "ui/base/resource/resource_bundle.h" |
| 52 #include "ui/gfx/canvas.h" | 52 #include "ui/gfx/canvas.h" |
| 53 #include "ui/gfx/font_list.h" | 53 #include "ui/gfx/font_list.h" |
| 54 #include "ui/gfx/image/image.h" | 54 #include "ui/gfx/image/image.h" |
| 55 #include "ui/gfx/image/image_skia_source.h" | 55 #include "ui/gfx/image/image_skia_source.h" |
| 56 #include "ui/gfx/scoped_canvas.h" | 56 #include "ui/gfx/scoped_canvas.h" |
| 57 #include "ui/gfx/skia_util.h" | 57 #include "ui/gfx/skia_util.h" |
| 58 #include "ui/gfx/text_utils.h" | 58 #include "ui/gfx/text_utils.h" |
| (...skipping 58 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 117 // Overridden from ImageButton. | 117 // Overridden from ImageButton. |
| 118 gfx::Size GetPreferredSize() const override { | 118 gfx::Size GetPreferredSize() const override { |
| 119 gfx::Size pref = ImageButton::GetPreferredSize(); | 119 gfx::Size pref = ImageButton::GetPreferredSize(); |
| 120 if (border()) { | 120 if (border()) { |
| 121 gfx::Insets insets = border()->GetInsets(); | 121 gfx::Insets insets = border()->GetInsets(); |
| 122 pref.Enlarge(insets.width(), insets.height()); | 122 pref.Enlarge(insets.width(), insets.height()); |
| 123 } | 123 } |
| 124 return pref; | 124 return pref; |
| 125 } | 125 } |
| 126 | 126 |
| 127 void GetAccessibleState(ui::AXViewState* state) override { | 127 void GetAccessibleNodeData(ui::AXNodeData* node_data) override { |
| 128 ImageButton::GetAccessibleState(state); | 128 ImageButton::GetAccessibleNodeData(node_data); |
| 129 state->role = ui::AX_ROLE_MENU_ITEM; | 129 node_data->role = ui::AX_ROLE_MENU_ITEM; |
| 130 } | 130 } |
| 131 | 131 |
| 132 private: | 132 private: |
| 133 DISALLOW_COPY_AND_ASSIGN(FullscreenButton); | 133 DISALLOW_COPY_AND_ASSIGN(FullscreenButton); |
| 134 }; | 134 }; |
| 135 | 135 |
| 136 // Combination border/background for the buttons contained in the menu. The | 136 // Combination border/background for the buttons contained in the menu. The |
| 137 // painting of the border/background is done here as LabelButton does not always | 137 // painting of the border/background is done here as LabelButton does not always |
| 138 // paint the border. | 138 // paint the border. |
| 139 class InMenuButtonBackground : public views::Background { | 139 class InMenuButtonBackground : public views::Background { |
| (...skipping 121 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 261 SetFocusBehavior(FocusBehavior::ALWAYS); | 261 SetFocusBehavior(FocusBehavior::ALWAYS); |
| 262 SetHorizontalAlignment(gfx::ALIGN_CENTER); | 262 SetHorizontalAlignment(gfx::ALIGN_CENTER); |
| 263 | 263 |
| 264 in_menu_background_ = new InMenuButtonBackground(type); | 264 in_menu_background_ = new InMenuButtonBackground(type); |
| 265 set_background(in_menu_background_); | 265 set_background(in_menu_background_); |
| 266 SetBorder(views::Border::CreateEmptyBorder(0, kHorizontalPadding, 0, | 266 SetBorder(views::Border::CreateEmptyBorder(0, kHorizontalPadding, 0, |
| 267 kHorizontalPadding)); | 267 kHorizontalPadding)); |
| 268 SetFontList(MenuConfig::instance().font_list); | 268 SetFontList(MenuConfig::instance().font_list); |
| 269 } | 269 } |
| 270 | 270 |
| 271 void GetAccessibleState(ui::AXViewState* state) override { | 271 void GetAccessibleNodeData(ui::AXNodeData* node_data) override { |
| 272 LabelButton::GetAccessibleState(state); | 272 LabelButton::GetAccessibleNodeData(node_data); |
| 273 state->role = ui::AX_ROLE_MENU_ITEM; | 273 node_data->role = ui::AX_ROLE_MENU_ITEM; |
| 274 } | 274 } |
| 275 | 275 |
| 276 // views::LabelButton | 276 // views::LabelButton |
| 277 void OnNativeThemeChanged(const ui::NativeTheme* theme) override { | 277 void OnNativeThemeChanged(const ui::NativeTheme* theme) override { |
| 278 if (theme) { | 278 if (theme) { |
| 279 SetTextColor( | 279 SetTextColor( |
| 280 views::Button::STATE_DISABLED, | 280 views::Button::STATE_DISABLED, |
| 281 theme->GetSystemColor( | 281 theme->GetSystemColor( |
| 282 ui::NativeTheme::kColorId_DisabledMenuItemForegroundColor)); | 282 ui::NativeTheme::kColorId_DisabledMenuItemForegroundColor)); |
| 283 SetTextColor( | 283 SetTextColor( |
| (...skipping 950 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 1234 0, | 1234 0, |
| 1235 BookmarkMenuDelegate::SHOW_PERMANENT_FOLDERS, | 1235 BookmarkMenuDelegate::SHOW_PERMANENT_FOLDERS, |
| 1236 BOOKMARK_LAUNCH_LOCATION_APP_MENU); | 1236 BOOKMARK_LAUNCH_LOCATION_APP_MENU); |
| 1237 } | 1237 } |
| 1238 | 1238 |
| 1239 int AppMenu::ModelIndexFromCommandId(int command_id) const { | 1239 int AppMenu::ModelIndexFromCommandId(int command_id) const { |
| 1240 CommandIDToEntry::const_iterator ix = command_id_to_entry_.find(command_id); | 1240 CommandIDToEntry::const_iterator ix = command_id_to_entry_.find(command_id); |
| 1241 DCHECK(ix != command_id_to_entry_.end()); | 1241 DCHECK(ix != command_id_to_entry_.end()); |
| 1242 return ix->second.second; | 1242 return ix->second.second; |
| 1243 } | 1243 } |
| OLD | NEW |