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 | 7 |
8 #include <string> | 8 #include <string> |
9 #include <vector> | 9 #include <vector> |
10 | 10 |
11 #include "base/compiler_specific.h" | 11 #include "base/compiler_specific.h" |
12 #include "base/memory/weak_ptr.h" | 12 #include "base/memory/weak_ptr.h" |
13 #include "base/prefs/pref_member.h" | 13 #include "base/prefs/pref_member.h" |
14 #include "chrome/browser/extensions/extension_context_menu_model.h" | 14 #include "chrome/browser/extensions/extension_context_menu_model.h" |
15 #include "chrome/browser/search_engines/template_url_service_observer.h" | 15 #include "chrome/browser/search_engines/template_url_service_observer.h" |
16 #include "chrome/browser/ui/omnibox/location_bar.h" | 16 #include "chrome/browser/ui/omnibox/location_bar.h" |
17 #include "chrome/browser/ui/omnibox/omnibox_edit_controller.h" | 17 #include "chrome/browser/ui/omnibox/omnibox_edit_controller.h" |
18 #include "chrome/browser/ui/search/search_model_observer.h" | 18 #include "chrome/browser/ui/search/search_model_observer.h" |
19 #include "chrome/browser/ui/toolbar/toolbar_model.h" | 19 #include "chrome/browser/ui/toolbar/toolbar_model.h" |
20 #include "chrome/browser/ui/views/dropdown_bar_host.h" | 20 #include "chrome/browser/ui/views/dropdown_bar_host.h" |
21 #include "chrome/browser/ui/views/dropdown_bar_host_delegate.h" | 21 #include "chrome/browser/ui/views/dropdown_bar_host_delegate.h" |
22 #include "chrome/browser/ui/views/extensions/extension_popup.h" | 22 #include "chrome/browser/ui/views/extensions/extension_popup.h" |
23 #include "chrome/browser/ui/views/omnibox/omnibox_view_views.h" | 23 #include "chrome/browser/ui/views/omnibox/omnibox_view_views.h" |
24 #include "content/public/browser/notification_observer.h" | 24 #include "content/public/browser/notification_observer.h" |
25 #include "content/public/browser/notification_registrar.h" | 25 #include "content/public/browser/notification_registrar.h" |
| 26 #include "ui/gfx/animation/animation_delegate.h" |
26 #include "ui/gfx/font.h" | 27 #include "ui/gfx/font.h" |
27 #include "ui/gfx/rect.h" | 28 #include "ui/gfx/rect.h" |
28 #include "ui/views/controls/button/button.h" | 29 #include "ui/views/controls/button/button.h" |
29 #include "ui/views/drag_controller.h" | 30 #include "ui/views/drag_controller.h" |
30 | 31 |
31 class ActionBoxButtonView; | 32 class ActionBoxButtonView; |
32 class CommandUpdater; | 33 class CommandUpdater; |
33 class ContentSettingBubbleModelDelegate; | 34 class ContentSettingBubbleModelDelegate; |
34 class ContentSettingImageView; | 35 class ContentSettingImageView; |
35 class EVBubbleView; | 36 class EVBubbleView; |
(...skipping 13 matching lines...) Expand all Loading... |
49 class StarView; | 50 class StarView; |
50 class TemplateURLService; | 51 class TemplateURLService; |
51 class ToolbarOriginChipView; | 52 class ToolbarOriginChipView; |
52 class TranslateIconView; | 53 class TranslateIconView; |
53 class ZoomView; | 54 class ZoomView; |
54 | 55 |
55 namespace content { | 56 namespace content { |
56 struct SSLStatus; | 57 struct SSLStatus; |
57 } | 58 } |
58 | 59 |
| 60 namespace gfx { |
| 61 class SlideAnimation; |
| 62 } |
| 63 |
59 namespace views { | 64 namespace views { |
60 class BubbleDelegateView; | 65 class BubbleDelegateView; |
61 class ImageButton; | 66 class ImageButton; |
62 class ImageView; | 67 class ImageView; |
63 class Label; | 68 class Label; |
64 class LabelButton; | 69 class LabelButton; |
65 class Widget; | 70 class Widget; |
66 } | 71 } |
67 | 72 |
68 ///////////////////////////////////////////////////////////////////////////// | 73 ///////////////////////////////////////////////////////////////////////////// |
69 // | 74 // |
70 // LocationBarView class | 75 // LocationBarView class |
71 // | 76 // |
72 // The LocationBarView class is a View subclass that paints the background | 77 // The LocationBarView class is a View subclass that paints the background |
73 // of the URL bar strip and contains its content. | 78 // of the URL bar strip and contains its content. |
74 // | 79 // |
75 ///////////////////////////////////////////////////////////////////////////// | 80 ///////////////////////////////////////////////////////////////////////////// |
76 class LocationBarView : public LocationBar, | 81 class LocationBarView : public LocationBar, |
77 public LocationBarTesting, | 82 public LocationBarTesting, |
78 public views::View, | 83 public views::View, |
79 public views::ButtonListener, | 84 public views::ButtonListener, |
80 public views::DragController, | 85 public views::DragController, |
81 public OmniboxEditController, | 86 public OmniboxEditController, |
82 public DropdownBarHostDelegate, | 87 public DropdownBarHostDelegate, |
| 88 public gfx::AnimationDelegate, |
83 public TemplateURLServiceObserver, | 89 public TemplateURLServiceObserver, |
84 public content::NotificationObserver, | 90 public content::NotificationObserver, |
85 public SearchModelObserver { | 91 public SearchModelObserver { |
86 public: | 92 public: |
87 // The location bar view's class name. | 93 // The location bar view's class name. |
88 static const char kViewClassName[]; | 94 static const char kViewClassName[]; |
89 | 95 |
90 // DropdownBarHostDelegate: | 96 // DropdownBarHostDelegate: |
91 virtual void SetFocusAndSelection(bool select_all) OVERRIDE; | 97 virtual void SetFocusAndSelection(bool select_all) OVERRIDE; |
92 virtual void SetAnimationOffset(int offset) OVERRIDE; | 98 virtual void SetAnimationOffset(int offset) OVERRIDE; |
93 | 99 |
94 // Returns the offset used while animating. | 100 // Returns the offset used during dropdown animation. |
95 int animation_offset() const { return animation_offset_; } | 101 int dropdown_animation_offset() const { return dropdown_animation_offset_; } |
96 | 102 |
97 class Delegate { | 103 class Delegate { |
98 public: | 104 public: |
99 // Should return the current web contents. | 105 // Should return the current web contents. |
100 virtual content::WebContents* GetWebContents() = 0; | 106 virtual content::WebContents* GetWebContents() = 0; |
101 | 107 |
102 // Returns the InstantController, or NULL if there isn't one. | 108 // Returns the InstantController, or NULL if there isn't one. |
103 virtual InstantController* GetInstant() = 0; | 109 virtual InstantController* GetInstant() = 0; |
104 | 110 |
105 virtual ToolbarModel* GetToolbarModel() = 0; | 111 virtual ToolbarModel* GetToolbarModel() = 0; |
(...skipping 142 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
248 gfx::Point GetLocationBarAnchorPoint() const; | 254 gfx::Point GetLocationBarAnchorPoint() const; |
249 | 255 |
250 OmniboxViewViews* omnibox_view() { return omnibox_view_; } | 256 OmniboxViewViews* omnibox_view() { return omnibox_view_; } |
251 | 257 |
252 views::View* generated_credit_card_view(); | 258 views::View* generated_credit_card_view(); |
253 | 259 |
254 // OmniboxEditController: | 260 // OmniboxEditController: |
255 virtual void Update(const content::WebContents* contents) OVERRIDE; | 261 virtual void Update(const content::WebContents* contents) OVERRIDE; |
256 virtual void OnChanged() OVERRIDE; | 262 virtual void OnChanged() OVERRIDE; |
257 virtual void OnSetFocus() OVERRIDE; | 263 virtual void OnSetFocus() OVERRIDE; |
| 264 virtual void ShowURL() OVERRIDE; |
258 virtual InstantController* GetInstant() OVERRIDE; | 265 virtual InstantController* GetInstant() OVERRIDE; |
259 virtual content::WebContents* GetWebContents() OVERRIDE; | 266 virtual content::WebContents* GetWebContents() OVERRIDE; |
260 virtual ToolbarModel* GetToolbarModel() OVERRIDE; | 267 virtual ToolbarModel* GetToolbarModel() OVERRIDE; |
261 virtual const ToolbarModel* GetToolbarModel() const OVERRIDE; | 268 virtual const ToolbarModel* GetToolbarModel() const OVERRIDE; |
262 | 269 |
263 // views::View: | 270 // views::View: |
264 virtual const char* GetClassName() const OVERRIDE; | 271 virtual const char* GetClassName() const OVERRIDE; |
265 virtual bool HasFocus() const OVERRIDE; | 272 virtual bool HasFocus() const OVERRIDE; |
266 virtual void GetAccessibleState(ui::AXViewState* state) OVERRIDE; | 273 virtual void GetAccessibleState(ui::AXViewState* state) OVERRIDE; |
267 virtual void OnBoundsChanged(const gfx::Rect& previous_bounds) OVERRIDE; | 274 virtual void OnBoundsChanged(const gfx::Rect& previous_bounds) OVERRIDE; |
(...skipping 77 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
345 // Amount of padding built into the standard omnibox icons. | 352 // Amount of padding built into the standard omnibox icons. |
346 static const int kIconInternalPadding; | 353 static const int kIconInternalPadding; |
347 // Amount of padding to place between the origin chip and the leading edge of | 354 // Amount of padding to place between the origin chip and the leading edge of |
348 // the location bar. | 355 // the location bar. |
349 static const int kOriginChipEdgeItemPadding; | 356 static const int kOriginChipEdgeItemPadding; |
350 // Amount of padding built into the origin chip. | 357 // Amount of padding built into the origin chip. |
351 static const int kOriginChipBuiltinPadding; | 358 static const int kOriginChipBuiltinPadding; |
352 // Space between the edge and a bubble. | 359 // Space between the edge and a bubble. |
353 static const int kBubblePadding; | 360 static const int kBubblePadding; |
354 | 361 |
355 protected: | 362 private: |
| 363 // views::View: |
356 virtual void OnFocus() OVERRIDE; | 364 virtual void OnFocus() OVERRIDE; |
357 | 365 |
358 private: | 366 // OmniboxEditController: |
| 367 virtual void HideURL() OVERRIDE; |
| 368 |
| 369 // gfx::AnimationDelegate: |
| 370 virtual void AnimationProgressed(const gfx::Animation* animation) OVERRIDE; |
| 371 virtual void AnimationEnded(const gfx::Animation* animation) OVERRIDE; |
| 372 |
359 typedef std::vector<ContentSettingImageView*> ContentSettingViews; | 373 typedef std::vector<ContentSettingImageView*> ContentSettingViews; |
360 | 374 |
361 friend class PageActionImageView; | 375 friend class PageActionImageView; |
362 friend class PageActionWithBadgeView; | 376 friend class PageActionWithBadgeView; |
363 typedef std::vector<ExtensionAction*> PageActions; | 377 typedef std::vector<ExtensionAction*> PageActions; |
364 typedef std::vector<PageActionWithBadgeView*> PageActionViews; | 378 typedef std::vector<PageActionWithBadgeView*> PageActionViews; |
365 | 379 |
366 // Returns the number of pixels of built-in padding to the left and right for | 380 // Returns the number of pixels of built-in padding to the left and right for |
367 // child views. This is nonzero when touch UI is enabled so as to space out | 381 // child views. This is nonzero when touch UI is enabled so as to space out |
368 // child views for easier targeting. See InitTouchableLocationBarChildView(). | 382 // child views for easier targeting. See InitTouchableLocationBarChildView(). |
(...skipping 40 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
409 bool HasValidSuggestText() const; | 423 bool HasValidSuggestText() const; |
410 | 424 |
411 // Helper to show the first run info bubble. | 425 // Helper to show the first run info bubble. |
412 void ShowFirstRunBubbleInternal(); | 426 void ShowFirstRunBubbleInternal(); |
413 | 427 |
414 // Handles a request to change the value of this text field from software | 428 // Handles a request to change the value of this text field from software |
415 // using an accessibility API (typically automation software, screen readers | 429 // using an accessibility API (typically automation software, screen readers |
416 // don't normally use this). Sets the value and clears the selection. | 430 // don't normally use this). Sets the value and clears the selection. |
417 void AccessibilitySetValue(const base::string16& new_value); | 431 void AccessibilitySetValue(const base::string16& new_value); |
418 | 432 |
| 433 // Origin chip animation control methods. |
| 434 void OnShowURLAnimationEnded(); |
| 435 void OnHideURLAnimationEnded(); |
| 436 |
419 // The Browser this LocationBarView is in. Note that at least | 437 // The Browser this LocationBarView is in. Note that at least |
420 // chromeos::SimpleWebViewDialog uses a LocationBarView outside any browser | 438 // chromeos::SimpleWebViewDialog uses a LocationBarView outside any browser |
421 // window, so this may be NULL. | 439 // window, so this may be NULL. |
422 Browser* browser_; | 440 Browser* browser_; |
423 | 441 |
424 OmniboxViewViews* omnibox_view_; | 442 OmniboxViewViews* omnibox_view_; |
425 | 443 |
426 // Our delegate. | 444 // Our delegate. |
427 Delegate* delegate_; | 445 Delegate* delegate_; |
428 | 446 |
(...skipping 75 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
504 // focused. Used when the toolbar is in full keyboard accessibility mode. | 522 // focused. Used when the toolbar is in full keyboard accessibility mode. |
505 bool show_focus_rect_; | 523 bool show_focus_rect_; |
506 | 524 |
507 // This is in case we're destroyed before the model loads. We need to make | 525 // This is in case we're destroyed before the model loads. We need to make |
508 // Add/RemoveObserver calls. | 526 // Add/RemoveObserver calls. |
509 TemplateURLService* template_url_service_; | 527 TemplateURLService* template_url_service_; |
510 | 528 |
511 // Tracks this preference to determine whether bookmark editing is allowed. | 529 // Tracks this preference to determine whether bookmark editing is allowed. |
512 BooleanPrefMember edit_bookmarks_enabled_; | 530 BooleanPrefMember edit_bookmarks_enabled_; |
513 | 531 |
514 // While animating, the host clips the widget and draws only the bottom | 532 // During dropdown animation, the host clips the widget and draws only the |
515 // part of it. The view needs to know the pixel offset at which we are drawing | 533 // bottom part of it. The view needs to know the pixel offset at which we are |
516 // the widget so that we can draw the curved edges that attach to the toolbar | 534 // drawing the widget so that we can draw the curved edges that attach to the |
517 // in the right location. | 535 // toolbar in the right location. |
518 int animation_offset_; | 536 int dropdown_animation_offset_; |
| 537 |
| 538 // Origin chip animations. |
| 539 scoped_ptr<gfx::SlideAnimation> show_url_animation_; |
| 540 scoped_ptr<gfx::SlideAnimation> hide_url_animation_; |
| 541 |
| 542 // Text label shown only during origin chip animations. |
| 543 views::Label* animated_host_label_; |
519 | 544 |
520 // Used to register for notifications received by NotificationObserver. | 545 // Used to register for notifications received by NotificationObserver. |
521 content::NotificationRegistrar registrar_; | 546 content::NotificationRegistrar registrar_; |
522 | 547 |
523 // Used to bind callback functions to this object. | 548 // Used to bind callback functions to this object. |
524 base::WeakPtrFactory<LocationBarView> weak_ptr_factory_; | 549 base::WeakPtrFactory<LocationBarView> weak_ptr_factory_; |
525 | 550 |
526 DISALLOW_COPY_AND_ASSIGN(LocationBarView); | 551 DISALLOW_COPY_AND_ASSIGN(LocationBarView); |
527 }; | 552 }; |
528 | 553 |
529 #endif // CHROME_BROWSER_UI_VIEWS_LOCATION_BAR_LOCATION_BAR_VIEW_H_ | 554 #endif // CHROME_BROWSER_UI_VIEWS_LOCATION_BAR_LOCATION_BAR_VIEW_H_ |
OLD | NEW |