| Index: chrome/browser/ui/cocoa/toolbar/reload_button_cocoa.mm
|
| diff --git a/chrome/browser/ui/cocoa/toolbar/reload_button_cocoa.mm b/chrome/browser/ui/cocoa/toolbar/reload_button_cocoa.mm
|
| index eec4d00892ee44e8e238380b26ba4fff5a33ed6d..8f1c05bd0d012834ea4b3933f3b5607b0c97bb4b 100644
|
| --- a/chrome/browser/ui/cocoa/toolbar/reload_button_cocoa.mm
|
| +++ b/chrome/browser/ui/cocoa/toolbar/reload_button_cocoa.mm
|
| @@ -10,12 +10,14 @@
|
| #include "chrome/app/chrome_command_ids.h"
|
| #include "chrome/browser/command_updater.h"
|
| #import "chrome/browser/ui/cocoa/accelerators_cocoa.h"
|
| +#import "chrome/browser/ui/cocoa/themed_window.h"
|
| #import "chrome/browser/ui/cocoa/view_id_util.h"
|
| #include "chrome/grit/generated_resources.h"
|
| #include "grit/theme_resources.h"
|
| #include "ui/base/accelerators/platform_accelerator_cocoa.h"
|
| #include "ui/base/l10n/l10n_util.h"
|
| #include "ui/base/l10n/l10n_util_mac.h"
|
| +#include "ui/base/material_design/material_design_controller.h"
|
| #import "ui/events/event_utils.h"
|
|
|
| namespace {
|
| @@ -89,27 +91,41 @@ const int kReloadMenuCommands[] = {
|
| [self removeAllToolTips];
|
| id cell = [self cell];
|
| [self setTag:anInt];
|
| +
|
| + // The old way of doing things.
|
| + if (!ui::MaterialDesignController::IsModeMaterial()) {
|
| + if (anInt == IDC_RELOAD) {
|
| + [cell setImageID:IDR_RELOAD
|
| + forButtonState:image_button_cell::kDefaultState];
|
| + [cell setImageID:IDR_RELOAD_H
|
| + forButtonState:image_button_cell::kHoverState];
|
| + [cell setImageID:IDR_RELOAD_P
|
| + forButtonState:image_button_cell::kPressedState];
|
| + // The stop button has a disabled image but the reload button doesn't. To
|
| + // unset it we have to explicilty change the image ID to 0.
|
| + [cell setImageID:0
|
| + forButtonState:image_button_cell::kDisabledState];
|
| + [self setToolTip:l10n_util::GetNSStringWithFixup(IDS_TOOLTIP_RELOAD)];
|
| + } else if (anInt == IDC_STOP) {
|
| + [cell setImageID:IDR_STOP
|
| + forButtonState:image_button_cell::kDefaultState];
|
| + [cell setImageID:IDR_STOP_H
|
| + forButtonState:image_button_cell::kHoverState];
|
| + [cell setImageID:IDR_STOP_P
|
| + forButtonState:image_button_cell::kPressedState];
|
| + [cell setImageID:IDR_STOP_D
|
| + forButtonState:image_button_cell::kDisabledState];
|
| + [self setToolTip:l10n_util::GetNSStringWithFixup(IDS_TOOLTIP_STOP)];
|
| + } else {
|
| + NOTREACHED();
|
| + }
|
| + return;
|
| + }
|
| +
|
| + [self resetIcons];
|
| if (anInt == IDC_RELOAD) {
|
| - [cell setImageID:IDR_RELOAD
|
| - forButtonState:image_button_cell::kDefaultState];
|
| - [cell setImageID:IDR_RELOAD_H
|
| - forButtonState:image_button_cell::kHoverState];
|
| - [cell setImageID:IDR_RELOAD_P
|
| - forButtonState:image_button_cell::kPressedState];
|
| - // The stop button has a disabled image but the reload button doesn't. To
|
| - // unset it we have to explicilty change the image ID to 0.
|
| - [cell setImageID:0
|
| - forButtonState:image_button_cell::kDisabledState];
|
| [self setToolTip:l10n_util::GetNSStringWithFixup(IDS_TOOLTIP_RELOAD)];
|
| } else if (anInt == IDC_STOP) {
|
| - [cell setImageID:IDR_STOP
|
| - forButtonState:image_button_cell::kDefaultState];
|
| - [cell setImageID:IDR_STOP_H
|
| - forButtonState:image_button_cell::kHoverState];
|
| - [cell setImageID:IDR_STOP_P
|
| - forButtonState:image_button_cell::kPressedState];
|
| - [cell setImageID:IDR_STOP_D
|
| - forButtonState:image_button_cell::kDisabledState];
|
| [self setToolTip:l10n_util::GetNSStringWithFixup(IDS_TOOLTIP_STOP)];
|
| } else {
|
| NOTREACHED();
|
| @@ -139,14 +155,27 @@ const int kReloadMenuCommands[] = {
|
| !pendingReloadTimer_ &&
|
| [[self cell] isMouseInside]) {
|
| id cell = [self cell];
|
| - [cell setImageID:IDR_STOP_D
|
| - forButtonState:image_button_cell::kDefaultState];
|
| - [cell setImageID:IDR_STOP_D
|
| - forButtonState:image_button_cell::kDisabledState];
|
| - [cell setImageID:IDR_STOP_D
|
| - forButtonState:image_button_cell::kHoverState];
|
| - [cell setImageID:IDR_STOP_D
|
| - forButtonState:image_button_cell::kPressedState];
|
| + if (ui::MaterialDesignController::IsModeMaterial()) {
|
| + [self setImagesFromIconId:gfx::VectorIconId::NAVIGATE_STOP];
|
| + NSImage* disabledStopImage =
|
| + [[self cell] imageForState:image_button_cell::kDisabledState
|
| + view:self];
|
| + [cell setImage:disabledStopImage
|
| + forButtonState:image_button_cell::kDefaultState];
|
| + [cell setImage:disabledStopImage
|
| + forButtonState:image_button_cell::kHoverState];
|
| + [cell setImage:disabledStopImage
|
| + forButtonState:image_button_cell::kPressedState];
|
| + } else {
|
| + [cell setImageID:IDR_STOP_D
|
| + forButtonState:image_button_cell::kDefaultState];
|
| + [cell setImageID:IDR_STOP_D
|
| + forButtonState:image_button_cell::kDisabledState];
|
| + [cell setImageID:IDR_STOP_D
|
| + forButtonState:image_button_cell::kHoverState];
|
| + [cell setImageID:IDR_STOP_D
|
| + forButtonState:image_button_cell::kPressedState];
|
| + }
|
| pendingReloadTimer_ =
|
| [NSTimer timerWithTimeInterval:kPendingReloadTimeout
|
| target:self
|
| @@ -257,6 +286,25 @@ const int kReloadMenuCommands[] = {
|
| command, ui::DispositionFromEventFlags(event_flags));
|
| }
|
|
|
| +- (void)resetIcons {
|
| + if ([self tag] == IDC_RELOAD) {
|
| + [self setImagesFromIconId:gfx::VectorIconId::NAVIGATE_RELOAD];
|
| + } else if ([self tag] == IDC_STOP) {
|
| + [self setImagesFromIconId:gfx::VectorIconId::NAVIGATE_STOP];
|
| + } else {
|
| + NOTREACHED();
|
| + }
|
| +}
|
| +
|
| +- (void)viewDidMoveToWindow {
|
| + // If a dark theme in Material Design, make sure the icon is the correct
|
| + // color.
|
| + if ([self window] && ui::MaterialDesignController::IsModeMaterial() &&
|
| + [[self window] hasDarkTheme]) {
|
| + [self resetIcons];
|
| + }
|
| +}
|
| +
|
| @end // ReloadButton
|
|
|
| @implementation ReloadButton (Testing)
|
|
|