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 "app/drag_drop_types.h" | 9 #include "app/drag_drop_types.h" |
10 #include "app/gfx/canvas.h" | 10 #include "app/gfx/canvas.h" |
11 #include "app/l10n_util.h" | 11 #include "app/l10n_util.h" |
12 #include "app/os_exchange_data.h" | 12 #include "app/os_exchange_data.h" |
13 #include "app/resource_bundle.h" | 13 #include "app/resource_bundle.h" |
14 #include "base/command_line.h" | 14 #include "base/command_line.h" |
15 #include "base/logging.h" | 15 #include "base/logging.h" |
16 #include "base/path_service.h" | 16 #include "base/path_service.h" |
17 #include "chrome/app/chrome_dll_resource.h" | 17 #include "chrome/app/chrome_dll_resource.h" |
18 #include "chrome/browser/bookmarks/bookmark_model.h" | 18 #include "chrome/browser/bookmarks/bookmark_model.h" |
19 #include "chrome/browser/browser.h" | 19 #include "chrome/browser/browser.h" |
20 #include "chrome/browser/browser_process.h" | 20 #include "chrome/browser/browser_process.h" |
21 #include "chrome/browser/character_encoding.h" | 21 #include "chrome/browser/character_encoding.h" |
22 #include "chrome/browser/metrics/user_metrics.h" | 22 #include "chrome/browser/metrics/user_metrics.h" |
23 #include "chrome/browser/profile.h" | 23 #include "chrome/browser/profile.h" |
24 #include "chrome/browser/tab_contents/navigation_controller.h" | 24 #include "chrome/browser/tab_contents/navigation_controller.h" |
25 #include "chrome/browser/tab_contents/navigation_entry.h" | 25 #include "chrome/browser/tab_contents/navigation_entry.h" |
26 #include "chrome/browser/browser_theme_provider.h" | 26 #include "chrome/browser/browser_theme_provider.h" |
27 #include "chrome/browser/user_data_manager.h" | 27 #include "chrome/browser/user_data_manager.h" |
28 #include "chrome/browser/views/bookmark_menu_button.h" | 28 #include "chrome/browser/views/bookmark_menu_button.h" |
29 #include "chrome/browser/views/dom_view.h" | |
30 #include "chrome/browser/views/event_utils.h" | 29 #include "chrome/browser/views/event_utils.h" |
31 #include "chrome/browser/views/go_button.h" | 30 #include "chrome/browser/views/go_button.h" |
32 #include "chrome/browser/views/location_bar_view.h" | 31 #include "chrome/browser/views/location_bar_view.h" |
33 #include "chrome/browser/views/theme_helpers.h" | |
34 #include "chrome/browser/views/toolbar_star_toggle.h" | 32 #include "chrome/browser/views/toolbar_star_toggle.h" |
35 #include "chrome/browser/view_ids.h" | 33 #include "chrome/browser/view_ids.h" |
36 #include "chrome/common/chrome_constants.h" | 34 #include "chrome/common/chrome_constants.h" |
37 #include "chrome/common/chrome_switches.h" | 35 #include "chrome/common/chrome_switches.h" |
38 #include "chrome/common/notification_service.h" | 36 #include "chrome/common/notification_service.h" |
39 #include "chrome/common/pref_names.h" | 37 #include "chrome/common/pref_names.h" |
40 #include "chrome/common/pref_service.h" | 38 #include "chrome/common/pref_service.h" |
41 #ifdef CHROME_PERSONALIZATION | 39 #ifdef CHROME_PERSONALIZATION |
42 #include "chrome/personalization/personalization.h" | 40 #include "chrome/personalization/personalization.h" |
43 #endif | 41 #endif |
44 #include "grit/chromium_strings.h" | 42 #include "grit/chromium_strings.h" |
45 #include "grit/generated_resources.h" | 43 #include "grit/generated_resources.h" |
46 #include "grit/theme_resources.h" | 44 #include "grit/theme_resources.h" |
47 #include "net/base/net_util.h" | 45 #include "net/base/net_util.h" |
48 #include "views/background.h" | 46 #include "views/background.h" |
49 #include "views/controls/button/button_dropdown.h" | 47 #include "views/controls/button/button_dropdown.h" |
50 #include "views/controls/hwnd_view.h" | |
51 #include "views/controls/label.h" | 48 #include "views/controls/label.h" |
| 49 #if defined(OS_WIN) |
52 #include "views/drag_utils.h" | 50 #include "views/drag_utils.h" |
53 #include "views/widget/tooltip_manager.h" | 51 #include "views/widget/tooltip_manager.h" |
| 52 #endif |
54 #include "views/window/non_client_view.h" | 53 #include "views/window/non_client_view.h" |
55 #include "views/window/window.h" | 54 #include "views/window/window.h" |
56 | 55 |
57 static const int kControlHorizOffset = 4; | 56 static const int kControlHorizOffset = 4; |
58 static const int kControlVertOffset = 6; | 57 static const int kControlVertOffset = 6; |
59 static const int kControlIndent = 3; | 58 static const int kControlIndent = 3; |
60 static const int kStatusBubbleWidth = 480; | 59 static const int kStatusBubbleWidth = 480; |
61 | 60 |
62 // Separation between the location bar and the menus. | 61 // Separation between the location bar and the menus. |
63 static const int kMenuButtonOffset = 3; | 62 static const int kMenuButtonOffset = 3; |
(...skipping 11 matching lines...) Expand all Loading... |
75 // The number of pixels of margin on the buttons on either side of the omnibox. | 74 // The number of pixels of margin on the buttons on either side of the omnibox. |
76 // We use this value to inset the bounds returned for the omnibox popup, since | 75 // We use this value to inset the bounds returned for the omnibox popup, since |
77 // we want the popup to be only as wide as the visible frame of the omnibox. | 76 // we want the popup to be only as wide as the visible frame of the omnibox. |
78 static const int kOmniboxButtonsHorizontalMargin = 2; | 77 static const int kOmniboxButtonsHorizontalMargin = 2; |
79 | 78 |
80 static SkBitmap* kPopupBackgroundEdge = NULL; | 79 static SkBitmap* kPopupBackgroundEdge = NULL; |
81 | 80 |
82 BrowserToolbarView::BrowserToolbarView(Browser* browser) | 81 BrowserToolbarView::BrowserToolbarView(Browser* browser) |
83 : EncodingMenuControllerDelegate(browser), | 82 : EncodingMenuControllerDelegate(browser), |
84 model_(browser->toolbar_model()), | 83 model_(browser->toolbar_model()), |
| 84 acc_focused_view_(NULL), |
85 back_(NULL), | 85 back_(NULL), |
86 forward_(NULL), | 86 forward_(NULL), |
87 reload_(NULL), | 87 reload_(NULL), |
88 home_(NULL), | 88 home_(NULL), |
89 star_(NULL), | 89 star_(NULL), |
90 location_bar_(NULL), | 90 location_bar_(NULL), |
91 go_(NULL), | 91 go_(NULL), |
| 92 page_menu_(NULL), |
| 93 app_menu_(NULL), |
| 94 bookmark_menu_(NULL), |
92 profile_(NULL), | 95 profile_(NULL), |
93 acc_focused_view_(NULL), | |
94 browser_(browser), | 96 browser_(browser), |
95 tab_(NULL), | 97 tab_(NULL), |
96 profiles_helper_(new GetProfilesHelper(this)), | 98 profiles_menu_(NULL), |
97 profiles_menu_(NULL) { | 99 profiles_helper_(new GetProfilesHelper(this)) { |
98 browser_->command_updater()->AddCommandObserver(IDC_BACK, this); | 100 browser_->command_updater()->AddCommandObserver(IDC_BACK, this); |
99 browser_->command_updater()->AddCommandObserver(IDC_FORWARD, this); | 101 browser_->command_updater()->AddCommandObserver(IDC_FORWARD, this); |
100 browser_->command_updater()->AddCommandObserver(IDC_RELOAD, this); | 102 browser_->command_updater()->AddCommandObserver(IDC_RELOAD, this); |
101 browser_->command_updater()->AddCommandObserver(IDC_HOME, this); | 103 browser_->command_updater()->AddCommandObserver(IDC_HOME, this); |
102 browser_->command_updater()->AddCommandObserver(IDC_STAR, this); | 104 browser_->command_updater()->AddCommandObserver(IDC_STAR, this); |
103 back_menu_model_.reset(new BackForwardMenuModelWin( | 105 back_menu_model_.reset(new BackForwardMenuModelWin( |
104 browser, BackForwardMenuModel::BACKWARD_MENU_DELEGATE)); | 106 browser, BackForwardMenuModel::BACKWARD_MENU_DELEGATE)); |
105 forward_menu_model_.reset(new BackForwardMenuModelWin( | 107 forward_menu_model_.reset(new BackForwardMenuModelWin( |
106 browser, BackForwardMenuModel::FORWARD_MENU_DELEGATE)); | 108 browser, BackForwardMenuModel::FORWARD_MENU_DELEGATE)); |
107 if (browser->type() == Browser::TYPE_NORMAL) | 109 if (browser->type() == Browser::TYPE_NORMAL) |
(...skipping 92 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
200 go_->SetID(VIEW_ID_GO_BUTTON); | 202 go_->SetID(VIEW_ID_GO_BUTTON); |
201 | 203 |
202 LoadCenterStackImages(); | 204 LoadCenterStackImages(); |
203 | 205 |
204 AddChildView(location_bar_); | 206 AddChildView(location_bar_); |
205 location_bar_->Init(); | 207 location_bar_->Init(); |
206 AddChildView(go_); | 208 AddChildView(go_); |
207 } | 209 } |
208 | 210 |
209 void BrowserToolbarView::CreateRightSideControls(Profile* profile) { | 211 void BrowserToolbarView::CreateRightSideControls(Profile* profile) { |
210 ThemeProvider* tp = GetThemeProvider(); | |
211 | |
212 page_menu_ = new views::MenuButton(NULL, std::wstring(), this, false); | 212 page_menu_ = new views::MenuButton(NULL, std::wstring(), this, false); |
213 page_menu_->SetAccessibleName(l10n_util::GetString(IDS_ACCNAME_PAGE)); | 213 page_menu_->SetAccessibleName(l10n_util::GetString(IDS_ACCNAME_PAGE)); |
214 page_menu_->SetTooltipText(l10n_util::GetString(IDS_PAGEMENU_TOOLTIP)); | 214 page_menu_->SetTooltipText(l10n_util::GetString(IDS_PAGEMENU_TOOLTIP)); |
215 page_menu_->SetID(VIEW_ID_PAGE_MENU); | 215 page_menu_->SetID(VIEW_ID_PAGE_MENU); |
216 | 216 |
217 | 217 |
218 app_menu_ = new views::MenuButton(NULL, std::wstring(), this, false); | 218 app_menu_ = new views::MenuButton(NULL, std::wstring(), this, false); |
219 app_menu_->SetAccessibleName(l10n_util::GetString(IDS_ACCNAME_APP)); | 219 app_menu_->SetAccessibleName(l10n_util::GetString(IDS_ACCNAME_APP)); |
220 app_menu_->SetTooltipText(l10n_util::GetStringF(IDS_APPMENU_TOOLTIP, | 220 app_menu_->SetTooltipText(l10n_util::GetStringF(IDS_APPMENU_TOOLTIP, |
221 l10n_util::GetString(IDS_PRODUCT_NAME))); | 221 l10n_util::GetString(IDS_PRODUCT_NAME))); |
(...skipping 197 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
419 } | 419 } |
420 | 420 |
421 // For glass, we need to draw a black line below the location bar to separate | 421 // For glass, we need to draw a black line below the location bar to separate |
422 // it from the content area. For non-glass, the NonClientView draws the | 422 // it from the content area. For non-glass, the NonClientView draws the |
423 // toolbar background below the location bar for us. | 423 // toolbar background below the location bar for us. |
424 if (GetWindow()->GetNonClientView()->UseNativeFrame()) | 424 if (GetWindow()->GetNonClientView()->UseNativeFrame()) |
425 canvas->FillRectInt(SK_ColorBLACK, 0, height() - 1, width(), 1); | 425 canvas->FillRectInt(SK_ColorBLACK, 0, height() - 1, width(), 1); |
426 } | 426 } |
427 | 427 |
428 void BrowserToolbarView::DidGainFocus() { | 428 void BrowserToolbarView::DidGainFocus() { |
| 429 #if defined(OS_WIN) |
429 // Check to see if MSAA focus should be restored to previously focused button, | 430 // Check to see if MSAA focus should be restored to previously focused button, |
430 // and if button is an enabled, visibled child of toolbar. | 431 // and if button is an enabled, visibled child of toolbar. |
431 if (!acc_focused_view_ || | 432 if (!acc_focused_view_ || |
432 (acc_focused_view_->GetParent()->GetID() != VIEW_ID_TOOLBAR) || | 433 (acc_focused_view_->GetParent()->GetID() != VIEW_ID_TOOLBAR) || |
433 !acc_focused_view_->IsEnabled() || | 434 !acc_focused_view_->IsEnabled() || |
434 !acc_focused_view_->IsVisible()) { | 435 !acc_focused_view_->IsVisible()) { |
435 // Find first accessible child (-1 to start search at parent). | 436 // Find first accessible child (-1 to start search at parent). |
436 int first_acc_child = GetNextAccessibleViewIndex(-1, false); | 437 int first_acc_child = GetNextAccessibleViewIndex(-1, false); |
437 | 438 |
438 // No buttons enabled or visible. | 439 // No buttons enabled or visible. |
(...skipping 16 matching lines...) Expand all Loading... |
455 | 456 |
456 // Update focused_view with MSAA-adjusted child id. | 457 // Update focused_view with MSAA-adjusted child id. |
457 view_index = acc_focused_view_->GetID(); | 458 view_index = acc_focused_view_->GetID(); |
458 } | 459 } |
459 | 460 |
460 gfx::NativeView wnd = GetWidget()->GetNativeView(); | 461 gfx::NativeView wnd = GetWidget()->GetNativeView(); |
461 | 462 |
462 // Notify Access Technology that there was a change in keyboard focus. | 463 // Notify Access Technology that there was a change in keyboard focus. |
463 ::NotifyWinEvent(EVENT_OBJECT_FOCUS, wnd, OBJID_CLIENT, | 464 ::NotifyWinEvent(EVENT_OBJECT_FOCUS, wnd, OBJID_CLIENT, |
464 static_cast<LONG>(view_index)); | 465 static_cast<LONG>(view_index)); |
| 466 #else |
| 467 // TODO(port): deal with toolbar a11y focus. |
| 468 NOTIMPLEMENTED(); |
| 469 #endif |
465 } | 470 } |
466 | 471 |
467 void BrowserToolbarView::WillLoseFocus() { | 472 void BrowserToolbarView::WillLoseFocus() { |
| 473 #if defined(OS_WIN) |
468 if (acc_focused_view_) { | 474 if (acc_focused_view_) { |
469 // Resetting focus state. | 475 // Resetting focus state. |
470 acc_focused_view_->SetHotTracked(false); | 476 acc_focused_view_->SetHotTracked(false); |
471 } | 477 } |
472 // Any tooltips that are active should be hidden when toolbar loses focus. | 478 // Any tooltips that are active should be hidden when toolbar loses focus. |
473 if (GetWidget() && GetWidget()->GetTooltipManager()) | 479 if (GetWidget() && GetWidget()->GetTooltipManager()) |
474 GetWidget()->GetTooltipManager()->HideKeyboardTooltip(); | 480 GetWidget()->GetTooltipManager()->HideKeyboardTooltip(); |
| 481 #else |
| 482 // TODO(port): deal with toolbar a11y focus. |
| 483 NOTIMPLEMENTED(); |
| 484 #endif |
475 } | 485 } |
476 | 486 |
477 bool BrowserToolbarView::OnKeyPressed(const views::KeyEvent& e) { | 487 bool BrowserToolbarView::OnKeyPressed(const views::KeyEvent& e) { |
| 488 #if defined(OS_WIN) |
478 // Paranoia check, button should be initialized upon toolbar gaining focus. | 489 // Paranoia check, button should be initialized upon toolbar gaining focus. |
479 if (!acc_focused_view_) | 490 if (!acc_focused_view_) |
480 return false; | 491 return false; |
481 | 492 |
482 int focused_view = GetChildIndex(acc_focused_view_); | 493 int focused_view = GetChildIndex(acc_focused_view_); |
483 int next_view = focused_view; | 494 int next_view = focused_view; |
484 | 495 |
485 switch (e.GetCharacter()) { | 496 switch (e.GetCharacter()) { |
486 case VK_LEFT: | 497 case VK_LEFT: |
487 next_view = GetNextAccessibleViewIndex(focused_view, true); | 498 next_view = GetNextAccessibleViewIndex(focused_view, true); |
(...skipping 47 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
535 // Show the tooltip for the view that got the focus. | 546 // Show the tooltip for the view that got the focus. |
536 if (GetWidget()->GetTooltipManager()) { | 547 if (GetWidget()->GetTooltipManager()) { |
537 GetWidget()->GetTooltipManager()-> | 548 GetWidget()->GetTooltipManager()-> |
538 ShowKeyboardTooltip(GetChildViewAt(next_view)); | 549 ShowKeyboardTooltip(GetChildViewAt(next_view)); |
539 } | 550 } |
540 // Notify Access Technology that there was a change in keyboard focus. | 551 // Notify Access Technology that there was a change in keyboard focus. |
541 ::NotifyWinEvent(EVENT_OBJECT_FOCUS, wnd, OBJID_CLIENT, | 552 ::NotifyWinEvent(EVENT_OBJECT_FOCUS, wnd, OBJID_CLIENT, |
542 static_cast<LONG>(view_id)); | 553 static_cast<LONG>(view_id)); |
543 return true; | 554 return true; |
544 } | 555 } |
| 556 #else |
| 557 // TODO(port): deal with toolbar a11y focus. |
| 558 NOTIMPLEMENTED(); |
| 559 #endif |
545 return false; | 560 return false; |
546 } | 561 } |
547 | 562 |
548 bool BrowserToolbarView::OnKeyReleased(const views::KeyEvent& e) { | 563 bool BrowserToolbarView::OnKeyReleased(const views::KeyEvent& e) { |
549 // Paranoia check, button should be initialized upon toolbar gaining focus. | 564 // Paranoia check, button should be initialized upon toolbar gaining focus. |
550 if (!acc_focused_view_) | 565 if (!acc_focused_view_) |
551 return false; | 566 return false; |
552 | 567 |
553 // Have keys be handled by the views themselves. | 568 // Have keys be handled by the views themselves. |
554 return acc_focused_view_->OnKeyReleased(e); | 569 return acc_focused_view_->OnKeyReleased(e); |
(...skipping 57 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
612 l10n_util::GetString(IDS_ZOOM_NORMAL)); | 627 l10n_util::GetString(IDS_ZOOM_NORMAL)); |
613 zoom_menu->AppendMenuItemWithLabel(IDC_ZOOM_MINUS, | 628 zoom_menu->AppendMenuItemWithLabel(IDC_ZOOM_MINUS, |
614 l10n_util::GetString(IDS_ZOOM_MINUS)); | 629 l10n_util::GetString(IDS_ZOOM_MINUS)); |
615 | 630 |
616 // Create encoding menu. | 631 // Create encoding menu. |
617 views::Menu* encoding_menu = menu->AppendSubMenu( | 632 views::Menu* encoding_menu = menu->AppendSubMenu( |
618 IDC_ENCODING_MENU, l10n_util::GetString(IDS_ENCODING_MENU)); | 633 IDC_ENCODING_MENU, l10n_util::GetString(IDS_ENCODING_MENU)); |
619 | 634 |
620 EncodingMenuControllerDelegate::BuildEncodingMenu(profile_, encoding_menu); | 635 EncodingMenuControllerDelegate::BuildEncodingMenu(profile_, encoding_menu); |
621 | 636 |
622 struct MenuCreateMaterial { | 637 #if defined(OS_WIN) |
| 638 const struct MenuCreateMaterial { |
623 unsigned int menu_id; | 639 unsigned int menu_id; |
624 unsigned int menu_label_id; | 640 unsigned int menu_label_id; |
625 }; | 641 } developer_menu_materials[] = { |
626 struct MenuCreateMaterial developer_menu_materials[] = { | |
627 { IDC_VIEW_SOURCE, IDS_VIEW_SOURCE }, | 642 { IDC_VIEW_SOURCE, IDS_VIEW_SOURCE }, |
628 { IDC_DEBUGGER, IDS_DEBUGGER }, | 643 { IDC_DEBUGGER, IDS_DEBUGGER }, |
629 { IDC_JS_CONSOLE, IDS_JS_CONSOLE }, | 644 { IDC_JS_CONSOLE, IDS_JS_CONSOLE }, |
630 { IDC_TASK_MANAGER, IDS_TASK_MANAGER } | 645 { IDC_TASK_MANAGER, IDS_TASK_MANAGER } |
631 }; | 646 }; |
632 // Append developer menu. | 647 // Append developer menu. |
633 menu->AppendSeparator(); | 648 menu->AppendSeparator(); |
634 views::Menu* developer_menu = menu->AppendSubMenu(IDC_DEVELOPER_MENU, | 649 views::Menu* developer_menu = menu->AppendSubMenu(IDC_DEVELOPER_MENU, |
635 l10n_util::GetString(IDS_DEVELOPER_MENU)); | 650 l10n_util::GetString(IDS_DEVELOPER_MENU)); |
636 | 651 |
637 const CommandLine& command_line = *CommandLine::ForCurrentProcess(); | 652 const CommandLine& command_line = *CommandLine::ForCurrentProcess(); |
638 bool new_tools = !command_line.HasSwitch( | 653 bool new_tools = !command_line.HasSwitch( |
639 switches::kDisableOutOfProcessDevTools); | 654 switches::kDisableOutOfProcessDevTools); |
640 | 655 |
641 for (int i = 0; i < arraysize(developer_menu_materials); ++i) { | 656 for (int i = 0; i < arraysize(developer_menu_materials); ++i) { |
642 if (new_tools && developer_menu_materials[i].menu_id == IDC_DEBUGGER) | 657 if (new_tools && developer_menu_materials[i].menu_id == IDC_DEBUGGER) |
643 continue; | 658 continue; |
644 if (developer_menu_materials[i].menu_id) { | 659 if (developer_menu_materials[i].menu_id) { |
645 developer_menu->AppendMenuItemWithLabel( | 660 developer_menu->AppendMenuItemWithLabel( |
646 developer_menu_materials[i].menu_id, | 661 developer_menu_materials[i].menu_id, |
647 l10n_util::GetString(developer_menu_materials[i].menu_label_id)); | 662 l10n_util::GetString(developer_menu_materials[i].menu_label_id)); |
648 } else { | 663 } else { |
649 developer_menu->AppendSeparator(); | 664 developer_menu->AppendSeparator(); |
650 } | 665 } |
651 } | 666 } |
| 667 #endif |
652 | 668 |
653 menu->AppendSeparator(); | 669 menu->AppendSeparator(); |
654 | 670 |
655 menu->AppendMenuItemWithLabel(IDC_REPORT_BUG, | 671 menu->AppendMenuItemWithLabel(IDC_REPORT_BUG, |
656 l10n_util::GetString(IDS_REPORT_BUG)); | 672 l10n_util::GetString(IDS_REPORT_BUG)); |
657 menu->RunMenuAt(pt.x(), pt.y()); | 673 menu->RunMenuAt(pt.x(), pt.y()); |
658 } | 674 } |
659 | 675 |
660 void BrowserToolbarView::RunAppMenu(const gfx::Point& pt, | 676 void BrowserToolbarView::RunAppMenu(const gfx::Point& pt, |
661 gfx::NativeView parent) { | 677 gfx::NativeView parent) { |
(...skipping 182 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
844 } | 860 } |
845 | 861 |
846 void BrowserToolbarView::WriteDragData(views::View* sender, | 862 void BrowserToolbarView::WriteDragData(views::View* sender, |
847 int press_x, | 863 int press_x, |
848 int press_y, | 864 int press_y, |
849 OSExchangeData* data) { | 865 OSExchangeData* data) { |
850 DCHECK( | 866 DCHECK( |
851 GetDragOperations(sender, press_x, press_y) != DragDropTypes::DRAG_NONE); | 867 GetDragOperations(sender, press_x, press_y) != DragDropTypes::DRAG_NONE); |
852 | 868 |
853 UserMetrics::RecordAction(L"Toolbar_DragStar", profile_); | 869 UserMetrics::RecordAction(L"Toolbar_DragStar", profile_); |
854 | 870 |
| 871 #if defined(OS_WIN) |
855 // If there is a bookmark for the URL, add the bookmark drag data for it. We | 872 // If there is a bookmark for the URL, add the bookmark drag data for it. We |
856 // do this to ensure the bookmark is moved, rather than creating an new | 873 // do this to ensure the bookmark is moved, rather than creating an new |
857 // bookmark. | 874 // bookmark. |
858 if (profile_ && profile_->GetBookmarkModel()) { | 875 if (profile_ && profile_->GetBookmarkModel()) { |
859 BookmarkNode* node = profile_->GetBookmarkModel()-> | 876 BookmarkNode* node = profile_->GetBookmarkModel()-> |
860 GetMostRecentlyAddedNodeForURL(tab_->GetURL()); | 877 GetMostRecentlyAddedNodeForURL(tab_->GetURL()); |
861 if (node) { | 878 if (node) { |
862 BookmarkDragData bookmark_data(node); | 879 BookmarkDragData bookmark_data(node); |
863 bookmark_data.Write(profile_, data); | 880 bookmark_data.Write(profile_, data); |
864 } | 881 } |
865 } | 882 } |
866 | 883 |
867 drag_utils::SetURLAndDragImage(tab_->GetURL(), | 884 drag_utils::SetURLAndDragImage(tab_->GetURL(), |
868 UTF16ToWideHack(tab_->GetTitle()), | 885 UTF16ToWideHack(tab_->GetTitle()), |
869 tab_->GetFavIcon(), | 886 tab_->GetFavIcon(), |
870 data); | 887 data); |
| 888 #else |
| 889 // TODO(port): do bookmark item drag & drop |
| 890 NOTIMPLEMENTED(); |
| 891 #endif |
871 } | 892 } |
872 | 893 |
873 TabContents* BrowserToolbarView::GetTabContents() { | 894 TabContents* BrowserToolbarView::GetTabContents() { |
874 return tab_; | 895 return tab_; |
875 } | 896 } |
876 | 897 |
877 void BrowserToolbarView::EnabledStateChangedForCommand(int id, bool enabled) { | 898 void BrowserToolbarView::EnabledStateChangedForCommand(int id, bool enabled) { |
878 views::Button* button = NULL; | 899 views::Button* button = NULL; |
879 switch (id) { | 900 switch (id) { |
880 case IDC_BACK: | 901 case IDC_BACK: |
(...skipping 73 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
954 case IDC_COPY: | 975 case IDC_COPY: |
955 *accel = views::Accelerator(L'C', false, true, false); | 976 *accel = views::Accelerator(L'C', false, true, false); |
956 return true; | 977 return true; |
957 case IDC_PASTE: | 978 case IDC_PASTE: |
958 *accel = views::Accelerator(L'V', false, true, false); | 979 *accel = views::Accelerator(L'V', false, true, false); |
959 return true; | 980 return true; |
960 } | 981 } |
961 // Else, we retrieve the accelerator information from the frame. | 982 // Else, we retrieve the accelerator information from the frame. |
962 return GetWidget()->GetAccelerator(id, accel); | 983 return GetWidget()->GetAccelerator(id, accel); |
963 } | 984 } |
OLD | NEW |