| 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 21 matching lines...) Expand all Loading... |
| 32 class ContentSettingImageView; | 32 class ContentSettingImageView; |
| 33 class EVBubbleView; | 33 class EVBubbleView; |
| 34 class ExtensionAction; | 34 class ExtensionAction; |
| 35 class GURL; | 35 class GURL; |
| 36 class GeneratedCreditCardView; | 36 class GeneratedCreditCardView; |
| 37 class InstantController; | 37 class InstantController; |
| 38 class KeywordHintView; | 38 class KeywordHintView; |
| 39 class LocationIconView; | 39 class LocationIconView; |
| 40 class OpenPDFInReaderView; | 40 class OpenPDFInReaderView; |
| 41 class ManagePasswordsIconView; | 41 class ManagePasswordsIconView; |
| 42 class OriginChipView; | |
| 43 class PageActionWithBadgeView; | 42 class PageActionWithBadgeView; |
| 44 class PageActionImageView; | 43 class PageActionImageView; |
| 45 class Profile; | 44 class Profile; |
| 46 class SearchButton; | |
| 47 class SelectedKeywordView; | 45 class SelectedKeywordView; |
| 48 class StarView; | 46 class StarView; |
| 49 class TemplateURLService; | 47 class TemplateURLService; |
| 50 class TranslateIconView; | 48 class TranslateIconView; |
| 51 class ZoomView; | 49 class ZoomView; |
| 52 | 50 |
| 53 namespace content { | 51 namespace content { |
| 54 struct SSLStatus; | 52 struct SSLStatus; |
| 55 } | 53 } |
| 56 | 54 |
| 57 namespace gfx { | |
| 58 class SlideAnimation; | |
| 59 } | |
| 60 | |
| 61 namespace views { | 55 namespace views { |
| 62 class BubbleDelegateView; | 56 class BubbleDelegateView; |
| 63 class ImageButton; | 57 class ImageButton; |
| 64 class ImageView; | 58 class ImageView; |
| 65 class Label; | 59 class Label; |
| 66 class Widget; | 60 class Widget; |
| 67 } | 61 } |
| 68 | 62 |
| 69 ///////////////////////////////////////////////////////////////////////////// | 63 ///////////////////////////////////////////////////////////////////////////// |
| 70 // | 64 // |
| 71 // LocationBarView class | 65 // LocationBarView class |
| 72 // | 66 // |
| 73 // The LocationBarView class is a View subclass that paints the background | 67 // The LocationBarView class is a View subclass that paints the background |
| 74 // of the URL bar strip and contains its content. | 68 // of the URL bar strip and contains its content. |
| 75 // | 69 // |
| 76 ///////////////////////////////////////////////////////////////////////////// | 70 ///////////////////////////////////////////////////////////////////////////// |
| 77 class LocationBarView : public LocationBar, | 71 class LocationBarView : public LocationBar, |
| 78 public LocationBarTesting, | 72 public LocationBarTesting, |
| 79 public views::View, | 73 public views::View, |
| 80 public views::ButtonListener, | 74 public views::ButtonListener, |
| 81 public views::DragController, | 75 public views::DragController, |
| 82 public OmniboxEditController, | 76 public OmniboxEditController, |
| 83 public DropdownBarHostDelegate, | 77 public DropdownBarHostDelegate, |
| 84 public gfx::AnimationDelegate, | |
| 85 public TemplateURLServiceObserver, | 78 public TemplateURLServiceObserver, |
| 86 public SearchModelObserver { | 79 public SearchModelObserver { |
| 87 public: | 80 public: |
| 88 // The location bar view's class name. | 81 // The location bar view's class name. |
| 89 static const char kViewClassName[]; | 82 static const char kViewClassName[]; |
| 90 | 83 |
| 91 // Returns the offset used during dropdown animation. | 84 // Returns the offset used during dropdown animation. |
| 92 int dropdown_animation_offset() const { return dropdown_animation_offset_; } | 85 int dropdown_animation_offset() const { return dropdown_animation_offset_; } |
| 93 | 86 |
| 94 class Delegate { | 87 class Delegate { |
| (...skipping 153 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 248 | 241 |
| 249 // views::View: | 242 // views::View: |
| 250 bool HasFocus() const override; | 243 bool HasFocus() const override; |
| 251 void GetAccessibleState(ui::AXViewState* state) override; | 244 void GetAccessibleState(ui::AXViewState* state) override; |
| 252 gfx::Size GetPreferredSize() const override; | 245 gfx::Size GetPreferredSize() const override; |
| 253 void Layout() override; | 246 void Layout() override; |
| 254 | 247 |
| 255 // OmniboxEditController: | 248 // OmniboxEditController: |
| 256 void Update(const content::WebContents* contents) override; | 249 void Update(const content::WebContents* contents) override; |
| 257 void ShowURL() override; | 250 void ShowURL() override; |
| 258 void EndOriginChipAnimations(bool cancel_fade) override; | |
| 259 ToolbarModel* GetToolbarModel() override; | 251 ToolbarModel* GetToolbarModel() override; |
| 260 content::WebContents* GetWebContents() override; | 252 content::WebContents* GetWebContents() override; |
| 261 | 253 |
| 262 // Thickness of the edges of the omnibox background images, in normal mode. | 254 // Thickness of the edges of the omnibox background images, in normal mode. |
| 263 static const int kNormalEdgeThickness; | 255 static const int kNormalEdgeThickness; |
| 264 // The same, but for popup mode. | 256 // The same, but for popup mode. |
| 265 static const int kPopupEdgeThickness; | 257 static const int kPopupEdgeThickness; |
| 266 // Space between items in the location bar, as well as between items and the | 258 // Space between items in the location bar, as well as between items and the |
| 267 // edges. | 259 // edges. |
| 268 static const int kItemPadding; | 260 static const int kItemPadding; |
| 269 // Amount of padding built into the standard omnibox icons. | 261 // Amount of padding built into the standard omnibox icons. |
| 270 static const int kIconInternalPadding; | 262 static const int kIconInternalPadding; |
| 271 // Amount of padding to place between the origin chip and the leading edge of | |
| 272 // the location bar. | |
| 273 static const int kOriginChipEdgeItemPadding; | |
| 274 // Amount of padding built into the origin chip. | |
| 275 static const int kOriginChipBuiltinPadding; | |
| 276 // Space between the edge and a bubble. | 263 // Space between the edge and a bubble. |
| 277 static const int kBubblePadding; | 264 static const int kBubblePadding; |
| 278 | 265 |
| 279 private: | 266 private: |
| 280 typedef std::vector<ContentSettingImageView*> ContentSettingViews; | 267 typedef std::vector<ContentSettingImageView*> ContentSettingViews; |
| 281 | 268 |
| 282 friend class PageActionImageView; | 269 friend class PageActionImageView; |
| 283 friend class PageActionWithBadgeView; | 270 friend class PageActionWithBadgeView; |
| 284 typedef std::vector<ExtensionAction*> PageActions; | 271 typedef std::vector<ExtensionAction*> PageActions; |
| 285 typedef std::vector<PageActionWithBadgeView*> PageActionViews; | 272 typedef std::vector<PageActionWithBadgeView*> PageActionViews; |
| (...skipping 45 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 331 // Used to "reverse" the URL showing/hiding animations, since we use separate | 318 // Used to "reverse" the URL showing/hiding animations, since we use separate |
| 332 // animations whose curves are not true inverses of each other. Based on the | 319 // animations whose curves are not true inverses of each other. Based on the |
| 333 // current position of the omnibox, calculates what value the desired | 320 // current position of the omnibox, calculates what value the desired |
| 334 // animation (|hide_url_animation_| if |hide| is true, |show_url_animation_| | 321 // animation (|hide_url_animation_| if |hide| is true, |show_url_animation_| |
| 335 // if it's false) should be set to in order to produce the same omnibox | 322 // if it's false) should be set to in order to produce the same omnibox |
| 336 // position. This way we can stop the old animation, set the new animation to | 323 // position. This way we can stop the old animation, set the new animation to |
| 337 // this value, and start it running, and the text will appear to reverse | 324 // this value, and start it running, and the text will appear to reverse |
| 338 // directions from its current location. | 325 // directions from its current location. |
| 339 double GetValueForAnimation(bool hide) const; | 326 double GetValueForAnimation(bool hide) const; |
| 340 | 327 |
| 341 // Resets |show_url_animation_| and the color changes it causes. | |
| 342 void ResetShowAnimationAndColors(); | |
| 343 | |
| 344 // LocationBar: | 328 // LocationBar: |
| 345 void ShowFirstRunBubble() override; | 329 void ShowFirstRunBubble() override; |
| 346 GURL GetDestinationURL() const override; | 330 GURL GetDestinationURL() const override; |
| 347 WindowOpenDisposition GetWindowOpenDisposition() const override; | 331 WindowOpenDisposition GetWindowOpenDisposition() const override; |
| 348 ui::PageTransition GetPageTransition() const override; | 332 ui::PageTransition GetPageTransition() const override; |
| 349 void AcceptInput() override; | 333 void AcceptInput() override; |
| 350 void FocusSearch() override; | 334 void FocusSearch() override; |
| 351 void UpdateContentSettingsIcons() override; | 335 void UpdateContentSettingsIcons() override; |
| 352 void UpdateManagePasswordsIconAndBubble() override; | 336 void UpdateManagePasswordsIconAndBubble() override; |
| 353 void UpdatePageActions() override; | 337 void UpdatePageActions() override; |
| (...skipping 33 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 387 int GetDragOperationsForView(View* sender, const gfx::Point& p) override; | 371 int GetDragOperationsForView(View* sender, const gfx::Point& p) override; |
| 388 bool CanStartDragForView(View* sender, | 372 bool CanStartDragForView(View* sender, |
| 389 const gfx::Point& press_pt, | 373 const gfx::Point& press_pt, |
| 390 const gfx::Point& p) override; | 374 const gfx::Point& p) override; |
| 391 | 375 |
| 392 // OmniboxEditController: | 376 // OmniboxEditController: |
| 393 void OnChanged() override; | 377 void OnChanged() override; |
| 394 void OnSetFocus() override; | 378 void OnSetFocus() override; |
| 395 InstantController* GetInstant() override; | 379 InstantController* GetInstant() override; |
| 396 const ToolbarModel* GetToolbarModel() const override; | 380 const ToolbarModel* GetToolbarModel() const override; |
| 397 void HideURL() override; | |
| 398 | 381 |
| 399 // DropdownBarHostDelegate: | 382 // DropdownBarHostDelegate: |
| 400 void SetFocusAndSelection(bool select_all) override; | 383 void SetFocusAndSelection(bool select_all) override; |
| 401 void SetAnimationOffset(int offset) override; | 384 void SetAnimationOffset(int offset) override; |
| 402 | 385 |
| 403 // gfx::AnimationDelegate: | |
| 404 void AnimationProgressed(const gfx::Animation* animation) override; | |
| 405 void AnimationEnded(const gfx::Animation* animation) override; | |
| 406 | |
| 407 // TemplateURLServiceObserver: | 386 // TemplateURLServiceObserver: |
| 408 void OnTemplateURLServiceChanged() override; | 387 void OnTemplateURLServiceChanged() override; |
| 409 | 388 |
| 410 // SearchModelObserver: | 389 // SearchModelObserver: |
| 411 void ModelChanged(const SearchModel::State& old_state, | 390 void ModelChanged(const SearchModel::State& old_state, |
| 412 const SearchModel::State& new_state) override; | 391 const SearchModel::State& new_state) override; |
| 413 | 392 |
| 414 // The Browser this LocationBarView is in. Note that at least | 393 // The Browser this LocationBarView is in. Note that at least |
| 415 // chromeos::SimpleWebViewDialog uses a LocationBarView outside any browser | 394 // chromeos::SimpleWebViewDialog uses a LocationBarView outside any browser |
| 416 // window, so this may be NULL. | 395 // window, so this may be NULL. |
| 417 Browser* browser_; | 396 Browser* browser_; |
| 418 | 397 |
| 419 OmniboxViewViews* omnibox_view_; | 398 OmniboxViewViews* omnibox_view_; |
| 420 | 399 |
| 421 // Our delegate. | 400 // Our delegate. |
| 422 Delegate* delegate_; | 401 Delegate* delegate_; |
| 423 | 402 |
| 424 // Object used to paint the border. | 403 // Object used to paint the border. |
| 425 scoped_ptr<views::Painter> border_painter_; | 404 scoped_ptr<views::Painter> border_painter_; |
| 426 | 405 |
| 427 // The origin chip that may appear in the location bar. | |
| 428 OriginChipView* origin_chip_view_; | |
| 429 | |
| 430 // An icon to the left of the edit field. | 406 // An icon to the left of the edit field. |
| 431 LocationIconView* location_icon_view_; | 407 LocationIconView* location_icon_view_; |
| 432 | 408 |
| 433 // A bubble displayed for EV HTTPS sites. | 409 // A bubble displayed for EV HTTPS sites. |
| 434 EVBubbleView* ev_bubble_view_; | 410 EVBubbleView* ev_bubble_view_; |
| 435 | 411 |
| 436 // A view to show inline autocompletion when an IME is active. In this case, | 412 // A view to show inline autocompletion when an IME is active. In this case, |
| 437 // we shouldn't change the text or selection inside the OmniboxView itself, | 413 // we shouldn't change the text or selection inside the OmniboxView itself, |
| 438 // since this will conflict with the IME's control over the text. So instead | 414 // since this will conflict with the IME's control over the text. So instead |
| 439 // we show any autocompletion in a separate field after the OmniboxView. | 415 // we show any autocompletion in a separate field after the OmniboxView. |
| (...skipping 38 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 478 | 454 |
| 479 // The page action icon views. | 455 // The page action icon views. |
| 480 PageActionViews page_action_views_; | 456 PageActionViews page_action_views_; |
| 481 | 457 |
| 482 // The icon for Translate. | 458 // The icon for Translate. |
| 483 TranslateIconView* translate_icon_view_; | 459 TranslateIconView* translate_icon_view_; |
| 484 | 460 |
| 485 // The star. | 461 // The star. |
| 486 StarView* star_view_; | 462 StarView* star_view_; |
| 487 | 463 |
| 488 // The search/go button. | |
| 489 SearchButton* search_button_; | |
| 490 | |
| 491 // Whether we're in popup mode. This value also controls whether the location | 464 // Whether we're in popup mode. This value also controls whether the location |
| 492 // bar is read-only. | 465 // bar is read-only. |
| 493 const bool is_popup_mode_; | 466 const bool is_popup_mode_; |
| 494 | 467 |
| 495 // True if we should show a focus rect while the location entry field is | 468 // True if we should show a focus rect while the location entry field is |
| 496 // focused. Used when the toolbar is in full keyboard accessibility mode. | 469 // focused. Used when the toolbar is in full keyboard accessibility mode. |
| 497 bool show_focus_rect_; | 470 bool show_focus_rect_; |
| 498 | 471 |
| 499 // This is in case we're destroyed before the model loads. We need to make | 472 // This is in case we're destroyed before the model loads. We need to make |
| 500 // Add/RemoveObserver calls. | 473 // Add/RemoveObserver calls. |
| 501 TemplateURLService* template_url_service_; | 474 TemplateURLService* template_url_service_; |
| 502 | 475 |
| 503 // Tracks this preference to determine whether bookmark editing is allowed. | 476 // Tracks this preference to determine whether bookmark editing is allowed. |
| 504 BooleanPrefMember edit_bookmarks_enabled_; | 477 BooleanPrefMember edit_bookmarks_enabled_; |
| 505 | 478 |
| 506 // During dropdown animation, the host clips the widget and draws only the | 479 // During dropdown animation, the host clips the widget and draws only the |
| 507 // bottom part of it. The view needs to know the pixel offset at which we are | 480 // bottom part of it. The view needs to know the pixel offset at which we are |
| 508 // drawing the widget so that we can draw the curved edges that attach to the | 481 // drawing the widget so that we can draw the curved edges that attach to the |
| 509 // toolbar in the right location. | 482 // toolbar in the right location. |
| 510 int dropdown_animation_offset_; | 483 int dropdown_animation_offset_; |
| 511 | 484 |
| 512 // Origin chip animations. | |
| 513 // | |
| 514 // For the "show URL" animation, we instantly hide the origin chip and show | |
| 515 // the |omnibox_view_| in its place, containing the complete URL. However, we | |
| 516 // clip that view (using the XXX_leading_inset_ and XXX_width_ members) so | |
| 517 // that only the hostname is visible. We also offset the omnibox (using the | |
| 518 // XXX_offset_ members) so the hostname is in the same place as it was in the | |
| 519 // origin chip. Finally, we set the selection text and background color of | |
| 520 // the text to match the pressed origin chip. Then, as the animation runs, | |
| 521 // all of these values are animated to their steady-state values (no omnibox | |
| 522 // offset, no inset, width equal to the full omnibox text [which is reset to | |
| 523 // "no width clamp" after the animation ends], and standard selection colors). | |
| 524 // | |
| 525 // For the hide animation, we run the positioning and clipping parts of the | |
| 526 // animation in reverse, but instead of changing the selection color, because | |
| 527 // there usually isn't a selection when hiding, we leave the omnibox colors | |
| 528 // alone, and when the hide animation has ended, tell the origin chip to | |
| 529 // fade-in its background. | |
| 530 scoped_ptr<gfx::SlideAnimation> show_url_animation_; | |
| 531 scoped_ptr<gfx::SlideAnimation> hide_url_animation_; | |
| 532 // The omnibox offset may be positive or negative. The starting offset is the | |
| 533 // amount necessary to shift the |omnibox_view_| by such that the hostname | |
| 534 // portion of the URL aligns with the hostname in the origin chip. As the | |
| 535 // show animation runs, the current offset gradually moves to 0. | |
| 536 int starting_omnibox_offset_; | |
| 537 int current_omnibox_offset_; | |
| 538 // The leading inset is always positive. The starting inset is the width of | |
| 539 // the text between the leading edge of the omnibox and the edge of the | |
| 540 // hostname, which is clipped off at the start of the show animation. Note | |
| 541 // that in RTL mode, this will be the part of the URL that is logically after | |
| 542 // the hostname. As the show animation runs, the current inset gradually | |
| 543 // moves to 0. | |
| 544 int starting_omnibox_leading_inset_; | |
| 545 int current_omnibox_leading_inset_; | |
| 546 // The width is always positive. The ending width is the width of the entire | |
| 547 // omnibox URL. As the show animation runs, the current width gradually moves | |
| 548 // from the width of the hostname to the ending value. | |
| 549 int current_omnibox_width_; | |
| 550 int ending_omnibox_width_; | |
| 551 | |
| 552 DISALLOW_COPY_AND_ASSIGN(LocationBarView); | 485 DISALLOW_COPY_AND_ASSIGN(LocationBarView); |
| 553 }; | 486 }; |
| 554 | 487 |
| 555 #endif // CHROME_BROWSER_UI_VIEWS_LOCATION_BAR_LOCATION_BAR_VIEW_H_ | 488 #endif // CHROME_BROWSER_UI_VIEWS_LOCATION_BAR_LOCATION_BAR_VIEW_H_ |
| OLD | NEW |