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

Side by Side Diff: ios/chrome/browser/ui/omnibox/location_bar_controller_impl.h

Issue 2796793003: [ios] Adds a LocationBarController interface. (Closed)
Patch Set: Review. 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 (c) 2012 The Chromium Authors. All rights reserved. 1 // Copyright (c) 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 #ifndef IOS_CHROME_BROWSER_UI_OMNIBOX_LOCATION_BAR_VIEW_IOS_H_ 5 #ifndef IOS_CHROME_BROWSER_UI_OMNIBOX_LOCATION_BAR_CONTROLLER_IMPL_H_
6 #define IOS_CHROME_BROWSER_UI_OMNIBOX_LOCATION_BAR_VIEW_IOS_H_ 6 #define IOS_CHROME_BROWSER_UI_OMNIBOX_LOCATION_BAR_CONTROLLER_IMPL_H_
7 7
8 #import <UIKit/UIKit.h> 8 #import <UIKit/UIKit.h>
9 9
10 #include <memory> 10 #include <memory>
11 11
12 #include "base/mac/scoped_nsobject.h" 12 #include "base/mac/scoped_nsobject.h"
13 #include "base/strings/utf_string_conversions.h" 13 #include "base/strings/utf_string_conversions.h"
14 #include "components/omnibox/browser/omnibox_view.h" 14 #include "components/omnibox/browser/omnibox_view.h"
15 #include "ios/chrome/browser/ui/omnibox/web_omnibox_edit_controller.h" 15 #include "ios/shared/chrome/browser/ui/omnibox/location_bar_controller.h"
16 #include "ui/base/page_transition_types.h" 16 #include "ui/base/page_transition_types.h"
17 #include "url/gurl.h" 17 #include "url/gurl.h"
18 18
19 namespace ios { 19 namespace ios {
20 class ChromeBrowserState; 20 class ChromeBrowserState;
21 } 21 }
22 22
23 namespace web { 23 namespace web {
24 class WebState; 24 class WebState;
25 } 25 }
26 26
27 @protocol LocationBarDelegate;
27 class OmniboxViewIOS; 28 class OmniboxViewIOS;
28 @class OmniboxClearButtonBridge; 29 @class OmniboxClearButtonBridge;
29 @protocol OmniboxPopupPositioner; 30 @protocol OmniboxPopupPositioner;
30 @class OmniboxTextFieldIOS; 31 @class OmniboxTextFieldIOS;
31 @protocol PreloadProvider; 32 @protocol PreloadProvider;
32 class ToolbarModel; 33 class ToolbarModel;
33 34
34 // Delegate for LocationBarViewIOS objects. Used to provide the location bar a 35 // Concrete implementation of the LocationBarController interface.
35 // way to open URLs and otherwise interact with the browser. 36 class LocationBarControllerImpl : public LocationBarController {
36 @protocol LocationBarDelegate
37 - (void)loadGURLFromLocationBar:(const GURL&)url
38 transition:(ui::PageTransition)transition;
39 - (void)locationBarHasBecomeFirstResponder;
40 - (void)locationBarHasResignedFirstResponder;
41 - (void)locationBarBeganEdit;
42 - (void)locationBarChanged;
43 - (web::WebState*)getWebState;
44 - (ToolbarModel*)toolbarModel;
45 @end
46
47 // C++ object that wraps an OmniboxViewIOS and serves as its
48 // OmniboxEditController. LocationBarViewIOS bridges between the edit view
49 // and the rest of the browser and manages text field decorations (location
50 // icon, security icon, etc.).
51 class LocationBarViewIOS : public WebOmniboxEditController {
52 public: 37 public:
53 LocationBarViewIOS(OmniboxTextFieldIOS* field, 38 LocationBarControllerImpl(OmniboxTextFieldIOS* field,
54 ios::ChromeBrowserState* browser_state, 39 ios::ChromeBrowserState* browser_state,
55 id<PreloadProvider> preloader, 40 id<PreloadProvider> preloader,
56 id<OmniboxPopupPositioner> positioner, 41 id<OmniboxPopupPositioner> positioner,
57 id<LocationBarDelegate> delegate); 42 id<LocationBarDelegate> delegate);
58 ~LocationBarViewIOS() override; 43 ~LocationBarControllerImpl() override;
59 44
60 // OmniboxEditController implementation 45 // OmniboxEditController implementation
61 void OnAutocompleteAccept(const GURL& url, 46 void OnAutocompleteAccept(const GURL& url,
62 WindowOpenDisposition disposition, 47 WindowOpenDisposition disposition,
63 ui::PageTransition transition, 48 ui::PageTransition transition,
64 AutocompleteMatchType::Type type) override; 49 AutocompleteMatchType::Type type) override;
65 void OnChanged() override; 50 void OnChanged() override;
66 void OnInputInProgress(bool in_progress) override; 51 void OnInputInProgress(bool in_progress) override;
67 void OnSetFocus() override; 52 void OnSetFocus() override;
68 ToolbarModel* GetToolbarModel() override; 53 ToolbarModel* GetToolbarModel() override;
69 const ToolbarModel* GetToolbarModel() const override; 54 const ToolbarModel* GetToolbarModel() const override;
70 55
71 // WebOmniboxEditController implementation. 56 // WebOmniboxEditController implementation.
72 web::WebState* GetWebState() override; 57 web::WebState* GetWebState() override;
73 void OnKillFocus() override; 58 void OnKillFocus() override;
74 59
75 // Called when toolbar state is updated. 60 // LocationBarController implementation.
76 void OnToolbarUpdated(); 61 void OnToolbarUpdated() override;
77 62 void HideKeyboardAndEndEditing() override;
78 // Resign omnibox first responder and end edit view editing. 63 void SetShouldShowHintText(bool show_hint_text) override;
79 void HideKeyboardAndEndEditing(); 64 const OmniboxView* GetLocationEntry() const override;
80 65 OmniboxView* GetLocationEntry() override;
81 // Tells the omnibox if it can show the hint text or not. 66 bool IsShowingPlaceholderWhileCollapsed() override;
82 void SetShouldShowHintText(bool show_hint_text);
83
84 // Returns a pointer to the text entry view.
85 const OmniboxView* GetLocationEntry() const;
86 OmniboxView* GetLocationEntry();
87
88 // True if the omnibox text field is showing a placeholder image in its left
89 // view while it's collapsed (i.e. not in editing mode).
90 bool IsShowingPlaceholderWhileCollapsed();
91 67
92 private: 68 private:
93 // Installs a UIButton that serves as the location icon and lock icon. This 69 // Installs a UIButton that serves as the location icon and lock icon. This
94 // button is installed as a left view of |field_|. 70 // button is installed as a left view of |field_|.
95 void InstallLocationIcon(); 71 void InstallLocationIcon();
96 72
97 // Creates and installs the voice search UIButton as a right view of |field_|. 73 // Creates and installs the voice search UIButton as a right view of |field_|.
98 // Does nothing on tablet. 74 // Does nothing on tablet.
99 void InstallVoiceSearchIcon(); 75 void InstallVoiceSearchIcon();
100 76
101 // Creates the clear text UIButton to be used as a right view of |field_|. 77 // Creates the clear text UIButton to be used as a right view of |field_|.
102 void CreateClearTextIcon(bool is_incognito); 78 void CreateClearTextIcon(bool is_incognito);
103 79
104 // Updates the view to show the appropriate button (e.g. clear text or voice 80 // Updates the view to show the appropriate button (e.g. clear text or voice
105 // search) on the right side of |field_|. 81 // search) on the right side of |field_|.
106 void UpdateRightDecorations(); 82 void UpdateRightDecorations();
107 83
108 bool show_hint_text_; 84 bool show_hint_text_;
109 base::scoped_nsobject<UIButton> clear_text_button_; 85 base::scoped_nsobject<UIButton> clear_text_button_;
110 std::unique_ptr<OmniboxViewIOS> edit_view_; 86 std::unique_ptr<OmniboxViewIOS> edit_view_;
111 base::scoped_nsobject<OmniboxClearButtonBridge> clear_button_bridge_; 87 base::scoped_nsobject<OmniboxClearButtonBridge> clear_button_bridge_;
112 // |field_| should be __weak but is included from non-ARC code. 88 // |field_| should be __weak but is included from non-ARC code.
113 __unsafe_unretained OmniboxTextFieldIOS* field_; 89 __unsafe_unretained OmniboxTextFieldIOS* field_;
114 // |delegate_| should be __weak but is included from non-ARC code. 90 // |delegate_| should be __weak but is included from non-ARC code.
115 __unsafe_unretained id<LocationBarDelegate> delegate_; 91 __unsafe_unretained id<LocationBarDelegate> delegate_;
116 bool is_showing_placeholder_while_collapsed_; 92 bool is_showing_placeholder_while_collapsed_;
117 }; 93 };
118 94
119 #endif // IOS_CHROME_BROWSER_UI_OMNIBOX_LOCATION_BAR_VIEW_IOS_H_ 95 #endif // IOS_CHROME_BROWSER_UI_OMNIBOX_LOCATION_BAR_CONTROLLER_IMPL_H_
OLDNEW

Powered by Google App Engine
This is Rietveld 408576698