| OLD | NEW |
| 1 // Copyright 2012 The Chromium Authors. All rights reserved. | 1 // Copyright 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 #import "ios/chrome/browser/ui/toolbar/toolbar_controller.h" | 5 #import "ios/chrome/browser/ui/toolbar/toolbar_controller.h" |
| 6 | 6 |
| 7 #include <QuartzCore/QuartzCore.h> | 7 #include <QuartzCore/QuartzCore.h> |
| 8 | 8 |
| 9 #include "base/format_macros.h" | 9 #include "base/format_macros.h" |
| 10 #include "base/i18n/rtl.h" | 10 #include "base/i18n/rtl.h" |
| 11 #include "base/ios/ios_util.h" | 11 #include "base/ios/ios_util.h" |
| 12 #include "base/mac/bundle_locations.h" | 12 #include "base/mac/bundle_locations.h" |
| 13 #include "base/mac/foundation_util.h" | 13 #include "base/mac/foundation_util.h" |
| 14 #include "base/memory/ptr_util.h" | 14 #include "base/memory/ptr_util.h" |
| 15 #include "base/metrics/user_metrics.h" | 15 #include "base/metrics/user_metrics.h" |
| 16 #include "base/metrics/user_metrics_action.h" | 16 #include "base/metrics/user_metrics_action.h" |
| 17 #import "ios/chrome/browser/ui/animation_util.h" | 17 #import "ios/chrome/browser/ui/animation_util.h" |
| 18 #import "ios/chrome/browser/ui/commands/UIKit+ChromeExecuteCommand.h" | 18 #import "ios/chrome/browser/ui/commands/UIKit+ChromeExecuteCommand.h" |
| 19 #import "ios/chrome/browser/ui/commands/generic_chrome_command.h" | 19 #import "ios/chrome/browser/ui/commands/generic_chrome_command.h" |
| 20 #include "ios/chrome/browser/ui/commands/ios_command_ids.h" | 20 #include "ios/chrome/browser/ui/commands/ios_command_ids.h" |
| 21 #import "ios/chrome/browser/ui/fullscreen_controller.h" | 21 #import "ios/chrome/browser/ui/fullscreen_controller.h" |
| 22 #import "ios/chrome/browser/ui/image_util.h" | 22 #import "ios/chrome/browser/ui/image_util.h" |
| 23 #import "ios/chrome/browser/ui/reversed_animation.h" | 23 #import "ios/chrome/browser/ui/reversed_animation.h" |
| 24 #include "ios/chrome/browser/ui/rtl_geometry.h" | 24 #include "ios/chrome/browser/ui/rtl_geometry.h" |
| 25 #import "ios/chrome/browser/ui/toolbar/toolbar_controller+protected.h" | 25 #import "ios/chrome/browser/ui/toolbar/toolbar_controller+protected.h" |
| 26 #import "ios/chrome/browser/ui/toolbar/toolbar_controller_private.h" | 26 #import "ios/chrome/browser/ui/toolbar/toolbar_controller_private.h" |
| 27 #include "ios/chrome/browser/ui/toolbar/toolbar_resource_macros.h" | 27 #include "ios/chrome/browser/ui/toolbar/toolbar_resource_macros.h" |
| 28 #import "ios/chrome/browser/ui/toolbar/toolbar_tools_menu_button.h" | 28 #import "ios/chrome/browser/ui/toolbar/toolbar_tools_menu_button.h" |
| 29 #import "ios/chrome/browser/ui/toolbar/tools_menu_button_observer_bridge.h" | 29 #import "ios/chrome/browser/ui/toolbar/tools_menu_button_observer_bridge.h" |
| 30 #import "ios/chrome/browser/ui/tools_menu/tools_menu_context.h" | 30 #import "ios/chrome/browser/ui/tools_menu/tools_menu_configuration.h" |
| 31 #import "ios/chrome/browser/ui/tools_menu/tools_popup_controller.h" | 31 #import "ios/chrome/browser/ui/tools_menu/tools_popup_controller.h" |
| 32 #import "ios/chrome/browser/ui/uikit_ui_util.h" | 32 #import "ios/chrome/browser/ui/uikit_ui_util.h" |
| 33 #import "ios/chrome/common/material_timing.h" | 33 #import "ios/chrome/common/material_timing.h" |
| 34 #include "ios/chrome/grit/ios_strings.h" | 34 #include "ios/chrome/grit/ios_strings.h" |
| 35 #include "ios/chrome/grit/ios_theme_resources.h" | 35 #include "ios/chrome/grit/ios_theme_resources.h" |
| 36 #import "ios/third_party/material_roboto_font_loader_ios/src/src/MaterialRobotoF
ontLoader.h" | 36 #import "ios/third_party/material_roboto_font_loader_ios/src/src/MaterialRobotoF
ontLoader.h" |
| 37 | 37 |
| 38 using base::UserMetricsAction; | 38 using base::UserMetricsAction; |
| 39 using ios::material::TimingFunction; | 39 using ios::material::TimingFunction; |
| 40 | 40 |
| (...skipping 540 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 581 - (CGRect)shareButtonAnchorRect { | 581 - (CGRect)shareButtonAnchorRect { |
| 582 // Shrink the padding around the shareButton so the popovers are anchored | 582 // Shrink the padding around the shareButton so the popovers are anchored |
| 583 // correctly. | 583 // correctly. |
| 584 return CGRectInset([shareButton_ bounds], 10, 0); | 584 return CGRectInset([shareButton_ bounds], 10, 0); |
| 585 } | 585 } |
| 586 | 586 |
| 587 - (UIView*)shareButtonView { | 587 - (UIView*)shareButtonView { |
| 588 return shareButton_.get(); | 588 return shareButton_.get(); |
| 589 } | 589 } |
| 590 | 590 |
| 591 - (void)showToolsMenuPopupWithContext:(ToolsMenuContext*)context { | 591 - (void)showToolsMenuPopupWithConfiguration: |
| 592 (ToolsMenuConfiguration*)configuration { |
| 592 // Because an animation hides and shows the tools popup menu it is possible to | 593 // Because an animation hides and shows the tools popup menu it is possible to |
| 593 // tap the tools button multiple times before the tools menu is shown. Ignore | 594 // tap the tools button multiple times before the tools menu is shown. Ignore |
| 594 // repeated taps between animations. | 595 // repeated taps between animations. |
| 595 if (toolsPopupController_) | 596 if (toolsPopupController_) |
| 596 return; | 597 return; |
| 597 | 598 |
| 598 base::RecordAction(UserMetricsAction("ShowAppMenu")); | 599 base::RecordAction(UserMetricsAction("ShowAppMenu")); |
| 599 | 600 |
| 600 // Keep the button pressed. | 601 // Keep the button pressed. |
| 601 [toolsMenuButton_ setToolsMenuIsVisible:YES]; | 602 [toolsMenuButton_ setToolsMenuIsVisible:YES]; |
| 602 | 603 |
| 603 [context setToolsMenuButton:toolsMenuButton_]; | 604 [configuration setToolsMenuButton:toolsMenuButton_]; |
| 604 toolsPopupController_.reset( | 605 toolsPopupController_.reset( |
| 605 [[ToolsPopupController alloc] initWithContext:context]); | 606 [[ToolsPopupController alloc] initWithConfiguration:configuration]); |
| 606 | 607 |
| 607 [toolsPopupController_ setDelegate:self]; | 608 [toolsPopupController_ setDelegate:self]; |
| 608 | 609 |
| 609 [[NSNotificationCenter defaultCenter] | 610 [[NSNotificationCenter defaultCenter] |
| 610 postNotificationName:kMenuWillShowNotification | 611 postNotificationName:kMenuWillShowNotification |
| 611 object:nil]; | 612 object:nil]; |
| 612 } | 613 } |
| 613 | 614 |
| 614 - (void)dismissToolsMenuPopup { | 615 - (void)dismissToolsMenuPopup { |
| 615 if (!toolsPopupController_.get()) | 616 if (!toolsPopupController_.get()) |
| (...skipping 431 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 1047 #pragma mark - | 1048 #pragma mark - |
| 1048 #pragma mark PopupMenuDelegate methods. | 1049 #pragma mark PopupMenuDelegate methods. |
| 1049 | 1050 |
| 1050 - (void)dismissPopupMenu:(PopupMenuController*)controller { | 1051 - (void)dismissPopupMenu:(PopupMenuController*)controller { |
| 1051 if ([controller isKindOfClass:[ToolsPopupController class]] && | 1052 if ([controller isKindOfClass:[ToolsPopupController class]] && |
| 1052 (ToolsPopupController*)controller == toolsPopupController_) | 1053 (ToolsPopupController*)controller == toolsPopupController_) |
| 1053 [self dismissToolsMenuPopup]; | 1054 [self dismissToolsMenuPopup]; |
| 1054 } | 1055 } |
| 1055 | 1056 |
| 1056 @end | 1057 @end |
| OLD | NEW |