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

Side by Side Diff: chrome/browser/ui/views/location_bar/location_bar_view.h

Issue 200783003: [OriginChip] Add animations for the hiding and showing of the chip. (Closed) Base URL: svn://svn.chromium.org/chrome/trunk/src
Patch Set: Respond to comments, merge Created 6 years, 9 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 | Annotate | Revision Log
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 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
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 animation_offset() const { return 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
(...skipping 143 matching lines...) Expand 10 before | Expand all | Expand 10 after
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
270 // gfx::AnimationDelegate:
271 virtual void AnimationProgressed(const gfx::Animation* animation) OVERRIDE;
272 virtual void AnimationEnded(const gfx::Animation* animation) OVERRIDE;
273
263 // views::View: 274 // views::View:
264 virtual const char* GetClassName() const OVERRIDE; 275 virtual const char* GetClassName() const OVERRIDE;
265 virtual bool HasFocus() const OVERRIDE; 276 virtual bool HasFocus() const OVERRIDE;
266 virtual void GetAccessibleState(ui::AXViewState* state) OVERRIDE; 277 virtual void GetAccessibleState(ui::AXViewState* state) OVERRIDE;
267 virtual void OnBoundsChanged(const gfx::Rect& previous_bounds) OVERRIDE; 278 virtual void OnBoundsChanged(const gfx::Rect& previous_bounds) OVERRIDE;
268 279
269 // views::ButtonListener: 280 // views::ButtonListener:
270 virtual void ButtonPressed(views::Button* sender, 281 virtual void ButtonPressed(views::Button* sender,
271 const ui::Event& event) OVERRIDE; 282 const ui::Event& event) OVERRIDE;
272 283
(...skipping 73 matching lines...) Expand 10 before | Expand all | Expand 10 after
346 static const int kIconInternalPadding; 357 static const int kIconInternalPadding;
347 // Amount of padding to place between the origin chip and the leading edge of 358 // Amount of padding to place between the origin chip and the leading edge of
348 // the location bar. 359 // the location bar.
349 static const int kOriginChipEdgeItemPadding; 360 static const int kOriginChipEdgeItemPadding;
350 // Amount of padding built into the origin chip. 361 // Amount of padding built into the origin chip.
351 static const int kOriginChipBuiltinPadding; 362 static const int kOriginChipBuiltinPadding;
352 // Space between the edge and a bubble. 363 // Space between the edge and a bubble.
353 static const int kBubblePadding; 364 static const int kBubblePadding;
354 365
355 protected: 366 protected:
367 // views::View:
356 virtual void OnFocus() OVERRIDE; 368 virtual void OnFocus() OVERRIDE;
357 369
370 // OmniboxEditController:
371 virtual void HideURL() OVERRIDE;
372
358 private: 373 private:
359 typedef std::vector<ContentSettingImageView*> ContentSettingViews; 374 typedef std::vector<ContentSettingImageView*> ContentSettingViews;
360 375
361 friend class PageActionImageView; 376 friend class PageActionImageView;
362 friend class PageActionWithBadgeView; 377 friend class PageActionWithBadgeView;
363 typedef std::vector<ExtensionAction*> PageActions; 378 typedef std::vector<ExtensionAction*> PageActions;
364 typedef std::vector<PageActionWithBadgeView*> PageActionViews; 379 typedef std::vector<PageActionWithBadgeView*> PageActionViews;
365 380
366 // Returns the number of pixels of built-in padding to the left and right for 381 // 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 382 // child views. This is nonzero when touch UI is enabled so as to space out
(...skipping 41 matching lines...) Expand 10 before | Expand all | Expand 10 after
409 bool HasValidSuggestText() const; 424 bool HasValidSuggestText() const;
410 425
411 // Helper to show the first run info bubble. 426 // Helper to show the first run info bubble.
412 void ShowFirstRunBubbleInternal(); 427 void ShowFirstRunBubbleInternal();
413 428
414 // Handles a request to change the value of this text field from software 429 // Handles a request to change the value of this text field from software
415 // using an accessibility API (typically automation software, screen readers 430 // using an accessibility API (typically automation software, screen readers
416 // don't normally use this). Sets the value and clears the selection. 431 // don't normally use this). Sets the value and clears the selection.
417 void AccessibilitySetValue(const base::string16& new_value); 432 void AccessibilitySetValue(const base::string16& new_value);
418 433
434 // Origin chip animation control methods.
435 void OnShowURLAnimationEnded();
436 void OnHideURLAnimationEnded();
437
419 // The Browser this LocationBarView is in. Note that at least 438 // The Browser this LocationBarView is in. Note that at least
420 // chromeos::SimpleWebViewDialog uses a LocationBarView outside any browser 439 // chromeos::SimpleWebViewDialog uses a LocationBarView outside any browser
421 // window, so this may be NULL. 440 // window, so this may be NULL.
422 Browser* browser_; 441 Browser* browser_;
423 442
424 OmniboxViewViews* omnibox_view_; 443 OmniboxViewViews* omnibox_view_;
425 444
426 // Our delegate. 445 // Our delegate.
427 Delegate* delegate_; 446 Delegate* delegate_;
428 447
(...skipping 75 matching lines...) Expand 10 before | Expand all | Expand 10 after
504 // focused. Used when the toolbar is in full keyboard accessibility mode. 523 // focused. Used when the toolbar is in full keyboard accessibility mode.
505 bool show_focus_rect_; 524 bool show_focus_rect_;
506 525
507 // This is in case we're destroyed before the model loads. We need to make 526 // This is in case we're destroyed before the model loads. We need to make
508 // Add/RemoveObserver calls. 527 // Add/RemoveObserver calls.
509 TemplateURLService* template_url_service_; 528 TemplateURLService* template_url_service_;
510 529
511 // Tracks this preference to determine whether bookmark editing is allowed. 530 // Tracks this preference to determine whether bookmark editing is allowed.
512 BooleanPrefMember edit_bookmarks_enabled_; 531 BooleanPrefMember edit_bookmarks_enabled_;
513 532
514 // While animating, the host clips the widget and draws only the bottom 533 // 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 534 // 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 535 // drawing the widget so that we can draw the curved edges that attach to the
517 // in the right location. 536 // toolbar in the right location.
518 int animation_offset_; 537 int animation_offset_;
519 538
539 // Origin chip animations.
540 scoped_ptr<gfx::SlideAnimation> show_url_animation_;
541 scoped_ptr<gfx::SlideAnimation> hide_url_animation_;
542
543 // Text label shown only during origin chip animations.
544 views::Label* animated_host_label_;
545
520 // Used to register for notifications received by NotificationObserver. 546 // Used to register for notifications received by NotificationObserver.
521 content::NotificationRegistrar registrar_; 547 content::NotificationRegistrar registrar_;
522 548
523 // Used to bind callback functions to this object. 549 // Used to bind callback functions to this object.
524 base::WeakPtrFactory<LocationBarView> weak_ptr_factory_; 550 base::WeakPtrFactory<LocationBarView> weak_ptr_factory_;
525 551
526 DISALLOW_COPY_AND_ASSIGN(LocationBarView); 552 DISALLOW_COPY_AND_ASSIGN(LocationBarView);
527 }; 553 };
528 554
529 #endif // CHROME_BROWSER_UI_VIEWS_LOCATION_BAR_LOCATION_BAR_VIEW_H_ 555 #endif // CHROME_BROWSER_UI_VIEWS_LOCATION_BAR_LOCATION_BAR_VIEW_H_
OLDNEW

Powered by Google App Engine
This is Rietveld 408576698