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