| 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 <stddef.h> | 8 #include <stddef.h> |
| 9 | 9 |
| 10 #include <string> | 10 #include <string> |
| (...skipping 94 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 105 }; | 105 }; |
| 106 | 106 |
| 107 enum ColorKind { | 107 enum ColorKind { |
| 108 BACKGROUND = 0, | 108 BACKGROUND = 0, |
| 109 TEXT, | 109 TEXT, |
| 110 SELECTED_TEXT, | 110 SELECTED_TEXT, |
| 111 DEEMPHASIZED_TEXT, | 111 DEEMPHASIZED_TEXT, |
| 112 SECURITY_CHIP_TEXT, | 112 SECURITY_CHIP_TEXT, |
| 113 }; | 113 }; |
| 114 | 114 |
| 115 // Width (and height) of icons in location bar. |
| 116 static constexpr int kLocationBarIconWidth = 16; |
| 117 |
| 115 // The location bar view's class name. | 118 // The location bar view's class name. |
| 116 static const char kViewClassName[]; | 119 static const char kViewClassName[]; |
| 117 | 120 |
| 118 LocationBarView(Browser* browser, | 121 LocationBarView(Browser* browser, |
| 119 Profile* profile, | 122 Profile* profile, |
| 120 CommandUpdater* command_updater, | 123 CommandUpdater* command_updater, |
| 121 Delegate* delegate, | 124 Delegate* delegate, |
| 122 bool is_popup_mode); | 125 bool is_popup_mode); |
| 123 | 126 |
| 124 ~LocationBarView() override; | 127 ~LocationBarView() override; |
| 125 | 128 |
| 126 // Returns the color for the location bar border in MD windows and non-MD | 129 // Returns the color for the location bar border given the window's |
| 127 // popup windows, given the window's |incognito| state. | 130 // |incognito| state. |
| 128 static SkColor GetBorderColor(bool incognito); | 131 static SkColor GetBorderColor(bool incognito); |
| 129 | 132 |
| 130 // Initializes the LocationBarView. | 133 // Initializes the LocationBarView. |
| 131 void Init(); | 134 void Init(); |
| 132 | 135 |
| 133 // True if this instance has been initialized by calling Init, which can only | 136 // True if this instance has been initialized by calling Init, which can only |
| 134 // be called when the receiving instance is attached to a view container. | 137 // be called when the receiving instance is attached to a view container. |
| 135 bool IsInitialized() const; | 138 bool IsInitialized() const; |
| 136 | 139 |
| 137 // Returns the appropriate color for the desired kind, based on the user's | 140 // Returns the appropriate color for the desired kind, based on the user's |
| (...skipping 41 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 179 return save_credit_card_icon_view_; | 182 return save_credit_card_icon_view_; |
| 180 } | 183 } |
| 181 | 184 |
| 182 // The translate icon. It may not be visible. | 185 // The translate icon. It may not be visible. |
| 183 TranslateIconView* translate_icon_view() { return translate_icon_view_; } | 186 TranslateIconView* translate_icon_view() { return translate_icon_view_; } |
| 184 | 187 |
| 185 // Returns the screen coordinates of the omnibox (where the URL text appears, | 188 // Returns the screen coordinates of the omnibox (where the URL text appears, |
| 186 // not where the icons are shown). | 189 // not where the icons are shown). |
| 187 gfx::Point GetOmniboxViewOrigin() const; | 190 gfx::Point GetOmniboxViewOrigin() const; |
| 188 | 191 |
| 189 // Returns the width of the location icon. | |
| 190 int GetLocationIconWidth() const; | |
| 191 | |
| 192 // Shows |text| as an inline autocompletion. This is useful for IMEs, where | 192 // Shows |text| as an inline autocompletion. This is useful for IMEs, where |
| 193 // we can't show the autocompletion inside the actual OmniboxView. See | 193 // we can't show the autocompletion inside the actual OmniboxView. See |
| 194 // comments on |ime_inline_autocomplete_view_|. | 194 // comments on |ime_inline_autocomplete_view_|. |
| 195 void SetImeInlineAutocompletion(const base::string16& text); | 195 void SetImeInlineAutocompletion(const base::string16& text); |
| 196 | 196 |
| 197 // Invoked from OmniboxViewWin to show gray text autocompletion. | 197 // Invoked from OmniboxViewWin to show gray text autocompletion. |
| 198 void SetGrayTextAutocompletion(const base::string16& text); | 198 void SetGrayTextAutocompletion(const base::string16& text); |
| 199 | 199 |
| 200 // Returns the current gray text autocompletion. | 200 // Returns the current gray text autocompletion. |
| 201 base::string16 GetGrayTextAutocompletion() const; | 201 base::string16 GetGrayTextAutocompletion() const; |
| (...skipping 66 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 268 // Helper for GetMinimumWidth(). Calculates the incremental minimum width | 268 // Helper for GetMinimumWidth(). Calculates the incremental minimum width |
| 269 // |view| should add to the trailing width after the omnibox. | 269 // |view| should add to the trailing width after the omnibox. |
| 270 int IncrementalMinimumWidth(views::View* view) const; | 270 int IncrementalMinimumWidth(views::View* view) const; |
| 271 | 271 |
| 272 // Returns the thickness of any visible edge, in pixels. | 272 // Returns the thickness of any visible edge, in pixels. |
| 273 int GetHorizontalEdgeThickness() const; | 273 int GetHorizontalEdgeThickness() const; |
| 274 int GetVerticalEdgeThickness() const; | 274 int GetVerticalEdgeThickness() const; |
| 275 | 275 |
| 276 // Returns the total amount of space reserved above or below the content, | 276 // Returns the total amount of space reserved above or below the content, |
| 277 // which is the vertical edge thickness plus the padding next to it. | 277 // which is the vertical edge thickness plus the padding next to it. |
| 278 int GetVerticalEdgeThicknessWithPadding() const; | 278 int GetTotalVerticalPadding() const; |
| 279 | 279 |
| 280 // Updates |location_icon_view_| based on the current state and theme. | 280 // Updates |location_icon_view_| based on the current state and theme. |
| 281 void RefreshLocationIcon(); | 281 void RefreshLocationIcon(); |
| 282 | 282 |
| 283 // Updates the visibility state of the Content Blocked icons to reflect what | 283 // Updates the visibility state of the Content Blocked icons to reflect what |
| 284 // is actually blocked on the current page. Returns true if the visibility | 284 // is actually blocked on the current page. Returns true if the visibility |
| 285 // of at least one of the views in |content_setting_views_| changed. | 285 // of at least one of the views in |content_setting_views_| changed. |
| 286 bool RefreshContentSettingViews(); | 286 bool RefreshContentSettingViews(); |
| 287 | 287 |
| 288 // Clears |page_action_views_| and removes the elements from the view | 288 // Clears |page_action_views_| and removes the elements from the view |
| (...skipping 75 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 364 ExtensionAction* GetPageAction(size_t index) override; | 364 ExtensionAction* GetPageAction(size_t index) override; |
| 365 ExtensionAction* GetVisiblePageAction(size_t index) override; | 365 ExtensionAction* GetVisiblePageAction(size_t index) override; |
| 366 void TestPageActionPressed(size_t index) override; | 366 void TestPageActionPressed(size_t index) override; |
| 367 bool GetBookmarkStarVisibility() override; | 367 bool GetBookmarkStarVisibility() override; |
| 368 | 368 |
| 369 // views::View: | 369 // views::View: |
| 370 const char* GetClassName() const override; | 370 const char* GetClassName() const override; |
| 371 void OnBoundsChanged(const gfx::Rect& previous_bounds) override; | 371 void OnBoundsChanged(const gfx::Rect& previous_bounds) override; |
| 372 void OnFocus() override; | 372 void OnFocus() override; |
| 373 void OnPaint(gfx::Canvas* canvas) override; | 373 void OnPaint(gfx::Canvas* canvas) override; |
| 374 void PaintChildren(const ui::PaintContext& context) override; | |
| 375 | 374 |
| 376 // views::DragController: | 375 // views::DragController: |
| 377 void WriteDragDataForView(View* sender, | 376 void WriteDragDataForView(View* sender, |
| 378 const gfx::Point& press_pt, | 377 const gfx::Point& press_pt, |
| 379 OSExchangeData* data) override; | 378 OSExchangeData* data) override; |
| 380 int GetDragOperationsForView(View* sender, const gfx::Point& p) override; | 379 int GetDragOperationsForView(View* sender, const gfx::Point& p) override; |
| 381 bool CanStartDragForView(View* sender, | 380 bool CanStartDragForView(View* sender, |
| 382 const gfx::Point& press_pt, | 381 const gfx::Point& press_pt, |
| 383 const gfx::Point& p) override; | 382 const gfx::Point& p) override; |
| 384 | 383 |
| (...skipping 14 matching lines...) Expand all Loading... |
| 399 // The Browser this LocationBarView is in. Note that at least | 398 // The Browser this LocationBarView is in. Note that at least |
| 400 // chromeos::SimpleWebViewDialog uses a LocationBarView outside any browser | 399 // chromeos::SimpleWebViewDialog uses a LocationBarView outside any browser |
| 401 // window, so this may be NULL. | 400 // window, so this may be NULL. |
| 402 Browser* browser_; | 401 Browser* browser_; |
| 403 | 402 |
| 404 OmniboxViewViews* omnibox_view_; | 403 OmniboxViewViews* omnibox_view_; |
| 405 | 404 |
| 406 // Our delegate. | 405 // Our delegate. |
| 407 Delegate* delegate_; | 406 Delegate* delegate_; |
| 408 | 407 |
| 409 // Object used to paint the border. Not used for material design. | |
| 410 std::unique_ptr<views::Painter> border_painter_; | |
| 411 | |
| 412 // An icon to the left of the edit field: the HTTPS lock, blank page icon, | 408 // An icon to the left of the edit field: the HTTPS lock, blank page icon, |
| 413 // search icon, EV HTTPS bubble, etc. | 409 // search icon, EV HTTPS bubble, etc. |
| 414 LocationIconView* location_icon_view_; | 410 LocationIconView* location_icon_view_; |
| 415 | 411 |
| 416 // 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, |
| 417 // 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, |
| 418 // 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 |
| 419 // we show any autocompletion in a separate field after the OmniboxView. | 415 // we show any autocompletion in a separate field after the OmniboxView. |
| 420 views::Label* ime_inline_autocomplete_view_; | 416 views::Label* ime_inline_autocomplete_view_; |
| 421 | 417 |
| (...skipping 60 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 482 bool web_contents_null_at_last_refresh_; | 478 bool web_contents_null_at_last_refresh_; |
| 483 | 479 |
| 484 // These allow toggling the verbose security state behavior via flags. | 480 // These allow toggling the verbose security state behavior via flags. |
| 485 bool should_show_secure_state_; | 481 bool should_show_secure_state_; |
| 486 bool should_animate_secure_state_; | 482 bool should_animate_secure_state_; |
| 487 | 483 |
| 488 DISALLOW_COPY_AND_ASSIGN(LocationBarView); | 484 DISALLOW_COPY_AND_ASSIGN(LocationBarView); |
| 489 }; | 485 }; |
| 490 | 486 |
| 491 #endif // CHROME_BROWSER_UI_VIEWS_LOCATION_BAR_LOCATION_BAR_VIEW_H_ | 487 #endif // CHROME_BROWSER_UI_VIEWS_LOCATION_BAR_LOCATION_BAR_VIEW_H_ |
| OLD | NEW |