Chromium Code Reviews| 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 |
| (...skipping 238 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... | |
| 249 | 249 |
| 250 // views::View: | 250 // views::View: |
| 251 virtual bool HasFocus() const OVERRIDE; | 251 virtual bool HasFocus() const OVERRIDE; |
| 252 virtual void GetAccessibleState(ui::AXViewState* state) OVERRIDE; | 252 virtual void GetAccessibleState(ui::AXViewState* state) OVERRIDE; |
| 253 virtual gfx::Size GetPreferredSize() const OVERRIDE; | 253 virtual gfx::Size GetPreferredSize() const OVERRIDE; |
| 254 virtual void Layout() OVERRIDE; | 254 virtual void Layout() OVERRIDE; |
| 255 | 255 |
| 256 // OmniboxEditController: | 256 // OmniboxEditController: |
| 257 virtual void Update(const content::WebContents* contents) OVERRIDE; | 257 virtual void Update(const content::WebContents* contents) OVERRIDE; |
| 258 virtual void ShowURL() OVERRIDE; | 258 virtual void ShowURL() OVERRIDE; |
| 259 virtual void EndOriginChipAnimations(bool cancel_fade) OVERRIDE; | |
| 259 virtual ToolbarModel* GetToolbarModel() OVERRIDE; | 260 virtual ToolbarModel* GetToolbarModel() OVERRIDE; |
| 260 virtual content::WebContents* GetWebContents() OVERRIDE; | 261 virtual content::WebContents* GetWebContents() OVERRIDE; |
| 261 | 262 |
| 262 // Thickness of the edges of the omnibox background images, in normal mode. | 263 // Thickness of the edges of the omnibox background images, in normal mode. |
| 263 static const int kNormalEdgeThickness; | 264 static const int kNormalEdgeThickness; |
| 264 // The same, but for popup mode. | 265 // The same, but for popup mode. |
| 265 static const int kPopupEdgeThickness; | 266 static const int kPopupEdgeThickness; |
| 266 // Space between items in the location bar, as well as between items and the | 267 // Space between items in the location bar, as well as between items and the |
| 267 // edges. | 268 // edges. |
| 268 static const int kItemPadding; | 269 static const int kItemPadding; |
| (...skipping 60 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... | |
| 329 // using an accessibility API (typically automation software, screen readers | 330 // using an accessibility API (typically automation software, screen readers |
| 330 // don't normally use this). Sets the value and clears the selection. | 331 // don't normally use this). Sets the value and clears the selection. |
| 331 void AccessibilitySetValue(const base::string16& new_value); | 332 void AccessibilitySetValue(const base::string16& new_value); |
| 332 | 333 |
| 333 // Returns true if the suggest text is valid. | 334 // Returns true if the suggest text is valid. |
| 334 bool HasValidSuggestText() const; | 335 bool HasValidSuggestText() const; |
| 335 | 336 |
| 336 bool ShouldShowKeywordBubble() const; | 337 bool ShouldShowKeywordBubble() const; |
| 337 bool ShouldShowEVBubble() const; | 338 bool ShouldShowEVBubble() const; |
| 338 | 339 |
| 339 // Origin chip animation control methods. | 340 // Used to "reverse" the URL showing/hiding animations, since we use separate |
| 340 void OnShowURLAnimationEnded(); | 341 // animations whose curves are not true inverses of each other. Based on the |
| 341 void OnHideURLAnimationEnded(); | 342 // current position of the omnibox, calculates what value the desired |
| 343 // animation (|hide_url_animation_| if |hide| is true, |show_url_animation_| | |
| 344 // if it's false) should be set to in order to produce the same omnibox | |
| 345 // position. This way we can stop the old animation, set the new animation to | |
| 346 // this value, and start it running, and the text will appear to reverse | |
| 347 // directions from its current location. | |
| 348 double GetValueForAnimation(bool hide) const; | |
| 349 | |
| 350 // Resets |show_url_animation_| and the color changes it causes. | |
| 351 void ResetShowAnimationAndColors(); | |
| 342 | 352 |
| 343 // LocationBar: | 353 // LocationBar: |
| 344 virtual void ShowFirstRunBubble() OVERRIDE; | 354 virtual void ShowFirstRunBubble() OVERRIDE; |
| 345 virtual GURL GetDestinationURL() const OVERRIDE; | 355 virtual GURL GetDestinationURL() const OVERRIDE; |
| 346 virtual WindowOpenDisposition GetWindowOpenDisposition() const OVERRIDE; | 356 virtual WindowOpenDisposition GetWindowOpenDisposition() const OVERRIDE; |
| 347 virtual content::PageTransition GetPageTransition() const OVERRIDE; | 357 virtual content::PageTransition GetPageTransition() const OVERRIDE; |
| 348 virtual void AcceptInput() OVERRIDE; | 358 virtual void AcceptInput() OVERRIDE; |
| 349 virtual void FocusSearch() OVERRIDE; | 359 virtual void FocusSearch() OVERRIDE; |
| 350 virtual void UpdateContentSettingsIcons() OVERRIDE; | 360 virtual void UpdateContentSettingsIcons() OVERRIDE; |
| 351 virtual void UpdateManagePasswordsIconAndBubble() OVERRIDE; | 361 virtual void UpdateManagePasswordsIconAndBubble() OVERRIDE; |
| (...skipping 153 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... | |
| 505 // Tracks this preference to determine whether bookmark editing is allowed. | 515 // Tracks this preference to determine whether bookmark editing is allowed. |
| 506 BooleanPrefMember edit_bookmarks_enabled_; | 516 BooleanPrefMember edit_bookmarks_enabled_; |
| 507 | 517 |
| 508 // During dropdown animation, the host clips the widget and draws only the | 518 // During dropdown animation, the host clips the widget and draws only the |
| 509 // bottom part of it. The view needs to know the pixel offset at which we are | 519 // bottom part of it. The view needs to know the pixel offset at which we are |
| 510 // drawing the widget so that we can draw the curved edges that attach to the | 520 // drawing the widget so that we can draw the curved edges that attach to the |
| 511 // toolbar in the right location. | 521 // toolbar in the right location. |
| 512 int dropdown_animation_offset_; | 522 int dropdown_animation_offset_; |
| 513 | 523 |
| 514 // Origin chip animations. | 524 // Origin chip animations. |
| 525 // | |
| 526 // For the "show URL" animation, we instantly hide the origin chip and show | |
|
Justin Donnelly
2014/06/02 15:07:33
Great description, thanks.
| |
| 527 // the |omnibox_view_| in its place, containing the complete URL. However, we | |
| 528 // clip that view (using the XXX_leading_inset_ and XXX_width_ members) so | |
| 529 // that only the hostname is visible. We also offset the omnibox (using the | |
| 530 // XXX_offset_ members) so the hostname is in the same place as it was in the | |
| 531 // origin chip. Finally, we set the selection text and background color of | |
| 532 // the text to match the pressed origin chip. Then, as the animation runs, | |
| 533 // all of these values are animated to their steady-state values (no omnibox | |
| 534 // offset, no inset, width equal to the full omnibox text [which is reset to | |
| 535 // "no width clamp" after the animation ends], and standard selection colors). | |
| 536 // | |
| 537 // For the hide animation, we run the positioning and clipping parts of the | |
| 538 // animation in reverse, but instead of changing the selection color, because | |
| 539 // there usually isn't a selection when hiding, we leave the omnibox colors | |
| 540 // alone, and when the hide animation has ended, tell the origin chip to | |
| 541 // fade-in its background. | |
| 515 scoped_ptr<gfx::SlideAnimation> show_url_animation_; | 542 scoped_ptr<gfx::SlideAnimation> show_url_animation_; |
| 516 scoped_ptr<gfx::SlideAnimation> hide_url_animation_; | 543 scoped_ptr<gfx::SlideAnimation> hide_url_animation_; |
| 517 | 544 // The omnibox offset may be positive or negative. The starting offset is the |
| 518 // Text label shown only during origin chip animations. | 545 // amount necessary to shift the |omnibox_view_| by such that the hostname |
| 519 views::Label* animated_host_label_; | 546 // portion of the URL aligns with the hostname in the origin chip. As the |
| 547 // show animation runs, the current offset gradually moves to 0. | |
| 548 int starting_omnibox_offset_; | |
| 549 int current_omnibox_offset_; | |
| 550 // The leading inset is always positive. The starting inset is the width of | |
| 551 // the text between the leading edge of the omnibox and the edge of the | |
| 552 // hostname, which is clipped off at the start of the show animation. Note | |
| 553 // that in RTL mode, this will be the part of the URL that is logically after | |
| 554 // the hostname. As the show animation runs, the current inset gradually | |
| 555 // moves to 0. | |
| 556 int starting_omnibox_leading_inset_; | |
| 557 int current_omnibox_leading_inset_; | |
| 558 // The width is always positive. The ending width is the width of the entire | |
| 559 // omnibox URL. As the show animation runs, the current width gradually moves | |
| 560 // from the width of the hostname to the ending value. | |
| 561 int current_omnibox_width_; | |
| 562 int ending_omnibox_width_; | |
| 520 | 563 |
| 521 // Used to register for notifications received by NotificationObserver. | 564 // Used to register for notifications received by NotificationObserver. |
| 522 content::NotificationRegistrar registrar_; | 565 content::NotificationRegistrar registrar_; |
| 523 | 566 |
| 524 // Used to bind callback functions to this object. | 567 // Used to bind callback functions to this object. |
| 525 base::WeakPtrFactory<LocationBarView> weak_ptr_factory_; | 568 base::WeakPtrFactory<LocationBarView> weak_ptr_factory_; |
| 526 | 569 |
| 527 DISALLOW_COPY_AND_ASSIGN(LocationBarView); | 570 DISALLOW_COPY_AND_ASSIGN(LocationBarView); |
| 528 }; | 571 }; |
| 529 | 572 |
| 530 #endif // CHROME_BROWSER_UI_VIEWS_LOCATION_BAR_LOCATION_BAR_VIEW_H_ | 573 #endif // CHROME_BROWSER_UI_VIEWS_LOCATION_BAR_LOCATION_BAR_VIEW_H_ |
| OLD | NEW |