| OLD | NEW |
| 1 // Copyright (c) 2009 The Chromium Authors. All rights reserved. | 1 // Copyright (c) 2009 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 #include "chrome/browser/views/toolbar_view.h" | 5 #include "chrome/browser/views/toolbar_view.h" |
| 6 | 6 |
| 7 #include <string> | 7 #include <string> |
| 8 | 8 |
| 9 #include "app/drag_drop_types.h" | 9 #include "app/drag_drop_types.h" |
| 10 #include "app/gfx/canvas.h" | 10 #include "app/gfx/canvas.h" |
| (...skipping 49 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 60 // Separation between the location bar and the menus. | 60 // Separation between the location bar and the menus. |
| 61 static const int kMenuButtonOffset = 3; | 61 static const int kMenuButtonOffset = 3; |
| 62 | 62 |
| 63 // Padding to the right of the location bar | 63 // Padding to the right of the location bar |
| 64 static const int kPaddingRight = 2; | 64 static const int kPaddingRight = 2; |
| 65 | 65 |
| 66 static const int kPopupTopSpacingNonGlass = 3; | 66 static const int kPopupTopSpacingNonGlass = 3; |
| 67 static const int kPopupBottomSpacingNonGlass = 2; | 67 static const int kPopupBottomSpacingNonGlass = 2; |
| 68 static const int kPopupBottomSpacingGlass = 1; | 68 static const int kPopupBottomSpacingGlass = 1; |
| 69 | 69 |
| 70 // The vertical distance between the bottom of the omnibox and the top of the | |
| 71 // popup. | |
| 72 static const int kOmniboxPopupVerticalSpacing = 2; | |
| 73 // The number of pixels of margin on the buttons on either side of the omnibox. | |
| 74 // We use this value to inset the bounds returned for the omnibox popup, since | |
| 75 // we want the popup to be only as wide as the visible frame of the omnibox. | |
| 76 static const int kOmniboxButtonsHorizontalMargin = 2; | |
| 77 | |
| 78 static SkBitmap* kPopupBackgroundEdge = NULL; | 70 static SkBitmap* kPopupBackgroundEdge = NULL; |
| 79 | 71 |
| 80 //////////////////////////////////////////////////////////////////////////////// | 72 //////////////////////////////////////////////////////////////////////////////// |
| 81 // EncodingMenuModel | 73 // EncodingMenuModel |
| 82 | 74 |
| 83 EncodingMenuModel::EncodingMenuModel(Browser* browser) | 75 EncodingMenuModel::EncodingMenuModel(Browser* browser) |
| 84 : SimpleMenuModel(this), | 76 : SimpleMenuModel(this), |
| 85 browser_(browser) { | 77 browser_(browser) { |
| 86 Build(); | 78 Build(); |
| 87 } | 79 } |
| (...skipping 269 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 357 // ongoing user edits, since it doesn't realize this is a user-initiated | 349 // ongoing user edits, since it doesn't realize this is a user-initiated |
| 358 // action. | 350 // action. |
| 359 location_bar_->Revert(); | 351 location_bar_->Revert(); |
| 360 break; | 352 break; |
| 361 } | 353 } |
| 362 browser_->ExecuteCommandWithDisposition( | 354 browser_->ExecuteCommandWithDisposition( |
| 363 id, event_utils::DispositionFromEventFlags(sender->mouse_event_flags())); | 355 id, event_utils::DispositionFromEventFlags(sender->mouse_event_flags())); |
| 364 } | 356 } |
| 365 | 357 |
| 366 //////////////////////////////////////////////////////////////////////////////// | 358 //////////////////////////////////////////////////////////////////////////////// |
| 367 // ToolbarView, AutocompletePopupPositioner implementation: | 359 // ToolbarView, BubblePositioner implementation: |
| 368 | 360 |
| 369 gfx::Rect ToolbarView::GetPopupBounds() const { | 361 gfx::Rect ToolbarView::GetLocationStackBounds() const { |
| 362 // The number of pixels from the left or right edges of the location stack to |
| 363 // "just inside the visible borders". When the omnibox bubble contents are |
| 364 // aligned with this, the visible borders tacked on to the outsides will line |
| 365 // up with the visible borders on the location stack. |
| 366 const int kLocationStackEdgeWidth = 2; |
| 367 |
| 370 gfx::Point origin; | 368 gfx::Point origin; |
| 371 views::View::ConvertPointToScreen(star_, &origin); | 369 views::View::ConvertPointToScreen(star_, &origin); |
| 372 origin.set_y(origin.y() + star_->height() + kOmniboxPopupVerticalSpacing); | 370 gfx::Rect stack_bounds(origin.x(), origin.y(), |
| 373 gfx::Rect popup_bounds(origin.x(), origin.y(), | |
| 374 star_->width() + location_bar_->width() + go_->width(), | 371 star_->width() + location_bar_->width() + go_->width(), |
| 375 0); | 372 location_bar_->height()); |
| 376 if (UILayoutIsRightToLeft()) { | 373 if (UILayoutIsRightToLeft()) { |
| 377 popup_bounds.set_x( | 374 stack_bounds.set_x( |
| 378 popup_bounds.x() - location_bar_->width() - go_->width()); | 375 stack_bounds.x() - location_bar_->width() - go_->width()); |
| 379 } else { | |
| 380 popup_bounds.set_x(popup_bounds.x()); | |
| 381 } | 376 } |
| 382 popup_bounds.set_y(popup_bounds.y()); | 377 // Inset the bounds to just inside the visible edges (see comment above). |
| 383 popup_bounds.set_width(popup_bounds.width()); | 378 stack_bounds.Inset(kLocationStackEdgeWidth, 0); |
| 384 // Inset the bounds a little, since the buttons on either edge of the omnibox | 379 return stack_bounds; |
| 385 // have invisible padding that makes the popup appear too wide. | |
| 386 popup_bounds.Inset(kOmniboxButtonsHorizontalMargin, 0); | |
| 387 return popup_bounds; | |
| 388 } | 380 } |
| 389 | 381 |
| 390 //////////////////////////////////////////////////////////////////////////////// | 382 //////////////////////////////////////////////////////////////////////////////// |
| 391 // ToolbarView, NotificationObserver implementation: | 383 // ToolbarView, NotificationObserver implementation: |
| 392 | 384 |
| 393 void ToolbarView::Observe(NotificationType type, | 385 void ToolbarView::Observe(NotificationType type, |
| 394 const NotificationSource& source, | 386 const NotificationSource& source, |
| 395 const NotificationDetails& details) { | 387 const NotificationDetails& details) { |
| 396 if (type == NotificationType::PREF_CHANGED) { | 388 if (type == NotificationType::PREF_CHANGED) { |
| 397 std::wstring* pref_name = Details<std::wstring>(details).ptr(); | 389 std::wstring* pref_name = Details<std::wstring>(details).ptr(); |
| (...skipping 688 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 1086 app_menu_contents_->AddItem(IDC_ABOUT, | 1078 app_menu_contents_->AddItem(IDC_ABOUT, |
| 1087 l10n_util::GetStringFUTF16( | 1079 l10n_util::GetStringFUTF16( |
| 1088 IDS_ABOUT, | 1080 IDS_ABOUT, |
| 1089 l10n_util::GetStringUTF16(IDS_PRODUCT_NAME))); | 1081 l10n_util::GetStringUTF16(IDS_PRODUCT_NAME))); |
| 1090 app_menu_contents_->AddItemWithStringId(IDC_HELP_PAGE, IDS_HELP_PAGE); | 1082 app_menu_contents_->AddItemWithStringId(IDC_HELP_PAGE, IDS_HELP_PAGE); |
| 1091 app_menu_contents_->AddSeparator(); | 1083 app_menu_contents_->AddSeparator(); |
| 1092 app_menu_contents_->AddItemWithStringId(IDC_EXIT, IDS_EXIT); | 1084 app_menu_contents_->AddItemWithStringId(IDC_EXIT, IDS_EXIT); |
| 1093 | 1085 |
| 1094 app_menu_menu_.reset(new views::Menu2(app_menu_contents_.get())); | 1086 app_menu_menu_.reset(new views::Menu2(app_menu_contents_.get())); |
| 1095 } | 1087 } |
| OLD | NEW |