| OLD | NEW |
| 1 // Copyright (c) 2010 The Chromium Authors. All rights reserved. | 1 // Copyright (c) 2010 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 "app/l10n_util.h" | 9 #include "app/l10n_util.h" |
| 10 #include "app/resource_bundle.h" | 10 #include "app/resource_bundle.h" |
| (...skipping 114 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 125 drop_down_pressed_(false), | 125 drop_down_pressed_(false), |
| 126 dragging_(false), | 126 dragging_(false), |
| 127 starting_drag_(false), | 127 starting_drag_(false), |
| 128 model_(model), | 128 model_(model), |
| 129 save_button_(NULL), | 129 save_button_(NULL), |
| 130 discard_button_(NULL), | 130 discard_button_(NULL), |
| 131 dangerous_download_label_(NULL), | 131 dangerous_download_label_(NULL), |
| 132 dangerous_download_label_sized_(false), | 132 dangerous_download_label_sized_(false), |
| 133 disabled_while_opening_(false), | 133 disabled_while_opening_(false), |
| 134 creation_time_(base::Time::Now()), | 134 creation_time_(base::Time::Now()), |
| 135 ALLOW_THIS_IN_INITIALIZER_LIST(reenable_method_factory_(this)) { | 135 ALLOW_THIS_IN_INITIALIZER_LIST(reenable_method_factory_(this)), |
| 136 deleted_(NULL) { |
| 136 DCHECK(download_); | 137 DCHECK(download_); |
| 137 download_->AddObserver(this); | 138 download_->AddObserver(this); |
| 138 | 139 |
| 139 ResourceBundle &rb = ResourceBundle::GetSharedInstance(); | 140 ResourceBundle &rb = ResourceBundle::GetSharedInstance(); |
| 140 | 141 |
| 141 BodyImageSet normal_body_image_set = { | 142 BodyImageSet normal_body_image_set = { |
| 142 rb.GetBitmapNamed(IDR_DOWNLOAD_BUTTON_LEFT_TOP), | 143 rb.GetBitmapNamed(IDR_DOWNLOAD_BUTTON_LEFT_TOP), |
| 143 rb.GetBitmapNamed(IDR_DOWNLOAD_BUTTON_LEFT_MIDDLE), | 144 rb.GetBitmapNamed(IDR_DOWNLOAD_BUTTON_LEFT_MIDDLE), |
| 144 rb.GetBitmapNamed(IDR_DOWNLOAD_BUTTON_LEFT_BOTTOM), | 145 rb.GetBitmapNamed(IDR_DOWNLOAD_BUTTON_LEFT_BOTTOM), |
| 145 rb.GetBitmapNamed(IDR_DOWNLOAD_BUTTON_CENTER_TOP), | 146 rb.GetBitmapNamed(IDR_DOWNLOAD_BUTTON_CENTER_TOP), |
| (...skipping 158 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 304 StartDownloadProgress(); | 305 StartDownloadProgress(); |
| 305 } | 306 } |
| 306 | 307 |
| 307 DownloadItemView::~DownloadItemView() { | 308 DownloadItemView::~DownloadItemView() { |
| 308 if (context_menu_.get()) { | 309 if (context_menu_.get()) { |
| 309 context_menu_->Stop(); | 310 context_menu_->Stop(); |
| 310 } | 311 } |
| 311 icon_consumer_.CancelAllRequests(); | 312 icon_consumer_.CancelAllRequests(); |
| 312 StopDownloadProgress(); | 313 StopDownloadProgress(); |
| 313 download_->RemoveObserver(this); | 314 download_->RemoveObserver(this); |
| 315 if (deleted_) |
| 316 *deleted_ = true; |
| 314 } | 317 } |
| 315 | 318 |
| 316 // Progress animation handlers. | 319 // Progress animation handlers. |
| 317 | 320 |
| 318 void DownloadItemView::UpdateDownloadProgress() { | 321 void DownloadItemView::UpdateDownloadProgress() { |
| 319 progress_angle_ = (progress_angle_ + | 322 progress_angle_ = (progress_angle_ + |
| 320 download_util::kUnknownIncrementDegrees) % | 323 download_util::kUnknownIncrementDegrees) % |
| 321 download_util::kMaxDegrees; | 324 download_util::kMaxDegrees; |
| 322 SchedulePaint(); | 325 SchedulePaint(); |
| 323 } | 326 } |
| (...skipping 488 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 812 point.set_y(height()); | 815 point.set_y(height()); |
| 813 if (base::i18n::IsRTL()) | 816 if (base::i18n::IsRTL()) |
| 814 point.set_x(drop_down_x_right_); | 817 point.set_x(drop_down_x_right_); |
| 815 else | 818 else |
| 816 point.set_x(drop_down_x_left_); | 819 point.set_x(drop_down_x_left_); |
| 817 | 820 |
| 818 views::View::ConvertPointToScreen(this, &point); | 821 views::View::ConvertPointToScreen(this, &point); |
| 819 | 822 |
| 820 if (!context_menu_.get()) | 823 if (!context_menu_.get()) |
| 821 context_menu_.reset(new DownloadShelfContextMenuWin(model_.get())); | 824 context_menu_.reset(new DownloadShelfContextMenuWin(model_.get())); |
| 825 // When we call the Run method on the menu, it runs an inner message loop |
| 826 // that might causes us to be deleted. |
| 827 bool deleted = false; |
| 828 deleted_ = &deleted; |
| 822 context_menu_->Run(point); | 829 context_menu_->Run(point); |
| 830 if (deleted) |
| 831 return true; // We have been deleted! Don't access 'this'. |
| 832 deleted_ = NULL; |
| 823 | 833 |
| 824 // If the menu action was to remove the download, this view will also be | 834 // If the menu action was to remove the download, this view will also be |
| 825 // invalid so we must not access 'this' in this case. | 835 // invalid so we must not access 'this' in this case. |
| 826 if (context_menu_->download()) { | 836 if (context_menu_->download()) { |
| 827 drop_down_pressed_ = false; | 837 drop_down_pressed_ = false; |
| 828 // Showing the menu blocks. Here we revert the state. | 838 // Showing the menu blocks. Here we revert the state. |
| 829 SetState(NORMAL, NORMAL); | 839 SetState(NORMAL, NORMAL); |
| 830 } | 840 } |
| 831 } | 841 } |
| 832 return true; | 842 return true; |
| (...skipping 174 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 1007 void DownloadItemView::Reenable() { | 1017 void DownloadItemView::Reenable() { |
| 1008 disabled_while_opening_ = false; | 1018 disabled_while_opening_ = false; |
| 1009 SetEnabled(true); // Triggers a repaint. | 1019 SetEnabled(true); // Triggers a repaint. |
| 1010 } | 1020 } |
| 1011 | 1021 |
| 1012 bool DownloadItemView::InDropDownButtonXCoordinateRange(int x) { | 1022 bool DownloadItemView::InDropDownButtonXCoordinateRange(int x) { |
| 1013 if (x > drop_down_x_left_ && x < drop_down_x_right_) | 1023 if (x > drop_down_x_left_ && x < drop_down_x_right_) |
| 1014 return true; | 1024 return true; |
| 1015 return false; | 1025 return false; |
| 1016 } | 1026 } |
| OLD | NEW |