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

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

Issue 768413003: TEST ONLY - DO NOT SUBMIT - FOR TRYBOTS (Closed) Base URL: https://chromium.googlesource.com/chromium/src.git@master
Patch Set: Fix bad merge Created 5 years, 11 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
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
(...skipping 21 matching lines...) Expand all
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
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 50 matching lines...) Expand 10 before | Expand all | Expand 10 after
336 // Used to "reverse" the URL showing/hiding animations, since we use separate 323 // Used to "reverse" the URL showing/hiding animations, since we use separate
337 // animations whose curves are not true inverses of each other. Based on the 324 // animations whose curves are not true inverses of each other. Based on the
338 // current position of the omnibox, calculates what value the desired 325 // current position of the omnibox, calculates what value the desired
339 // animation (|hide_url_animation_| if |hide| is true, |show_url_animation_| 326 // animation (|hide_url_animation_| if |hide| is true, |show_url_animation_|
340 // if it's false) should be set to in order to produce the same omnibox 327 // if it's false) should be set to in order to produce the same omnibox
341 // position. This way we can stop the old animation, set the new animation to 328 // position. This way we can stop the old animation, set the new animation to
342 // this value, and start it running, and the text will appear to reverse 329 // this value, and start it running, and the text will appear to reverse
343 // directions from its current location. 330 // directions from its current location.
344 double GetValueForAnimation(bool hide) const; 331 double GetValueForAnimation(bool hide) const;
345 332
346 // Resets |show_url_animation_| and the color changes it causes.
347 void ResetShowAnimationAndColors();
348
349 // LocationBar: 333 // LocationBar:
350 void ShowFirstRunBubble() override; 334 void ShowFirstRunBubble() override;
351 GURL GetDestinationURL() const override; 335 GURL GetDestinationURL() const override;
352 WindowOpenDisposition GetWindowOpenDisposition() const override; 336 WindowOpenDisposition GetWindowOpenDisposition() const override;
353 ui::PageTransition GetPageTransition() const override; 337 ui::PageTransition GetPageTransition() const override;
354 void AcceptInput() override; 338 void AcceptInput() override;
355 void FocusSearch() override; 339 void FocusSearch() override;
356 void UpdateContentSettingsIcons() override; 340 void UpdateContentSettingsIcons() override;
357 void UpdateManagePasswordsIconAndBubble() override; 341 void UpdateManagePasswordsIconAndBubble() override;
358 void UpdatePageActions() override; 342 void UpdatePageActions() override;
(...skipping 32 matching lines...) Expand 10 before | Expand all | Expand 10 after
391 int GetDragOperationsForView(View* sender, const gfx::Point& p) override; 375 int GetDragOperationsForView(View* sender, const gfx::Point& p) override;
392 bool CanStartDragForView(View* sender, 376 bool CanStartDragForView(View* sender,
393 const gfx::Point& press_pt, 377 const gfx::Point& press_pt,
394 const gfx::Point& p) override; 378 const gfx::Point& p) override;
395 379
396 // OmniboxEditController: 380 // OmniboxEditController:
397 void OnChanged() override; 381 void OnChanged() override;
398 void OnSetFocus() override; 382 void OnSetFocus() override;
399 InstantController* GetInstant() override; 383 InstantController* GetInstant() override;
400 const ToolbarModel* GetToolbarModel() const override; 384 const ToolbarModel* GetToolbarModel() const override;
401 void HideURL() override;
402 385
403 // DropdownBarHostDelegate: 386 // DropdownBarHostDelegate:
404 void SetFocusAndSelection(bool select_all) override; 387 void SetFocusAndSelection(bool select_all) override;
405 void SetAnimationOffset(int offset) override; 388 void SetAnimationOffset(int offset) override;
406 389
407 // gfx::AnimationDelegate:
408 void AnimationProgressed(const gfx::Animation* animation) override;
409 void AnimationEnded(const gfx::Animation* animation) override;
410
411 // TemplateURLServiceObserver: 390 // TemplateURLServiceObserver:
412 void OnTemplateURLServiceChanged() override; 391 void OnTemplateURLServiceChanged() override;
413 392
414 // SearchModelObserver: 393 // SearchModelObserver:
415 void ModelChanged(const SearchModel::State& old_state, 394 void ModelChanged(const SearchModel::State& old_state,
416 const SearchModel::State& new_state) override; 395 const SearchModel::State& new_state) override;
417 396
418 // The Browser this LocationBarView is in. Note that at least 397 // The Browser this LocationBarView is in. Note that at least
419 // chromeos::SimpleWebViewDialog uses a LocationBarView outside any browser 398 // chromeos::SimpleWebViewDialog uses a LocationBarView outside any browser
420 // window, so this may be NULL. 399 // window, so this may be NULL.
421 Browser* browser_; 400 Browser* browser_;
422 401
423 OmniboxViewViews* omnibox_view_; 402 OmniboxViewViews* omnibox_view_;
424 403
425 // Our delegate. 404 // Our delegate.
426 Delegate* delegate_; 405 Delegate* delegate_;
427 406
428 // Object used to paint the border. 407 // Object used to paint the border.
429 scoped_ptr<views::Painter> border_painter_; 408 scoped_ptr<views::Painter> border_painter_;
430 409
431 // The origin chip that may appear in the location bar.
432 OriginChipView* origin_chip_view_;
433
434 // An icon to the left of the edit field. 410 // An icon to the left of the edit field.
435 LocationIconView* location_icon_view_; 411 LocationIconView* location_icon_view_;
436 412
437 // A bubble displayed for EV HTTPS sites. 413 // A bubble displayed for EV HTTPS sites.
438 EVBubbleView* ev_bubble_view_; 414 EVBubbleView* ev_bubble_view_;
439 415
440 // A view to show inline autocompletion when an IME is active. In this case, 416 // A view to show inline autocompletion when an IME is active. In this case,
441 // we shouldn't change the text or selection inside the OmniboxView itself, 417 // we shouldn't change the text or selection inside the OmniboxView itself,
442 // since this will conflict with the IME's control over the text. So instead 418 // since this will conflict with the IME's control over the text. So instead
443 // we show any autocompletion in a separate field after the OmniboxView. 419 // we show any autocompletion in a separate field after the OmniboxView.
(...skipping 35 matching lines...) Expand 10 before | Expand all | Expand 10 after
479 455
480 // The page action icon views. 456 // The page action icon views.
481 PageActionViews page_action_views_; 457 PageActionViews page_action_views_;
482 458
483 // The icon for Translate. 459 // The icon for Translate.
484 TranslateIconView* translate_icon_view_; 460 TranslateIconView* translate_icon_view_;
485 461
486 // The star. 462 // The star.
487 StarView* star_view_; 463 StarView* star_view_;
488 464
489 // The search/go button.
490 SearchButton* search_button_;
491
492 // Whether we're in popup mode. This value also controls whether the location 465 // Whether we're in popup mode. This value also controls whether the location
493 // bar is read-only. 466 // bar is read-only.
494 const bool is_popup_mode_; 467 const bool is_popup_mode_;
495 468
496 // True if we should show a focus rect while the location entry field is 469 // True if we should show a focus rect while the location entry field is
497 // focused. Used when the toolbar is in full keyboard accessibility mode. 470 // focused. Used when the toolbar is in full keyboard accessibility mode.
498 bool show_focus_rect_; 471 bool show_focus_rect_;
499 472
500 // This is in case we're destroyed before the model loads. We need to make 473 // This is in case we're destroyed before the model loads. We need to make
501 // Add/RemoveObserver calls. 474 // Add/RemoveObserver calls.
502 TemplateURLService* template_url_service_; 475 TemplateURLService* template_url_service_;
503 476
504 // Tracks this preference to determine whether bookmark editing is allowed. 477 // Tracks this preference to determine whether bookmark editing is allowed.
505 BooleanPrefMember edit_bookmarks_enabled_; 478 BooleanPrefMember edit_bookmarks_enabled_;
506 479
507 // During dropdown animation, the host clips the widget and draws only the 480 // During dropdown animation, the host clips the widget and draws only the
508 // bottom part of it. The view needs to know the pixel offset at which we are 481 // bottom part of it. The view needs to know the pixel offset at which we are
509 // drawing the widget so that we can draw the curved edges that attach to the 482 // drawing the widget so that we can draw the curved edges that attach to the
510 // toolbar in the right location. 483 // toolbar in the right location.
511 int dropdown_animation_offset_; 484 int dropdown_animation_offset_;
512 485
513 // Origin chip animations.
514 //
515 // For the "show URL" animation, we instantly hide the origin chip and show
516 // the |omnibox_view_| in its place, containing the complete URL. However, we
517 // clip that view (using the XXX_leading_inset_ and XXX_width_ members) so
518 // that only the hostname is visible. We also offset the omnibox (using the
519 // XXX_offset_ members) so the hostname is in the same place as it was in the
520 // origin chip. Finally, we set the selection text and background color of
521 // the text to match the pressed origin chip. Then, as the animation runs,
522 // all of these values are animated to their steady-state values (no omnibox
523 // offset, no inset, width equal to the full omnibox text [which is reset to
524 // "no width clamp" after the animation ends], and standard selection colors).
525 //
526 // For the hide animation, we run the positioning and clipping parts of the
527 // animation in reverse, but instead of changing the selection color, because
528 // there usually isn't a selection when hiding, we leave the omnibox colors
529 // alone, and when the hide animation has ended, tell the origin chip to
530 // fade-in its background.
531 scoped_ptr<gfx::SlideAnimation> show_url_animation_;
532 scoped_ptr<gfx::SlideAnimation> hide_url_animation_;
533 // The omnibox offset may be positive or negative. The starting offset is the
534 // amount necessary to shift the |omnibox_view_| by such that the hostname
535 // portion of the URL aligns with the hostname in the origin chip. As the
536 // show animation runs, the current offset gradually moves to 0.
537 int starting_omnibox_offset_;
538 int current_omnibox_offset_;
539 // The leading inset is always positive. The starting inset is the width of
540 // the text between the leading edge of the omnibox and the edge of the
541 // hostname, which is clipped off at the start of the show animation. Note
542 // that in RTL mode, this will be the part of the URL that is logically after
543 // the hostname. As the show animation runs, the current inset gradually
544 // moves to 0.
545 int starting_omnibox_leading_inset_;
546 int current_omnibox_leading_inset_;
547 // The width is always positive. The ending width is the width of the entire
548 // omnibox URL. As the show animation runs, the current width gradually moves
549 // from the width of the hostname to the ending value.
550 int current_omnibox_width_;
551 int ending_omnibox_width_;
552
553 // This is a debug state variable that stores if the WebContents was null 486 // This is a debug state variable that stores if the WebContents was null
554 // during the last RefreshPageAction. 487 // during the last RefreshPageAction.
555 bool web_contents_null_at_last_refresh_; 488 bool web_contents_null_at_last_refresh_;
556 489
557 DISALLOW_COPY_AND_ASSIGN(LocationBarView); 490 DISALLOW_COPY_AND_ASSIGN(LocationBarView);
558 }; 491 };
559 492
560 #endif // CHROME_BROWSER_UI_VIEWS_LOCATION_BAR_LOCATION_BAR_VIEW_H_ 493 #endif // CHROME_BROWSER_UI_VIEWS_LOCATION_BAR_LOCATION_BAR_VIEW_H_
OLDNEW
« no previous file with comments | « chrome/browser/ui/views/frame/browser_view.cc ('k') | chrome/browser/ui/views/location_bar/location_bar_view.cc » ('j') | no next file with comments »

Powered by Google App Engine
This is Rietveld 408576698