| 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/web_toolbar_controller.h" | 5 #import "ios/chrome/browser/ui/toolbar/web_toolbar_controller.h" |
| 6 | 6 |
| 7 #import <CoreLocation/CoreLocation.h> | 7 #import <CoreLocation/CoreLocation.h> |
| 8 #include <QuartzCore/QuartzCore.h> | 8 #include <QuartzCore/QuartzCore.h> |
| 9 | 9 |
| 10 #include <stdint.h> | 10 #include <stdint.h> |
| 11 | 11 |
| 12 #include <algorithm> | 12 #include <algorithm> |
| 13 #include <memory> | 13 #include <memory> |
| 14 | 14 |
| 15 #include "base/command_line.h" | 15 #include "base/command_line.h" |
| 16 #include "base/ios/weak_nsobject.h" | 16 #include "base/ios/weak_nsobject.h" |
| 17 #include "base/logging.h" | 17 #include "base/logging.h" |
| 18 #include "base/mac/bundle_locations.h" | 18 #include "base/mac/bundle_locations.h" |
| 19 #include "base/mac/foundation_util.h" | 19 #include "base/mac/foundation_util.h" |
| 20 #include "base/memory/ptr_util.h" |
| 20 #include "base/metrics/histogram_macros.h" | 21 #include "base/metrics/histogram_macros.h" |
| 21 #include "base/metrics/user_metrics.h" | 22 #include "base/metrics/user_metrics.h" |
| 22 #include "base/metrics/user_metrics_action.h" | 23 #include "base/metrics/user_metrics_action.h" |
| 23 #include "base/strings/sys_string_conversions.h" | 24 #include "base/strings/sys_string_conversions.h" |
| 24 #include "components/google/core/browser/google_util.h" | 25 #include "components/google/core/browser/google_util.h" |
| 25 #include "components/omnibox/browser/omnibox_edit_model.h" | 26 #include "components/omnibox/browser/omnibox_edit_model.h" |
| 26 #include "components/search_engines/util.h" | 27 #include "components/search_engines/util.h" |
| 27 #include "components/strings/grit/components_strings.h" | 28 #include "components/strings/grit/components_strings.h" |
| 28 #include "components/toolbar/toolbar_model.h" | 29 #include "components/toolbar/toolbar_model.h" |
| 29 #include "ios/chrome/browser/autocomplete/autocomplete_scheme_classifier_impl.h" | 30 #include "ios/chrome/browser/autocomplete/autocomplete_scheme_classifier_impl.h" |
| 30 #include "ios/chrome/browser/browser_state/chrome_browser_state.h" | 31 #include "ios/chrome/browser/browser_state/chrome_browser_state.h" |
| 31 #include "ios/chrome/browser/chrome_url_constants.h" | 32 #include "ios/chrome/browser/chrome_url_constants.h" |
| 32 #include "ios/chrome/browser/reading_list/reading_list_model_factory.h" | 33 #include "ios/chrome/browser/reading_list/reading_list_model_factory.h" |
| 33 #include "ios/chrome/browser/search_engines/template_url_service_factory.h" | 34 #include "ios/chrome/browser/search_engines/template_url_service_factory.h" |
| 34 #import "ios/chrome/browser/tabs/tab.h" | 35 #import "ios/chrome/browser/tabs/tab.h" |
| 35 #import "ios/chrome/browser/tabs/tab_model.h" | 36 #import "ios/chrome/browser/tabs/tab_model.h" |
| 36 #import "ios/chrome/browser/ui/animation_util.h" | 37 #import "ios/chrome/browser/ui/animation_util.h" |
| 37 #import "ios/chrome/browser/ui/colors/MDCPalette+CrAdditions.h" | 38 #import "ios/chrome/browser/ui/colors/MDCPalette+CrAdditions.h" |
| 38 #import "ios/chrome/browser/ui/commands/UIKit+ChromeExecuteCommand.h" | 39 #import "ios/chrome/browser/ui/commands/UIKit+ChromeExecuteCommand.h" |
| 39 #import "ios/chrome/browser/ui/commands/generic_chrome_command.h" | 40 #import "ios/chrome/browser/ui/commands/generic_chrome_command.h" |
| 40 #include "ios/chrome/browser/ui/commands/ios_command_ids.h" | 41 #include "ios/chrome/browser/ui/commands/ios_command_ids.h" |
| 41 #import "ios/chrome/browser/ui/history/tab_history_popup_controller.h" | 42 #import "ios/chrome/browser/ui/history/tab_history_popup_controller.h" |
| 42 #import "ios/chrome/browser/ui/image_util.h" | 43 #import "ios/chrome/browser/ui/image_util.h" |
| 43 #import "ios/chrome/browser/ui/keyboard/hardware_keyboard_watcher.h" | 44 #import "ios/chrome/browser/ui/keyboard/hardware_keyboard_watcher.h" |
| 45 #include "ios/chrome/browser/ui/omnibox/location_bar_controller_impl.h" |
| 44 #include "ios/chrome/browser/ui/omnibox/omnibox_view_ios.h" | 46 #include "ios/chrome/browser/ui/omnibox/omnibox_view_ios.h" |
| 45 #import "ios/chrome/browser/ui/reversed_animation.h" | 47 #import "ios/chrome/browser/ui/reversed_animation.h" |
| 46 #include "ios/chrome/browser/ui/rtl_geometry.h" | 48 #include "ios/chrome/browser/ui/rtl_geometry.h" |
| 47 #import "ios/chrome/browser/ui/toolbar/toolbar_controller+protected.h" | 49 #import "ios/chrome/browser/ui/toolbar/toolbar_controller+protected.h" |
| 48 #import "ios/chrome/browser/ui/toolbar/toolbar_controller.h" | 50 #import "ios/chrome/browser/ui/toolbar/toolbar_controller.h" |
| 49 #import "ios/chrome/browser/ui/toolbar/toolbar_model_ios.h" | 51 #import "ios/chrome/browser/ui/toolbar/toolbar_model_ios.h" |
| 50 #include "ios/chrome/browser/ui/toolbar/toolbar_resource_macros.h" | 52 #include "ios/chrome/browser/ui/toolbar/toolbar_resource_macros.h" |
| 51 #include "ios/chrome/browser/ui/ui_util.h" | 53 #include "ios/chrome/browser/ui/ui_util.h" |
| 52 #import "ios/chrome/browser/ui/uikit_ui_util.h" | 54 #import "ios/chrome/browser/ui/uikit_ui_util.h" |
| 53 #import "ios/chrome/browser/ui/url_loader.h" | 55 #import "ios/chrome/browser/ui/url_loader.h" |
| 54 #import "ios/chrome/browser/ui/voice/text_to_speech_player.h" | 56 #import "ios/chrome/browser/ui/voice/text_to_speech_player.h" |
| 55 #import "ios/chrome/browser/ui/voice/voice_search_notification_names.h" | 57 #import "ios/chrome/browser/ui/voice/voice_search_notification_names.h" |
| 56 #import "ios/chrome/common/material_timing.h" | 58 #import "ios/chrome/common/material_timing.h" |
| 57 #include "ios/chrome/grit/ios_strings.h" | 59 #include "ios/chrome/grit/ios_strings.h" |
| 58 #import "ios/public/provider/chrome/browser/chrome_browser_provider.h" | 60 #import "ios/public/provider/chrome/browser/chrome_browser_provider.h" |
| 59 #import "ios/public/provider/chrome/browser/images/branded_image_provider.h" | 61 #import "ios/public/provider/chrome/browser/images/branded_image_provider.h" |
| 60 #import "ios/public/provider/chrome/browser/voice/voice_search_provider.h" | 62 #import "ios/public/provider/chrome/browser/voice/voice_search_provider.h" |
| 63 #include "ios/shared/chrome/browser/ui/omnibox/location_bar_controller.h" |
| 64 #include "ios/shared/chrome/browser/ui/omnibox/location_bar_delegate.h" |
| 61 #import "ios/third_party/material_components_ios/src/components/Palettes/src/Mat
erialPalettes.h" | 65 #import "ios/third_party/material_components_ios/src/components/Palettes/src/Mat
erialPalettes.h" |
| 62 #import "ios/third_party/material_components_ios/src/components/ProgressView/src
/MaterialProgressView.h" | 66 #import "ios/third_party/material_components_ios/src/components/ProgressView/src
/MaterialProgressView.h" |
| 63 #import "ios/third_party/material_components_ios/src/components/Typography/src/M
aterialTypography.h" | 67 #import "ios/third_party/material_components_ios/src/components/Typography/src/M
aterialTypography.h" |
| 64 #include "ios/web/public/referrer.h" | 68 #include "ios/web/public/referrer.h" |
| 65 #import "ios/web/public/web_state/web_state.h" | 69 #import "ios/web/public/web_state/web_state.h" |
| 66 #import "net/base/mac/url_conversions.h" | 70 #import "net/base/mac/url_conversions.h" |
| 67 #include "ui/base/l10n/l10n_util.h" | 71 #include "ui/base/l10n/l10n_util.h" |
| 68 #include "ui/base/page_transition_types.h" | 72 #include "ui/base/page_transition_types.h" |
| 69 #import "ui/gfx/ios/NSString+CrStringDrawing.h" | 73 #import "ui/gfx/ios/NSString+CrStringDrawing.h" |
| 70 | 74 |
| (...skipping 178 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 249 base::scoped_nsobject<UIButton> _cancelButton; | 253 base::scoped_nsobject<UIButton> _cancelButton; |
| 250 base::scoped_nsobject<UIView> _keyBoardAccessoryView; | 254 base::scoped_nsobject<UIView> _keyBoardAccessoryView; |
| 251 base::scoped_nsobject<UIButton> _keyboardVoiceSearchButton; | 255 base::scoped_nsobject<UIButton> _keyboardVoiceSearchButton; |
| 252 // Progress bar used to show what fraction of the page has loaded. | 256 // Progress bar used to show what fraction of the page has loaded. |
| 253 base::scoped_nsobject<MDCProgressView> _determinateProgressView; | 257 base::scoped_nsobject<MDCProgressView> _determinateProgressView; |
| 254 base::scoped_nsobject<UIImageView> _omniboxBackground; | 258 base::scoped_nsobject<UIImageView> _omniboxBackground; |
| 255 BOOL _prerenderAnimating; | 259 BOOL _prerenderAnimating; |
| 256 base::scoped_nsobject<UIImageView> _incognitoIcon; | 260 base::scoped_nsobject<UIImageView> _incognitoIcon; |
| 257 base::scoped_nsobject<UIView> _clippingView; | 261 base::scoped_nsobject<UIView> _clippingView; |
| 258 | 262 |
| 259 std::unique_ptr<LocationBarViewIOS> _locationBar; | 263 std::unique_ptr<LocationBarController> _locationBar; |
| 260 BOOL _initialLayoutComplete; | 264 BOOL _initialLayoutComplete; |
| 261 // If |YES|, toolbar is incognito. | 265 // If |YES|, toolbar is incognito. |
| 262 BOOL _incognito; | 266 BOOL _incognito; |
| 263 | 267 |
| 264 // If set to |YES|, disables animations that tests would otherwise trigger. | 268 // If set to |YES|, disables animations that tests would otherwise trigger. |
| 265 BOOL _unitTesting; | 269 BOOL _unitTesting; |
| 266 | 270 |
| 267 // If set to |YES|, text to speech is currently playing and the toolbar voice | 271 // If set to |YES|, text to speech is currently playing and the toolbar voice |
| 268 // icon should indicate so. | 272 // icon should indicate so. |
| 269 BOOL _isTTSPlaying; | 273 BOOL _isTTSPlaying; |
| (...skipping 318 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 588 SetA11yLabelAndUiAutomationName(_starButton, IDS_TOOLTIP_STAR, @"Bookmark"); | 592 SetA11yLabelAndUiAutomationName(_starButton, IDS_TOOLTIP_STAR, @"Bookmark"); |
| 589 SetA11yLabelAndUiAutomationName( | 593 SetA11yLabelAndUiAutomationName( |
| 590 _voiceSearchButton, IDS_IOS_ACCNAME_VOICE_SEARCH, @"Voice Search"); | 594 _voiceSearchButton, IDS_IOS_ACCNAME_VOICE_SEARCH, @"Voice Search"); |
| 591 SetA11yLabelAndUiAutomationName(_omniBox, IDS_ACCNAME_LOCATION, @"Address"); | 595 SetA11yLabelAndUiAutomationName(_omniBox, IDS_ACCNAME_LOCATION, @"Address"); |
| 592 | 596 |
| 593 // Resize the container to match the available area. | 597 // Resize the container to match the available area. |
| 594 [self.view addSubview:_webToolbar]; | 598 [self.view addSubview:_webToolbar]; |
| 595 [_webToolbar setAutoresizingMask:UIViewAutoresizingFlexibleWidth | | 599 [_webToolbar setAutoresizingMask:UIViewAutoresizingFlexibleWidth | |
| 596 UIViewAutoresizingFlexibleBottomMargin]; | 600 UIViewAutoresizingFlexibleBottomMargin]; |
| 597 [_webToolbar setFrame:[self specificControlsArea]]; | 601 [_webToolbar setFrame:[self specificControlsArea]]; |
| 598 _locationBar.reset( | 602 _locationBar = base::MakeUnique<LocationBarControllerImpl>( |
| 599 new LocationBarViewIOS(_omniBox, _browserState, preloader, self, self)); | 603 _omniBox, _browserState, preloader, self, self); |
| 600 | 604 |
| 601 // Create the determinate progress bar (phone only). | 605 // Create the determinate progress bar (phone only). |
| 602 if (idiom == IPHONE_IDIOM) { | 606 if (idiom == IPHONE_IDIOM) { |
| 603 CGFloat progressWidth = self.view.frame.size.width; | 607 CGFloat progressWidth = self.view.frame.size.width; |
| 604 CGFloat progressHeight = 0; | 608 CGFloat progressHeight = 0; |
| 605 progressHeight = kMaterialProgressBarHeight; | 609 progressHeight = kMaterialProgressBarHeight; |
| 606 _determinateProgressView.reset([[MDCProgressView alloc] init]); | 610 _determinateProgressView.reset([[MDCProgressView alloc] init]); |
| 607 _determinateProgressView.get().hidden = YES; | 611 _determinateProgressView.get().hidden = YES; |
| 608 [_determinateProgressView | 612 [_determinateProgressView |
| 609 setProgressTintColor:[MDCPalette cr_bluePalette].tint500]; | 613 setProgressTintColor:[MDCPalette cr_bluePalette].tint500]; |
| (...skipping 1358 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 1968 [[GenericChromeCommand alloc] initWithTag:IDC_PRELOAD_VOICE_SEARCH]); | 1972 [[GenericChromeCommand alloc] initWithTag:IDC_PRELOAD_VOICE_SEARCH]); |
| 1969 [sender chromeExecuteCommand:command]; | 1973 [sender chromeExecuteCommand:command]; |
| 1970 } | 1974 } |
| 1971 | 1975 |
| 1972 // Called when the keyboard voice search button is tapped with voice search | 1976 // Called when the keyboard voice search button is tapped with voice search |
| 1973 // disabled. Hides the voice search button but takes no other action. | 1977 // disabled. Hides the voice search button but takes no other action. |
| 1974 - (void)ignoreVoiceSearch:(id)sender { | 1978 - (void)ignoreVoiceSearch:(id)sender { |
| 1975 [_keyboardVoiceSearchButton setHidden:YES]; | 1979 [_keyboardVoiceSearchButton setHidden:YES]; |
| 1976 } | 1980 } |
| 1977 | 1981 |
| 1978 - (LocationBarViewIOS*)locationBar { | |
| 1979 return _locationBar.get(); | |
| 1980 } | |
| 1981 | |
| 1982 - (CGFloat)omniboxLeading { | 1982 - (CGFloat)omniboxLeading { |
| 1983 // Compute what the leading (x-origin) position for the omniboox should be | 1983 // Compute what the leading (x-origin) position for the omniboox should be |
| 1984 // based on what other controls are active. | 1984 // based on what other controls are active. |
| 1985 InterfaceIdiom idiom = IsIPadIdiom() ? IPAD_IDIOM : IPHONE_IDIOM; | 1985 InterfaceIdiom idiom = IsIPadIdiom() ? IPAD_IDIOM : IPHONE_IDIOM; |
| 1986 | 1986 |
| 1987 CGFloat trailingPadding = 0.0; | 1987 CGFloat trailingPadding = 0.0; |
| 1988 | 1988 |
| 1989 LayoutRect leadingControlLayout = LayoutRectForRectInBoundingRect( | 1989 LayoutRect leadingControlLayout = LayoutRectForRectInBoundingRect( |
| 1990 [_backButton frame], [_webToolbar bounds]); | 1990 [_backButton frame], [_webToolbar bounds]); |
| 1991 LayoutRect forwardButtonLayout = | 1991 LayoutRect forwardButtonLayout = |
| (...skipping 577 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 2569 | 2569 |
| 2570 - (BOOL)isPrerenderAnimationRunning { | 2570 - (BOOL)isPrerenderAnimationRunning { |
| 2571 return _prerenderAnimating; | 2571 return _prerenderAnimating; |
| 2572 } | 2572 } |
| 2573 | 2573 |
| 2574 - (OmniboxTextFieldIOS*)omnibox { | 2574 - (OmniboxTextFieldIOS*)omnibox { |
| 2575 return _omniBox.get(); | 2575 return _omniBox.get(); |
| 2576 } | 2576 } |
| 2577 | 2577 |
| 2578 @end | 2578 @end |
| OLD | NEW |