| OLD | NEW |
| 1 // Copyright (c) 2006-2008 The Chromium Authors. All rights reserved. | 1 // Copyright (c) 2006-2008 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 "base/command_line.h" | 9 #include "base/command_line.h" |
| 10 #include "base/logging.h" | 10 #include "base/logging.h" |
| 11 #include "base/path_service.h" | 11 #include "base/path_service.h" |
| 12 #include "chrome/app/chrome_dll_resource.h" | 12 #include "chrome/app/chrome_dll_resource.h" |
| 13 #include "chrome/browser/bookmarks/bookmark_drag_data.h" | |
| 14 #include "chrome/browser/bookmarks/bookmark_model.h" | 13 #include "chrome/browser/bookmarks/bookmark_model.h" |
| 15 #include "chrome/browser/browser.h" | 14 #include "chrome/browser/browser.h" |
| 16 #include "chrome/browser/browser_process.h" | 15 #include "chrome/browser/browser_process.h" |
| 17 #include "chrome/browser/character_encoding.h" | 16 #include "chrome/browser/character_encoding.h" |
| 18 #include "chrome/browser/drag_utils.h" | 17 #include "chrome/browser/drag_utils.h" |
| 19 #include "chrome/browser/metrics/user_metrics.h" | 18 #include "chrome/browser/metrics/user_metrics.h" |
| 20 #include "chrome/browser/profile.h" | 19 #include "chrome/browser/profile.h" |
| 21 #include "chrome/browser/tab_contents/navigation_controller.h" | 20 #include "chrome/browser/tab_contents/navigation_controller.h" |
| 22 #include "chrome/browser/tab_contents/navigation_entry.h" | 21 #include "chrome/browser/tab_contents/navigation_entry.h" |
| 23 #include "chrome/browser/user_data_manager.h" | 22 #include "chrome/browser/user_data_manager.h" |
| 23 #include "chrome/browser/views/bookmark_menu_button.h" |
| 24 #include "chrome/browser/views/dom_view.h" | 24 #include "chrome/browser/views/dom_view.h" |
| 25 #include "chrome/browser/views/go_button.h" | 25 #include "chrome/browser/views/go_button.h" |
| 26 #include "chrome/browser/views/location_bar_view.h" | 26 #include "chrome/browser/views/location_bar_view.h" |
| 27 #include "chrome/browser/views/theme_helpers.h" | 27 #include "chrome/browser/views/theme_helpers.h" |
| 28 #include "chrome/browser/views/toolbar_star_toggle.h" | 28 #include "chrome/browser/views/toolbar_star_toggle.h" |
| 29 #include "chrome/browser/view_ids.h" | 29 #include "chrome/browser/view_ids.h" |
| 30 #include "chrome/common/chrome_constants.h" | 30 #include "chrome/common/chrome_constants.h" |
| 31 #include "chrome/common/chrome_switches.h" | 31 #include "chrome/common/chrome_switches.h" |
| 32 #include "chrome/common/drag_drop_types.h" | 32 #include "chrome/common/drag_drop_types.h" |
| 33 #include "chrome/common/gfx/chrome_canvas.h" | 33 #include "chrome/common/gfx/chrome_canvas.h" |
| (...skipping 236 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 270 if (UILayoutIsRightToLeft()) | 270 if (UILayoutIsRightToLeft()) |
| 271 app_menu_->SetIcon(*rb.GetBitmapNamed(IDR_MENU_CHROME_RTL)); | 271 app_menu_->SetIcon(*rb.GetBitmapNamed(IDR_MENU_CHROME_RTL)); |
| 272 else | 272 else |
| 273 app_menu_->SetIcon(*rb.GetBitmapNamed(IDR_MENU_CHROME)); | 273 app_menu_->SetIcon(*rb.GetBitmapNamed(IDR_MENU_CHROME)); |
| 274 | 274 |
| 275 app_menu_->SetAccessibleName(l10n_util::GetString(IDS_ACCNAME_APP)); | 275 app_menu_->SetAccessibleName(l10n_util::GetString(IDS_ACCNAME_APP)); |
| 276 app_menu_->SetTooltipText(l10n_util::GetStringF(IDS_APPMENU_TOOLTIP, | 276 app_menu_->SetTooltipText(l10n_util::GetStringF(IDS_APPMENU_TOOLTIP, |
| 277 l10n_util::GetString(IDS_PRODUCT_NAME))); | 277 l10n_util::GetString(IDS_PRODUCT_NAME))); |
| 278 app_menu_->SetID(VIEW_ID_APP_MENU); | 278 app_menu_->SetID(VIEW_ID_APP_MENU); |
| 279 AddChildView(app_menu_); | 279 AddChildView(app_menu_); |
| 280 |
| 281 if (CommandLine::ForCurrentProcess()->HasSwitch(switches::kBookmarkMenu)) { |
| 282 bookmark_menu_ = new BookmarkMenuButton(browser_); |
| 283 AddChildView(bookmark_menu_); |
| 284 } else { |
| 285 bookmark_menu_ = NULL; |
| 286 } |
| 280 } | 287 } |
| 281 | 288 |
| 282 void BrowserToolbarView::Layout() { | 289 void BrowserToolbarView::Layout() { |
| 283 // If we have not been initialized yet just do nothing. | 290 // If we have not been initialized yet just do nothing. |
| 284 if (back_ == NULL) | 291 if (back_ == NULL) |
| 285 return; | 292 return; |
| 286 | 293 |
| 287 if (!IsDisplayModeNormal()) { | 294 if (!IsDisplayModeNormal()) { |
| 288 int edge_width = (browser_->window() && browser_->window()->IsMaximized()) ? | 295 int edge_width = (browser_->window() && browser_->window()->IsMaximized()) ? |
| 289 0 : kPopupBackgroundEdge->width(); // See Paint(). | 296 0 : kPopupBackgroundEdge->width(); // See Paint(). |
| (...skipping 35 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 325 home_->SetVisible(false); | 332 home_->SetVisible(false); |
| 326 home_->SetBounds(reload_->x() + reload_->width(), child_y, 0, child_height); | 333 home_->SetBounds(reload_->x() + reload_->width(), child_y, 0, child_height); |
| 327 } | 334 } |
| 328 | 335 |
| 329 star_->SetBounds(home_->x() + home_->width() + kControlHorizOffset, | 336 star_->SetBounds(home_->x() + home_->width() + kControlHorizOffset, |
| 330 child_y, star_->GetPreferredSize().width(), child_height); | 337 child_y, star_->GetPreferredSize().width(), child_height); |
| 331 | 338 |
| 332 int go_button_width = go_->GetPreferredSize().width(); | 339 int go_button_width = go_->GetPreferredSize().width(); |
| 333 int page_menu_width = page_menu_->GetPreferredSize().width(); | 340 int page_menu_width = page_menu_->GetPreferredSize().width(); |
| 334 int app_menu_width = app_menu_->GetPreferredSize().width(); | 341 int app_menu_width = app_menu_->GetPreferredSize().width(); |
| 342 int bookmark_menu_width = bookmark_menu_ ? |
| 343 bookmark_menu_->GetPreferredSize().width() : 0; |
| 335 int location_x = star_->x() + star_->width(); | 344 int location_x = star_->x() + star_->width(); |
| 336 int available_width = width() - kPaddingRight - app_menu_width - | 345 int available_width = width() - kPaddingRight - bookmark_menu_width - |
| 337 page_menu_width - kMenuButtonOffset - go_button_width - location_x; | 346 app_menu_width - page_menu_width - kMenuButtonOffset - go_button_width - |
| 347 location_x; |
| 338 location_bar_->SetBounds(location_x, child_y, std::max(available_width, 0), | 348 location_bar_->SetBounds(location_x, child_y, std::max(available_width, 0), |
| 339 child_height); | 349 child_height); |
| 340 | 350 |
| 341 go_->SetBounds(location_bar_->x() + location_bar_->width(), child_y, | 351 go_->SetBounds(location_bar_->x() + location_bar_->width(), child_y, |
| 342 go_button_width, child_height); | 352 go_button_width, child_height); |
| 343 | 353 |
| 344 page_menu_->SetBounds(go_->x() + go_->width() + kMenuButtonOffset, child_y, | 354 page_menu_->SetBounds(go_->x() + go_->width() + kMenuButtonOffset, child_y, |
| 345 page_menu_width, child_height); | 355 page_menu_width, child_height); |
| 346 | 356 |
| 347 app_menu_->SetBounds(page_menu_->x() + page_menu_->width(), child_y, | 357 app_menu_->SetBounds(page_menu_->x() + page_menu_->width(), child_y, |
| 348 app_menu_width, child_height); | 358 app_menu_width, child_height); |
| 359 |
| 360 if (bookmark_menu_) { |
| 361 bookmark_menu_->SetBounds(app_menu_->x() + app_menu_->width(), child_y, |
| 362 bookmark_menu_width, child_height); |
| 363 } |
| 349 } | 364 } |
| 350 | 365 |
| 351 void BrowserToolbarView::Paint(ChromeCanvas* canvas) { | 366 void BrowserToolbarView::Paint(ChromeCanvas* canvas) { |
| 352 View::Paint(canvas); | 367 View::Paint(canvas); |
| 353 | 368 |
| 354 if (IsDisplayModeNormal()) | 369 if (IsDisplayModeNormal()) |
| 355 return; | 370 return; |
| 356 | 371 |
| 357 // In maximized mode, we don't draw the endcaps on the location bar, because | 372 // In maximized mode, we don't draw the endcaps on the location bar, because |
| 358 // when they're flush against the edge of the screen they just look glitchy. | 373 // when they're flush against the edge of the screen they just look glitchy. |
| (...skipping 491 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 850 case IDC_COPY: | 865 case IDC_COPY: |
| 851 *accel = views::Accelerator(L'C', false, true, false); | 866 *accel = views::Accelerator(L'C', false, true, false); |
| 852 return true; | 867 return true; |
| 853 case IDC_PASTE: | 868 case IDC_PASTE: |
| 854 *accel = views::Accelerator(L'V', false, true, false); | 869 *accel = views::Accelerator(L'V', false, true, false); |
| 855 return true; | 870 return true; |
| 856 } | 871 } |
| 857 // Else, we retrieve the accelerator information from the frame. | 872 // Else, we retrieve the accelerator information from the frame. |
| 858 return GetWidget()->GetAccelerator(id, accel); | 873 return GetWidget()->GetAccelerator(id, accel); |
| 859 } | 874 } |
| OLD | NEW |