OLD | NEW |
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 CHROME_BROWSER_UI_VIEWS_LOCATION_BAR_LOCATION_BAR_VIEW_H_ | 5 #ifndef CHROME_BROWSER_UI_VIEWS_LOCATION_BAR_LOCATION_BAR_VIEW_H_ |
6 #define CHROME_BROWSER_UI_VIEWS_LOCATION_BAR_LOCATION_BAR_VIEW_H_ | 6 #define CHROME_BROWSER_UI_VIEWS_LOCATION_BAR_LOCATION_BAR_VIEW_H_ |
7 #pragma once | 7 #pragma once |
8 | 8 |
9 #include <string> | 9 #include <string> |
10 #include <vector> | 10 #include <vector> |
(...skipping 14 matching lines...) Expand all Loading... |
25 #include "ui/views/drag_controller.h" | 25 #include "ui/views/drag_controller.h" |
26 | 26 |
27 #if defined(USE_AURA) | 27 #if defined(USE_AURA) |
28 #include "chrome/browser/ui/views/omnibox/omnibox_view_views.h" | 28 #include "chrome/browser/ui/views/omnibox/omnibox_view_views.h" |
29 #elif defined(OS_WIN) | 29 #elif defined(OS_WIN) |
30 #include "chrome/browser/ui/views/omnibox/omnibox_view_win.h" | 30 #include "chrome/browser/ui/views/omnibox/omnibox_view_win.h" |
31 #elif defined(TOOLKIT_USES_GTK) | 31 #elif defined(TOOLKIT_USES_GTK) |
32 #include "chrome/browser/ui/gtk/omnibox/omnibox_view_gtk.h" | 32 #include "chrome/browser/ui/gtk/omnibox/omnibox_view_gtk.h" |
33 #endif | 33 #endif |
34 | 34 |
| 35 class Browser; |
35 class ChromeToMobileView; | 36 class ChromeToMobileView; |
36 class CommandUpdater; | |
37 class ContentSettingBubbleModelDelegate; | |
38 class ContentSettingImageView; | 37 class ContentSettingImageView; |
39 class EVBubbleView; | 38 class EVBubbleView; |
40 class ExtensionAction; | 39 class ExtensionAction; |
41 class GURL; | 40 class GURL; |
42 class InstantController; | 41 class InstantController; |
43 class KeywordHintView; | 42 class KeywordHintView; |
44 class LocationIconView; | 43 class LocationIconView; |
45 class PageActionWithBadgeView; | 44 class PageActionWithBadgeView; |
46 class PageActionImageView; | |
47 class Profile; | |
48 class SelectedKeywordView; | 45 class SelectedKeywordView; |
49 class StarView; | 46 class StarView; |
50 class TabContentsWrapper; | 47 class TabContentsWrapper; |
51 class TemplateURLService; | 48 class TemplateURLService; |
52 | 49 |
53 namespace views { | |
54 class BubbleDelegateView; | |
55 class Widget; | |
56 } | |
57 | |
58 #if defined(OS_WIN) || defined(USE_AURA) | 50 #if defined(OS_WIN) || defined(USE_AURA) |
59 class SuggestedTextView; | 51 class SuggestedTextView; |
60 #endif | 52 #endif |
61 | 53 |
62 ///////////////////////////////////////////////////////////////////////////// | 54 ///////////////////////////////////////////////////////////////////////////// |
63 // | 55 // |
64 // LocationBarView class | 56 // LocationBarView class |
65 // | 57 // |
66 // The LocationBarView class is a View subclass that paints the background | 58 // The LocationBarView class is a View subclass that paints the background |
67 // of the URL bar strip and contains its content. | 59 // of the URL bar strip and contains its content. |
(...skipping 19 matching lines...) Expand all Loading... |
87 int animation_offset() const { return animation_offset_; } | 79 int animation_offset() const { return animation_offset_; } |
88 | 80 |
89 class Delegate { | 81 class Delegate { |
90 public: | 82 public: |
91 // Should return the current tab contents. | 83 // Should return the current tab contents. |
92 virtual TabContentsWrapper* GetTabContentsWrapper() const = 0; | 84 virtual TabContentsWrapper* GetTabContentsWrapper() const = 0; |
93 | 85 |
94 // Returns the InstantController, or NULL if there isn't one. | 86 // Returns the InstantController, or NULL if there isn't one. |
95 virtual InstantController* GetInstant() = 0; | 87 virtual InstantController* GetInstant() = 0; |
96 | 88 |
97 // Creates Widget for the given delegate. | |
98 virtual views::Widget* CreateViewsBubble( | |
99 views::BubbleDelegateView* bubble_delegate) = 0; | |
100 | |
101 // Creates PageActionImageView. Caller gets an ownership. | |
102 virtual PageActionImageView* CreatePageActionImageView( | |
103 LocationBarView* owner, | |
104 ExtensionAction* action) = 0; | |
105 | |
106 // Returns ContentSettingBubbleModelDelegate. | |
107 virtual ContentSettingBubbleModelDelegate* | |
108 GetContentSettingBubbleModelDelegate() = 0; | |
109 | |
110 // Shows page information in the given web contents. | |
111 virtual void ShowPageInfo(content::WebContents* web_contents, | |
112 const GURL& url, | |
113 const content::SSLStatus& ssl, | |
114 bool show_history) = 0; | |
115 | |
116 // Called by the location bar view when the user starts typing in the edit. | 89 // Called by the location bar view when the user starts typing in the edit. |
117 // This forces our security style to be UNKNOWN for the duration of the | 90 // This forces our security style to be UNKNOWN for the duration of the |
118 // editing. | 91 // editing. |
119 virtual void OnInputInProgress(bool in_progress) = 0; | 92 virtual void OnInputInProgress(bool in_progress) = 0; |
120 | |
121 protected: | |
122 virtual ~Delegate() {} | |
123 }; | 93 }; |
124 | 94 |
125 enum ColorKind { | 95 enum ColorKind { |
126 BACKGROUND = 0, | 96 BACKGROUND = 0, |
127 TEXT, | 97 TEXT, |
128 SELECTED_TEXT, | 98 SELECTED_TEXT, |
129 DEEMPHASIZED_TEXT, | 99 DEEMPHASIZED_TEXT, |
130 SECURITY_TEXT, | 100 SECURITY_TEXT, |
131 }; | 101 }; |
132 | 102 |
133 // The modes reflect the different scenarios where a location bar can be used. | 103 // The modes reflect the different scenarios where a location bar can be used. |
134 // The normal mode is the mode used in a regular browser window. | 104 // The normal mode is the mode used in a regular browser window. |
135 // In popup mode, the location bar view is read only and has a slightly | 105 // In popup mode, the location bar view is read only and has a slightly |
136 // different presentation (font size / color). | 106 // different presentation (font size / color). |
137 // In app launcher mode, the location bar is empty and no security states or | 107 // In app launcher mode, the location bar is empty and no security states or |
138 // page/browser actions are displayed. | 108 // page/browser actions are displayed. |
139 enum Mode { | 109 enum Mode { |
140 NORMAL = 0, | 110 NORMAL = 0, |
141 POPUP, | 111 POPUP, |
142 APP_LAUNCHER | 112 APP_LAUNCHER |
143 }; | 113 }; |
144 | 114 |
145 LocationBarView(Profile* profile, | 115 LocationBarView(Browser* browser, |
146 CommandUpdater* command_updater, | |
147 ToolbarModel* model, | 116 ToolbarModel* model, |
148 Delegate* delegate, | 117 Delegate* delegate, |
149 Mode mode); | 118 Mode mode); |
150 | |
151 virtual ~LocationBarView(); | 119 virtual ~LocationBarView(); |
152 | 120 |
153 void Init(); | 121 void Init(); |
154 | 122 |
155 // True if this instance has been initialized by calling Init, which can only | 123 // True if this instance has been initialized by calling Init, which can only |
156 // be called when the receiving instance is attached to a view container. | 124 // be called when the receiving instance is attached to a view container. |
157 bool IsInitialized() const; | 125 bool IsInitialized() const; |
158 | 126 |
159 // Returns the appropriate color for the desired kind, based on the user's | 127 // Returns the appropriate color for the desired kind, based on the user's |
160 // system theme. | 128 // system theme. |
161 static SkColor GetColor(ToolbarModel::SecurityLevel security_level, | 129 static SkColor GetColor(ToolbarModel::SecurityLevel security_level, |
162 ColorKind kind); | 130 ColorKind kind); |
163 | 131 |
164 // Updates the location bar. We also reset the bar's permanent text and | 132 // Updates the location bar. We also reset the bar's permanent text and |
165 // security style, and, if |tab_for_state_restoring| is non-NULL, also restore | 133 // security style, and, if |tab_for_state_restoring| is non-NULL, also restore |
166 // saved state that the tab holds. | 134 // saved state that the tab holds. |
167 void Update(const content::WebContents* tab_for_state_restoring); | 135 void Update(const content::WebContents* tab_for_state_restoring); |
168 | 136 |
169 // Returns corresponding profile. | 137 Browser* browser() const { return browser_; } |
170 Profile* profile() const { return profile_; } | |
171 | |
172 // Returns the delegate. | |
173 Delegate* delegate() const { return delegate_; } | |
174 | 138 |
175 // Sets |preview_enabled| for the PageAction View associated with this | 139 // Sets |preview_enabled| for the PageAction View associated with this |
176 // |page_action|. If |preview_enabled| is true, the view will display the | 140 // |page_action|. If |preview_enabled| is true, the view will display the |
177 // PageActions icon even though it has not been activated by the extension. | 141 // PageActions icon even though it has not been activated by the extension. |
178 // This is used by the ExtensionInstalledBubble to preview what the icon | 142 // This is used by the ExtensionInstalledBubble to preview what the icon |
179 // will look like for the user upon installation of the extension. | 143 // will look like for the user upon installation of the extension. |
180 void SetPreviewEnabledPageAction(ExtensionAction *page_action, | 144 void SetPreviewEnabledPageAction(ExtensionAction *page_action, |
181 bool preview_enabled); | 145 bool preview_enabled); |
182 | 146 |
183 // Retrieves the PageAction View which is associated with |page_action|. | 147 // Retrieves the PageAction View which is associated with |page_action|. |
(...skipping 197 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
381 OmniboxViewWin* GetOmniboxViewWin(); | 345 OmniboxViewWin* GetOmniboxViewWin(); |
382 #endif | 346 #endif |
383 #endif | 347 #endif |
384 | 348 |
385 // Helper to show the first run info bubble. | 349 // Helper to show the first run info bubble. |
386 void ShowFirstRunBubbleInternal(); | 350 void ShowFirstRunBubbleInternal(); |
387 | 351 |
388 // The Autocomplete Edit field. | 352 // The Autocomplete Edit field. |
389 scoped_ptr<OmniboxView> location_entry_; | 353 scoped_ptr<OmniboxView> location_entry_; |
390 | 354 |
391 // The profile which corresponds to this View. | 355 // The Browser object that corresponds to this View. |
392 Profile* profile_; | 356 Browser* browser_; |
393 | |
394 // Command updater which corresponds to this View. | |
395 CommandUpdater* command_updater_; | |
396 | 357 |
397 // The model. | 358 // The model. |
398 ToolbarModel* model_; | 359 ToolbarModel* model_; |
399 | 360 |
400 // Our delegate. | 361 // Our delegate. |
401 Delegate* delegate_; | 362 Delegate* delegate_; |
402 | 363 |
403 // This is the string of text from the autocompletion session that the user | 364 // This is the string of text from the autocompletion session that the user |
404 // entered or selected. | 365 // entered or selected. |
405 string16 location_input_; | 366 string16 location_input_; |
(...skipping 66 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
472 // While animating, the host clips the widget and draws only the bottom | 433 // While animating, the host clips the widget and draws only the bottom |
473 // part of it. The view needs to know the pixel offset at which we are drawing | 434 // part of it. The view needs to know the pixel offset at which we are drawing |
474 // the widget so that we can draw the curved edges that attach to the toolbar | 435 // the widget so that we can draw the curved edges that attach to the toolbar |
475 // in the right location. | 436 // in the right location. |
476 int animation_offset_; | 437 int animation_offset_; |
477 | 438 |
478 DISALLOW_IMPLICIT_CONSTRUCTORS(LocationBarView); | 439 DISALLOW_IMPLICIT_CONSTRUCTORS(LocationBarView); |
479 }; | 440 }; |
480 | 441 |
481 #endif // CHROME_BROWSER_UI_VIEWS_LOCATION_BAR_LOCATION_BAR_VIEW_H_ | 442 #endif // CHROME_BROWSER_UI_VIEWS_LOCATION_BAR_LOCATION_BAR_VIEW_H_ |
OLD | NEW |