OLD | NEW |
1 // Copyright (c) 2009 The Chromium Authors. All rights reserved. | 1 // Copyright (c) 2009 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 CHROME_BROWSER_COCOA_LOCATION_BAR_VIEW_MAC_H_ | 5 #ifndef CHROME_BROWSER_COCOA_LOCATION_BAR_VIEW_MAC_H_ |
6 #define CHROME_BROWSER_COCOA_LOCATION_BAR_VIEW_MAC_H_ | 6 #define CHROME_BROWSER_COCOA_LOCATION_BAR_VIEW_MAC_H_ |
7 | 7 |
8 #import <Cocoa/Cocoa.h> | 8 #import <Cocoa/Cocoa.h> |
9 | 9 |
| 10 #include "base/scoped_nsobject.h" |
10 #include "base/scoped_ptr.h" | 11 #include "base/scoped_ptr.h" |
11 #include "chrome/browser/autocomplete/autocomplete_edit.h" | 12 #include "chrome/browser/autocomplete/autocomplete_edit.h" |
12 #include "chrome/browser/autocomplete/autocomplete_edit_view_mac.h" | 13 #include "chrome/browser/autocomplete/autocomplete_edit_view_mac.h" |
13 #include "chrome/browser/location_bar.h" | 14 #include "chrome/browser/location_bar.h" |
14 | 15 |
15 @class AutocompleteTextField; | 16 @class AutocompleteTextField; |
16 class CommandUpdater; | 17 class CommandUpdater; |
| 18 class Profile; |
17 class ToolbarModel; | 19 class ToolbarModel; |
18 | 20 |
19 // A C++ bridge class that represents the location bar UI element to | 21 // A C++ bridge class that represents the location bar UI element to |
20 // the portable code. Wires up an AutocompleteEditViewMac instance to | 22 // the portable code. Wires up an AutocompleteEditViewMac instance to |
21 // the location bar text field, which handles most of the work. | 23 // the location bar text field, which handles most of the work. |
22 | 24 |
23 class LocationBarViewMac : public AutocompleteEditController, | 25 class LocationBarViewMac : public AutocompleteEditController, |
24 public LocationBar, | 26 public LocationBar, |
25 public LocationBarTesting { | 27 public LocationBarTesting { |
26 public: | 28 public: |
(...skipping 31 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
58 | 60 |
59 virtual void OnAutocompleteAccept(const GURL& url, | 61 virtual void OnAutocompleteAccept(const GURL& url, |
60 WindowOpenDisposition disposition, | 62 WindowOpenDisposition disposition, |
61 PageTransition::Type transition, | 63 PageTransition::Type transition, |
62 const GURL& alternate_nav_url); | 64 const GURL& alternate_nav_url); |
63 virtual void OnChanged(); | 65 virtual void OnChanged(); |
64 virtual void OnInputInProgress(bool in_progress); | 66 virtual void OnInputInProgress(bool in_progress); |
65 virtual SkBitmap GetFavIcon() const; | 67 virtual SkBitmap GetFavIcon() const; |
66 virtual std::wstring GetTitle() const; | 68 virtual std::wstring GetTitle() const; |
67 | 69 |
| 70 NSImage* GetTabButtonImage(); |
| 71 |
| 72 // Internals of OnChanged(), pulled out for purposes of unit |
| 73 // testing. Sets up |field| based on the parameters, which are |
| 74 // pulled from edit_view->model(). |
| 75 static void OnChangedImpl(AutocompleteTextField* field, |
| 76 const std::wstring& keyword, |
| 77 const std::wstring& short_name, |
| 78 const bool is_keyword_hint, |
| 79 const bool show_search_hint, |
| 80 NSImage* image); |
| 81 |
68 private: | 82 private: |
69 scoped_ptr<AutocompleteEditViewMac> edit_view_; | 83 scoped_ptr<AutocompleteEditViewMac> edit_view_; |
70 | 84 |
71 CommandUpdater* command_updater_; // Weak, owned by Browser. | 85 CommandUpdater* command_updater_; // Weak, owned by Browser. |
72 | 86 |
| 87 AutocompleteTextField* field_; // owned by tab controller |
| 88 |
73 // When we get an OnAutocompleteAccept notification from the autocomplete | 89 // When we get an OnAutocompleteAccept notification from the autocomplete |
74 // edit, we save the input string so we can give it back to the browser on | 90 // edit, we save the input string so we can give it back to the browser on |
75 // the LocationBar interface via GetInputString(). | 91 // the LocationBar interface via GetInputString(). |
76 std::wstring location_input_; | 92 std::wstring location_input_; |
77 | 93 |
78 // The user's desired disposition for how their input should be opened. | 94 // The user's desired disposition for how their input should be opened. |
79 WindowOpenDisposition disposition_; | 95 WindowOpenDisposition disposition_; |
80 | 96 |
| 97 Profile* profile_; |
| 98 |
| 99 // Image used in drawing keyword hint. |
| 100 scoped_nsobject<NSImage> tab_button_image_; |
| 101 |
81 // The transition type to use for the navigation. | 102 // The transition type to use for the navigation. |
82 PageTransition::Type transition_; | 103 PageTransition::Type transition_; |
83 | 104 |
84 DISALLOW_COPY_AND_ASSIGN(LocationBarViewMac); | 105 DISALLOW_COPY_AND_ASSIGN(LocationBarViewMac); |
85 }; | 106 }; |
86 | 107 |
87 #endif // CHROME_BROWSER_COCOA_LOCATION_BAR_VIEW_MAC_H_ | 108 #endif // CHROME_BROWSER_COCOA_LOCATION_BAR_VIEW_MAC_H_ |
OLD | NEW |