| 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/download_item_view.h" | 5 #include "chrome/browser/views/download_item_view.h" | 
| 6 | 6 | 
| 7 #include <vector> | 7 #include <vector> | 
| 8 | 8 | 
| 9 #include "base/file_util.h" | 9 #include "base/file_util.h" | 
| 10 #include "base/string_util.h" | 10 #include "base/string_util.h" | 
| (...skipping 581 matching lines...) Expand 10 before | Expand all | Expand 10 after  Loading... | 
| 592 bool DownloadItemView::OnMousePressed(const ChromeViews::MouseEvent& event) { | 592 bool DownloadItemView::OnMousePressed(const ChromeViews::MouseEvent& event) { | 
| 593   // Mouse should not activate us in dangerous mode. | 593   // Mouse should not activate us in dangerous mode. | 
| 594   if (IsDangerousMode()) | 594   if (IsDangerousMode()) | 
| 595     return true; | 595     return true; | 
| 596 | 596 | 
| 597   // Stop any completion animation. | 597   // Stop any completion animation. | 
| 598   if (complete_animation_.get() && complete_animation_->IsAnimating()) | 598   if (complete_animation_.get() && complete_animation_->IsAnimating()) | 
| 599     complete_animation_->End(); | 599     complete_animation_->End(); | 
| 600 | 600 | 
| 601   if (event.IsOnlyLeftMouseButton()) { | 601   if (event.IsOnlyLeftMouseButton()) { | 
| 602     WTL::CPoint point(event.x(), event.y()); | 602     gfx::Point point(event.location()); | 
| 603     if (event.x() < drop_down_x_) { | 603     if (event.x() < drop_down_x_) { | 
| 604       SetState(PUSHED, NORMAL); | 604       SetState(PUSHED, NORMAL); | 
| 605       return true; | 605       return true; | 
| 606     } | 606     } | 
| 607 | 607 | 
| 608     drop_down_pressed_ = true; | 608     drop_down_pressed_ = true; | 
| 609     SetState(NORMAL, PUSHED); | 609     SetState(NORMAL, PUSHED); | 
| 610 | 610 | 
| 611     // Similar hack as in MenuButton. | 611     // Similar hack as in MenuButton. | 
| 612     // We're about to show the menu from a mouse press. By showing from the | 612     // We're about to show the menu from a mouse press. By showing from the | 
| 613     // mouse press event we block RootView in mouse dispatching. This also | 613     // mouse press event we block RootView in mouse dispatching. This also | 
| 614     // appears to cause RootView to get a mouse pressed BEFORE the mouse | 614     // appears to cause RootView to get a mouse pressed BEFORE the mouse | 
| 615     // release is seen, which means RootView sends us another mouse press no | 615     // release is seen, which means RootView sends us another mouse press no | 
| 616     // matter where the user pressed. To force RootView to recalculate the | 616     // matter where the user pressed. To force RootView to recalculate the | 
| 617     // mouse target during the mouse press we explicitly set the mouse handler | 617     // mouse target during the mouse press we explicitly set the mouse handler | 
| 618     // to NULL. | 618     // to NULL. | 
| 619     GetRootView()->SetMouseHandler(NULL); | 619     GetRootView()->SetMouseHandler(NULL); | 
| 620 | 620 | 
| 621     // The menu's position is different depending on the UI layout. | 621     // The menu's position is different depending on the UI layout. | 
| 622     // DownloadShelfContextMenu will take care of setting the right anchor for | 622     // DownloadShelfContextMenu will take care of setting the right anchor for | 
| 623     // the menu depending on the locale. | 623     // the menu depending on the locale. | 
| 624     // | 624     // | 
| 625     // TODO(idana): when bug# 1163334 is fixed the following check should be | 625     // TODO(idana): when bug# 1163334 is fixed the following check should be | 
| 626     // replaced with UILayoutIsRightToLeft(). | 626     // replaced with UILayoutIsRightToLeft(). | 
| 627     point.y = height(); | 627     point.set_y(height()); | 
| 628     if (l10n_util::GetTextDirection() == l10n_util::RIGHT_TO_LEFT) { | 628     if (l10n_util::GetTextDirection() == l10n_util::RIGHT_TO_LEFT) { | 
| 629       point.x = width(); | 629       point.set_x(width()); | 
| 630     } else { | 630     } else { | 
| 631       point.x = drop_down_x_; | 631       point.set_x(drop_down_x_); | 
| 632     } | 632     } | 
| 633 | 633 | 
| 634     ChromeViews::View::ConvertPointToScreen(this, &point); | 634     ChromeViews::View::ConvertPointToScreen(this, &point); | 
| 635     download_util::DownloadShelfContextMenu menu(download_, | 635     download_util::DownloadShelfContextMenu menu(download_, | 
| 636                                                  GetViewContainer()->GetHWND(), | 636                                                  GetViewContainer()->GetHWND(), | 
| 637                                                  model_.get(), | 637                                                  model_.get(), | 
| 638                                                  point); | 638                                                  point.ToPOINT()); | 
| 639     drop_down_pressed_ = false; | 639     drop_down_pressed_ = false; | 
| 640     // Showing the menu blocks. Here we revert the state. | 640     // Showing the menu blocks. Here we revert the state. | 
| 641     SetState(NORMAL, NORMAL); | 641     SetState(NORMAL, NORMAL); | 
| 642   } | 642   } | 
| 643   return true; | 643   return true; | 
| 644 } | 644 } | 
| 645 | 645 | 
| 646 void DownloadItemView::OnMouseMoved(const ChromeViews::MouseEvent& event) { | 646 void DownloadItemView::OnMouseMoved(const ChromeViews::MouseEvent& event) { | 
| 647   // Mouse should not activate us in dangerous mode. | 647   // Mouse should not activate us in dangerous mode. | 
| 648   if (IsDangerousMode()) | 648   if (IsDangerousMode()) | 
| (...skipping 140 matching lines...) Expand 10 before | Expand all | Expand 10 after  Loading... | 
| 789     sp_index = text.find(L" ", sp_index + 1); | 789     sp_index = text.find(L" ", sp_index + 1); | 
| 790   } | 790   } | 
| 791 | 791 | 
| 792   // If we have a line with no space, we won't cut it. | 792   // If we have a line with no space, we won't cut it. | 
| 793   if (min_width == -1) | 793   if (min_width == -1) | 
| 794     dangerous_download_label_->GetPreferredSize(&size); | 794     dangerous_download_label_->GetPreferredSize(&size); | 
| 795 | 795 | 
| 796   dangerous_download_label_->SetBounds(0, 0, size.cx, size.cy); | 796   dangerous_download_label_->SetBounds(0, 0, size.cx, size.cy); | 
| 797   dangerous_download_label_sized_ = true; | 797   dangerous_download_label_sized_ = true; | 
| 798 } | 798 } | 
| OLD | NEW | 
|---|