Chromium Code Reviews
chromiumcodereview-hr@appspot.gserviceaccount.com (chromiumcodereview-hr) | Please choose your nickname with Settings | Help | Chromium Project | Gerrit Changes | Sign out
(429)

Side by Side Diff: ios/chrome/browser/ui/toolbar/web_toolbar_controller.mm

Issue 2796793003: [ios] Adds a LocationBarController interface. (Closed)
Patch Set: Created 3 years, 8 months ago
Use n/p to move between diff chunks; N/P to move between comments. Draft comments are only viewable by you.
Jump to:
View unified diff | Download patch
OLDNEW
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>
(...skipping 23 matching lines...) Expand all
34 #import "ios/chrome/browser/tabs/tab.h" 34 #import "ios/chrome/browser/tabs/tab.h"
35 #import "ios/chrome/browser/tabs/tab_model.h" 35 #import "ios/chrome/browser/tabs/tab_model.h"
36 #import "ios/chrome/browser/ui/animation_util.h" 36 #import "ios/chrome/browser/ui/animation_util.h"
37 #import "ios/chrome/browser/ui/colors/MDCPalette+CrAdditions.h" 37 #import "ios/chrome/browser/ui/colors/MDCPalette+CrAdditions.h"
38 #import "ios/chrome/browser/ui/commands/UIKit+ChromeExecuteCommand.h" 38 #import "ios/chrome/browser/ui/commands/UIKit+ChromeExecuteCommand.h"
39 #import "ios/chrome/browser/ui/commands/generic_chrome_command.h" 39 #import "ios/chrome/browser/ui/commands/generic_chrome_command.h"
40 #include "ios/chrome/browser/ui/commands/ios_command_ids.h" 40 #include "ios/chrome/browser/ui/commands/ios_command_ids.h"
41 #import "ios/chrome/browser/ui/history/tab_history_popup_controller.h" 41 #import "ios/chrome/browser/ui/history/tab_history_popup_controller.h"
42 #import "ios/chrome/browser/ui/image_util.h" 42 #import "ios/chrome/browser/ui/image_util.h"
43 #import "ios/chrome/browser/ui/keyboard/hardware_keyboard_watcher.h" 43 #import "ios/chrome/browser/ui/keyboard/hardware_keyboard_watcher.h"
44 #include "ios/chrome/browser/ui/omnibox/location_bar_controller_impl.h"
44 #include "ios/chrome/browser/ui/omnibox/omnibox_view_ios.h" 45 #include "ios/chrome/browser/ui/omnibox/omnibox_view_ios.h"
45 #import "ios/chrome/browser/ui/reversed_animation.h" 46 #import "ios/chrome/browser/ui/reversed_animation.h"
46 #include "ios/chrome/browser/ui/rtl_geometry.h" 47 #include "ios/chrome/browser/ui/rtl_geometry.h"
47 #import "ios/chrome/browser/ui/toolbar/toolbar_controller+protected.h" 48 #import "ios/chrome/browser/ui/toolbar/toolbar_controller+protected.h"
48 #import "ios/chrome/browser/ui/toolbar/toolbar_controller.h" 49 #import "ios/chrome/browser/ui/toolbar/toolbar_controller.h"
49 #import "ios/chrome/browser/ui/toolbar/toolbar_model_ios.h" 50 #import "ios/chrome/browser/ui/toolbar/toolbar_model_ios.h"
50 #include "ios/chrome/browser/ui/toolbar/toolbar_resource_macros.h" 51 #include "ios/chrome/browser/ui/toolbar/toolbar_resource_macros.h"
51 #include "ios/chrome/browser/ui/ui_util.h" 52 #include "ios/chrome/browser/ui/ui_util.h"
52 #import "ios/chrome/browser/ui/uikit_ui_util.h" 53 #import "ios/chrome/browser/ui/uikit_ui_util.h"
53 #import "ios/chrome/browser/ui/url_loader.h" 54 #import "ios/chrome/browser/ui/url_loader.h"
54 #import "ios/chrome/browser/ui/voice/text_to_speech_player.h" 55 #import "ios/chrome/browser/ui/voice/text_to_speech_player.h"
55 #import "ios/chrome/browser/ui/voice/voice_search_notification_names.h" 56 #import "ios/chrome/browser/ui/voice/voice_search_notification_names.h"
56 #import "ios/chrome/common/material_timing.h" 57 #import "ios/chrome/common/material_timing.h"
57 #include "ios/chrome/grit/ios_strings.h" 58 #include "ios/chrome/grit/ios_strings.h"
58 #import "ios/public/provider/chrome/browser/chrome_browser_provider.h" 59 #import "ios/public/provider/chrome/browser/chrome_browser_provider.h"
59 #import "ios/public/provider/chrome/browser/images/branded_image_provider.h" 60 #import "ios/public/provider/chrome/browser/images/branded_image_provider.h"
60 #import "ios/public/provider/chrome/browser/voice/voice_search_provider.h" 61 #import "ios/public/provider/chrome/browser/voice/voice_search_provider.h"
62 #include "ios/shared/chrome/browser/ui/omnibox/location_bar_controller.h"
63 #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" 64 #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" 65 #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" 66 #import "ios/third_party/material_components_ios/src/components/Typography/src/M aterialTypography.h"
64 #include "ios/web/public/referrer.h" 67 #include "ios/web/public/referrer.h"
65 #import "ios/web/public/web_state/web_state.h" 68 #import "ios/web/public/web_state/web_state.h"
66 #import "net/base/mac/url_conversions.h" 69 #import "net/base/mac/url_conversions.h"
67 #include "ui/base/l10n/l10n_util.h" 70 #include "ui/base/l10n/l10n_util.h"
68 #include "ui/base/page_transition_types.h" 71 #include "ui/base/page_transition_types.h"
69 #import "ui/gfx/ios/NSString+CrStringDrawing.h" 72 #import "ui/gfx/ios/NSString+CrStringDrawing.h"
70 73
(...skipping 178 matching lines...) Expand 10 before | Expand all | Expand 10 after
249 base::scoped_nsobject<UIButton> _cancelButton; 252 base::scoped_nsobject<UIButton> _cancelButton;
250 base::scoped_nsobject<UIView> _keyBoardAccessoryView; 253 base::scoped_nsobject<UIView> _keyBoardAccessoryView;
251 base::scoped_nsobject<UIButton> _keyboardVoiceSearchButton; 254 base::scoped_nsobject<UIButton> _keyboardVoiceSearchButton;
252 // Progress bar used to show what fraction of the page has loaded. 255 // Progress bar used to show what fraction of the page has loaded.
253 base::scoped_nsobject<MDCProgressView> _determinateProgressView; 256 base::scoped_nsobject<MDCProgressView> _determinateProgressView;
254 base::scoped_nsobject<UIImageView> _omniboxBackground; 257 base::scoped_nsobject<UIImageView> _omniboxBackground;
255 BOOL _prerenderAnimating; 258 BOOL _prerenderAnimating;
256 base::scoped_nsobject<UIImageView> _incognitoIcon; 259 base::scoped_nsobject<UIImageView> _incognitoIcon;
257 base::scoped_nsobject<UIView> _clippingView; 260 base::scoped_nsobject<UIView> _clippingView;
258 261
259 std::unique_ptr<LocationBarViewIOS> _locationBar; 262 std::unique_ptr<LocationBarController> _locationBar;
260 BOOL _initialLayoutComplete; 263 BOOL _initialLayoutComplete;
261 // If |YES|, toolbar is incognito. 264 // If |YES|, toolbar is incognito.
262 BOOL _incognito; 265 BOOL _incognito;
263 266
264 // If set to |YES|, disables animations that tests would otherwise trigger. 267 // If set to |YES|, disables animations that tests would otherwise trigger.
265 BOOL _unitTesting; 268 BOOL _unitTesting;
266 269
267 // If set to |YES|, text to speech is currently playing and the toolbar voice 270 // If set to |YES|, text to speech is currently playing and the toolbar voice
268 // icon should indicate so. 271 // icon should indicate so.
269 BOOL _isTTSPlaying; 272 BOOL _isTTSPlaying;
(...skipping 318 matching lines...) Expand 10 before | Expand all | Expand 10 after
588 SetA11yLabelAndUiAutomationName(_starButton, IDS_TOOLTIP_STAR, @"Bookmark"); 591 SetA11yLabelAndUiAutomationName(_starButton, IDS_TOOLTIP_STAR, @"Bookmark");
589 SetA11yLabelAndUiAutomationName( 592 SetA11yLabelAndUiAutomationName(
590 _voiceSearchButton, IDS_IOS_ACCNAME_VOICE_SEARCH, @"Voice Search"); 593 _voiceSearchButton, IDS_IOS_ACCNAME_VOICE_SEARCH, @"Voice Search");
591 SetA11yLabelAndUiAutomationName(_omniBox, IDS_ACCNAME_LOCATION, @"Address"); 594 SetA11yLabelAndUiAutomationName(_omniBox, IDS_ACCNAME_LOCATION, @"Address");
592 595
593 // Resize the container to match the available area. 596 // Resize the container to match the available area.
594 [self.view addSubview:_webToolbar]; 597 [self.view addSubview:_webToolbar];
595 [_webToolbar setAutoresizingMask:UIViewAutoresizingFlexibleWidth | 598 [_webToolbar setAutoresizingMask:UIViewAutoresizingFlexibleWidth |
596 UIViewAutoresizingFlexibleBottomMargin]; 599 UIViewAutoresizingFlexibleBottomMargin];
597 [_webToolbar setFrame:[self specificControlsArea]]; 600 [_webToolbar setFrame:[self specificControlsArea]];
598 _locationBar.reset( 601 _locationBar.reset(new LocationBarControllerImpl(_omniBox, _browserState,
sdefresne 2017/04/04 13:58:16 nit: use base::MakeUnique if possible _location
rohitrao (ping after 24h) 2017/04/04 14:32:29 Done.
599 new LocationBarViewIOS(_omniBox, _browserState, preloader, self, self)); 602 preloader, self, self));
600 603
601 // Create the determinate progress bar (phone only). 604 // Create the determinate progress bar (phone only).
602 if (idiom == IPHONE_IDIOM) { 605 if (idiom == IPHONE_IDIOM) {
603 CGFloat progressWidth = self.view.frame.size.width; 606 CGFloat progressWidth = self.view.frame.size.width;
604 CGFloat progressHeight = 0; 607 CGFloat progressHeight = 0;
605 progressHeight = kMaterialProgressBarHeight; 608 progressHeight = kMaterialProgressBarHeight;
606 _determinateProgressView.reset([[MDCProgressView alloc] init]); 609 _determinateProgressView.reset([[MDCProgressView alloc] init]);
607 _determinateProgressView.get().hidden = YES; 610 _determinateProgressView.get().hidden = YES;
608 [_determinateProgressView 611 [_determinateProgressView
609 setProgressTintColor:[MDCPalette cr_bluePalette].tint500]; 612 setProgressTintColor:[MDCPalette cr_bluePalette].tint500];
(...skipping 1358 matching lines...) Expand 10 before | Expand all | Expand 10 after
1968 [[GenericChromeCommand alloc] initWithTag:IDC_PRELOAD_VOICE_SEARCH]); 1971 [[GenericChromeCommand alloc] initWithTag:IDC_PRELOAD_VOICE_SEARCH]);
1969 [sender chromeExecuteCommand:command]; 1972 [sender chromeExecuteCommand:command];
1970 } 1973 }
1971 1974
1972 // Called when the keyboard voice search button is tapped with voice search 1975 // Called when the keyboard voice search button is tapped with voice search
1973 // disabled. Hides the voice search button but takes no other action. 1976 // disabled. Hides the voice search button but takes no other action.
1974 - (void)ignoreVoiceSearch:(id)sender { 1977 - (void)ignoreVoiceSearch:(id)sender {
1975 [_keyboardVoiceSearchButton setHidden:YES]; 1978 [_keyboardVoiceSearchButton setHidden:YES];
1976 } 1979 }
1977 1980
1978 - (LocationBarViewIOS*)locationBar {
1979 return _locationBar.get();
1980 }
1981
1982 - (CGFloat)omniboxLeading { 1981 - (CGFloat)omniboxLeading {
1983 // Compute what the leading (x-origin) position for the omniboox should be 1982 // Compute what the leading (x-origin) position for the omniboox should be
1984 // based on what other controls are active. 1983 // based on what other controls are active.
1985 InterfaceIdiom idiom = IsIPadIdiom() ? IPAD_IDIOM : IPHONE_IDIOM; 1984 InterfaceIdiom idiom = IsIPadIdiom() ? IPAD_IDIOM : IPHONE_IDIOM;
1986 1985
1987 CGFloat trailingPadding = 0.0; 1986 CGFloat trailingPadding = 0.0;
1988 1987
1989 LayoutRect leadingControlLayout = LayoutRectForRectInBoundingRect( 1988 LayoutRect leadingControlLayout = LayoutRectForRectInBoundingRect(
1990 [_backButton frame], [_webToolbar bounds]); 1989 [_backButton frame], [_webToolbar bounds]);
1991 LayoutRect forwardButtonLayout = 1990 LayoutRect forwardButtonLayout =
(...skipping 577 matching lines...) Expand 10 before | Expand all | Expand 10 after
2569 2568
2570 - (BOOL)isPrerenderAnimationRunning { 2569 - (BOOL)isPrerenderAnimationRunning {
2571 return _prerenderAnimating; 2570 return _prerenderAnimating;
2572 } 2571 }
2573 2572
2574 - (OmniboxTextFieldIOS*)omnibox { 2573 - (OmniboxTextFieldIOS*)omnibox {
2575 return _omniBox.get(); 2574 return _omniBox.get();
2576 } 2575 }
2577 2576
2578 @end 2577 @end
OLDNEW

Powered by Google App Engine
This is Rietveld 408576698