OLD | NEW |
1 // Copyright (c) 2010 The Chromium Authors. All rights reserved. | 1 // Copyright (c) 2010 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_VIEWS_LOCATION_BAR_LOCATION_BAR_VIEW_H_ | 5 #ifndef CHROME_BROWSER_VIEWS_LOCATION_BAR_LOCATION_BAR_VIEW_H_ |
6 #define CHROME_BROWSER_VIEWS_LOCATION_BAR_LOCATION_BAR_VIEW_H_ | 6 #define CHROME_BROWSER_VIEWS_LOCATION_BAR_LOCATION_BAR_VIEW_H_ |
7 | 7 |
8 #include <string> | 8 #include <string> |
9 #include <vector> | 9 #include <vector> |
10 | 10 |
11 #include "base/task.h" | 11 #include "base/task.h" |
12 #include "chrome/browser/autocomplete/autocomplete_edit.h" | 12 #include "chrome/browser/autocomplete/autocomplete_edit.h" |
13 #include "chrome/browser/extensions/extension_context_menu_model.h" | 13 #include "chrome/browser/extensions/extension_context_menu_model.h" |
14 #include "chrome/browser/first_run.h" | 14 #include "chrome/browser/first_run.h" |
15 #include "chrome/browser/location_bar.h" | 15 #include "chrome/browser/location_bar.h" |
| 16 #include "chrome/browser/search_engines/template_url_model.h" |
16 #include "chrome/browser/tab_contents/tab_contents.h" | 17 #include "chrome/browser/tab_contents/tab_contents.h" |
17 #include "chrome/browser/toolbar_model.h" | 18 #include "chrome/browser/toolbar_model.h" |
18 #include "chrome/browser/views/extensions/extension_popup.h" | 19 #include "chrome/browser/views/extensions/extension_popup.h" |
19 #include "chrome/common/notification_observer.h" | 20 #include "chrome/common/notification_observer.h" |
20 #include "chrome/common/notification_registrar.h" | 21 #include "chrome/common/notification_registrar.h" |
21 #include "gfx/font.h" | 22 #include "gfx/font.h" |
22 #include "gfx/rect.h" | 23 #include "gfx/rect.h" |
23 #include "views/controls/native/native_view_host.h" | 24 #include "views/controls/native/native_view_host.h" |
24 | 25 |
25 #if defined(OS_WIN) | 26 #if defined(OS_WIN) |
(...skipping 25 matching lines...) Expand all Loading... |
51 // LocationBarView class | 52 // LocationBarView class |
52 // | 53 // |
53 // The LocationBarView class is a View subclass that paints the background | 54 // The LocationBarView class is a View subclass that paints the background |
54 // of the URL bar strip and contains its content. | 55 // of the URL bar strip and contains its content. |
55 // | 56 // |
56 ///////////////////////////////////////////////////////////////////////////// | 57 ///////////////////////////////////////////////////////////////////////////// |
57 class LocationBarView : public LocationBar, | 58 class LocationBarView : public LocationBar, |
58 public LocationBarTesting, | 59 public LocationBarTesting, |
59 public views::View, | 60 public views::View, |
60 public views::DragController, | 61 public views::DragController, |
61 public AutocompleteEditController { | 62 public AutocompleteEditController, |
| 63 public TemplateURLModelObserver { |
62 public: | 64 public: |
63 // The location bar view's class name. | 65 // The location bar view's class name. |
64 static const char kViewClassName[]; | 66 static const char kViewClassName[]; |
65 | 67 |
66 class Delegate { | 68 class Delegate { |
67 public: | 69 public: |
68 // Should return the current tab contents. | 70 // Should return the current tab contents. |
69 virtual TabContents* GetTabContents() = 0; | 71 virtual TabContents* GetTabContents() = 0; |
70 | 72 |
71 // Called by the location bar view when the user starts typing in the edit. | 73 // Called by the location bar view when the user starts typing in the edit. |
(...skipping 24 matching lines...) Expand all Loading... |
96 | 98 |
97 LocationBarView(Profile* profile, | 99 LocationBarView(Profile* profile, |
98 CommandUpdater* command_updater, | 100 CommandUpdater* command_updater, |
99 ToolbarModel* model, | 101 ToolbarModel* model, |
100 Delegate* delegate, | 102 Delegate* delegate, |
101 Mode mode); | 103 Mode mode); |
102 virtual ~LocationBarView(); | 104 virtual ~LocationBarView(); |
103 | 105 |
104 void Init(); | 106 void Init(); |
105 | 107 |
106 // Returns whether this instance has been initialized by callin Init. Init can | 108 // True if this instance has been initialized by calling Init, which can only |
107 // only be called when the receiving instance is attached to a view container. | 109 // be called when the receiving instance is attached to a view container. |
108 bool IsInitialized() const; | 110 bool IsInitialized() const; |
109 | 111 |
110 // Returns the appropriate color for the desired kind, based on the user's | 112 // Returns the appropriate color for the desired kind, based on the user's |
111 // system theme. | 113 // system theme. |
112 static SkColor GetColor(ToolbarModel::SecurityLevel security_level, | 114 static SkColor GetColor(ToolbarModel::SecurityLevel security_level, |
113 ColorKind kind); | 115 ColorKind kind); |
114 | 116 |
115 // Updates the location bar. We also reset the bar's permanent text and | 117 // Updates the location bar. We also reset the bar's permanent text and |
116 // security style, and, if |tab_for_state_restoring| is non-NULL, also restore | 118 // security style, and, if |tab_for_state_restoring| is non-NULL, also restore |
117 // saved state that the tab holds. | 119 // saved state that the tab holds. |
(...skipping 95 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
213 } | 215 } |
214 virtual LocationBarTesting* GetLocationBarForTesting() { return this; } | 216 virtual LocationBarTesting* GetLocationBarForTesting() { return this; } |
215 | 217 |
216 // Overridden from LocationBarTesting: | 218 // Overridden from LocationBarTesting: |
217 virtual int PageActionCount() { return page_action_views_.size(); } | 219 virtual int PageActionCount() { return page_action_views_.size(); } |
218 virtual int PageActionVisibleCount(); | 220 virtual int PageActionVisibleCount(); |
219 virtual ExtensionAction* GetPageAction(size_t index); | 221 virtual ExtensionAction* GetPageAction(size_t index); |
220 virtual ExtensionAction* GetVisiblePageAction(size_t index); | 222 virtual ExtensionAction* GetVisiblePageAction(size_t index); |
221 virtual void TestPageActionPressed(size_t index); | 223 virtual void TestPageActionPressed(size_t index); |
222 | 224 |
| 225 // Overridden from TemplateURLModelObserver |
| 226 virtual void OnTemplateURLModelChanged(); |
| 227 |
223 static const int kVertMargin; // Space above and below the edit. | 228 static const int kVertMargin; // Space above and below the edit. |
224 static const int kEdgeThickness; // Unavailable space at horizontal edges. | 229 static const int kEdgeThickness; // Unavailable space at horizontal edges. |
225 static const int kItemPadding; // Space between items within the bar. | 230 static const int kItemPadding; // Space between items within the bar. |
226 | 231 |
227 protected: | 232 protected: |
228 void Focus(); | 233 void Focus(); |
229 | 234 |
230 private: | 235 private: |
231 typedef std::vector<ContentSettingImageView*> ContentSettingViews; | 236 typedef std::vector<ContentSettingImageView*> ContentSettingViews; |
232 | 237 |
(...skipping 111 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
344 // The star. | 349 // The star. |
345 StarView* star_view_; | 350 StarView* star_view_; |
346 | 351 |
347 // The mode that dictates how the bar shows. | 352 // The mode that dictates how the bar shows. |
348 Mode mode_; | 353 Mode mode_; |
349 | 354 |
350 // True if we should show a focus rect while the location entry field is | 355 // True if we should show a focus rect while the location entry field is |
351 // focused. Used when the toolbar is in full keyboard accessibility mode. | 356 // focused. Used when the toolbar is in full keyboard accessibility mode. |
352 bool show_focus_rect_; | 357 bool show_focus_rect_; |
353 | 358 |
| 359 // Whether bubble text is short or long. |
| 360 FirstRun::BubbleType bubble_type_; |
| 361 |
| 362 // This is in case we're destroyed before the model loads. We store the model |
| 363 // because calling profile_->GetTemplateURLModel() in the destructor causes a |
| 364 // crash. |
| 365 TemplateURLModel* template_url_model_; |
| 366 |
354 #if defined(OS_LINUX) | 367 #if defined(OS_LINUX) |
355 scoped_ptr<AccessibleWidgetHelper> accessible_widget_helper_; | 368 scoped_ptr<AccessibleWidgetHelper> accessible_widget_helper_; |
356 #endif | 369 #endif |
357 | 370 |
358 // Used to schedule a task for the first run info bubble. | |
359 ScopedRunnableMethodFactory<LocationBarView> first_run_bubble_; | |
360 | |
361 DISALLOW_IMPLICIT_CONSTRUCTORS(LocationBarView); | 371 DISALLOW_IMPLICIT_CONSTRUCTORS(LocationBarView); |
362 }; | 372 }; |
363 | 373 |
364 #endif // CHROME_BROWSER_VIEWS_LOCATION_BAR_LOCATION_BAR_VIEW_H_ | 374 #endif // CHROME_BROWSER_VIEWS_LOCATION_BAR_LOCATION_BAR_VIEW_H_ |
OLD | NEW |