Chromium Code Reviews
chromiumcodereview-hr@appspot.gserviceaccount.com (chromiumcodereview-hr) | Please choose your nickname with Settings | Help | Chromium Project | Gerrit Changes | Sign out
(118)

Side by Side Diff: chrome/browser/ui/gtk/download/download_shelf_gtk.cc

Issue 12995025: [Mac] DownloadShelf should be notified when autoclosing. (Closed) Base URL: svn://svn.chromium.org/chrome/trunk/src
Patch Set: + NSTrackingInVisibleRect Created 7 years, 8 months ago
Use n/p to move between diff chunks; N/P to move between comments. Draft comments are only viewable by you.
Jump to:
View unified diff | Download patch | Annotate | Revision Log
OLDNEW
1 // Copyright (c) 2012 The Chromium Authors. All rights reserved. 1 // Copyright (c) 2012 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/ui/gtk/download/download_shelf_gtk.h" 5 #include "chrome/browser/ui/gtk/download/download_shelf_gtk.h"
6 6
7 #include <string> 7 #include <string>
8 8
9 #include "base/bind.h" 9 #include "base/bind.h"
10 #include "chrome/browser/download/download_item_model.h" 10 #include "chrome/browser/download/download_item_model.h"
(...skipping 180 matching lines...) Expand 10 before | Expand all | Expand 10 after
191 bool DownloadShelfGtk::IsClosing() const { 191 bool DownloadShelfGtk::IsClosing() const {
192 return slide_widget_->IsClosing(); 192 return slide_widget_->IsClosing();
193 } 193 }
194 194
195 void DownloadShelfGtk::DoShow() { 195 void DownloadShelfGtk::DoShow() {
196 slide_widget_->Open(); 196 slide_widget_->Open();
197 browser_->UpdateDownloadShelfVisibility(true); 197 browser_->UpdateDownloadShelfVisibility(true);
198 CancelAutoClose(); 198 CancelAutoClose();
199 } 199 }
200 200
201 void DownloadShelfGtk::DoClose() { 201 void DownloadShelfGtk::DoClose(CloseReason reason) {
202 // When we are closing, we can vertically overlap the render view. Make sure 202 // When we are closing, we can vertically overlap the render view. Make sure
203 // we are on top. 203 // we are on top.
204 gdk_window_raise(gtk_widget_get_window(shelf_.get())); 204 gdk_window_raise(gtk_widget_get_window(shelf_.get()));
205 slide_widget_->Close(); 205 slide_widget_->Close();
206 browser_->UpdateDownloadShelfVisibility(false); 206 browser_->UpdateDownloadShelfVisibility(false);
207 int num_in_progress = 0; 207 int num_in_progress = 0;
208 for (size_t i = 0; i < download_items_.size(); ++i) { 208 for (size_t i = 0; i < download_items_.size(); ++i) {
209 if (download_items_[i]->download()->IsInProgress()) 209 if (download_items_[i]->download()->IsInProgress())
210 ++num_in_progress; 210 ++num_in_progress;
211 } 211 }
212 download_util::RecordShelfClose( 212 download_util::RecordShelfClose(
213 download_items_.size(), num_in_progress, close_on_mouse_out_); 213 download_items_.size(), num_in_progress, reason == AUTOMATIC);
214 SetCloseOnMouseOut(false); 214 SetCloseOnMouseOut(false);
215 } 215 }
216 216
217 Browser* DownloadShelfGtk::browser() const { 217 Browser* DownloadShelfGtk::browser() const {
218 return browser_; 218 return browser_;
219 } 219 }
220 220
221 void DownloadShelfGtk::Closed() { 221 void DownloadShelfGtk::Closed() {
222 // Don't remove completed downloads if the shelf is just being auto-hidden 222 // Don't remove completed downloads if the shelf is just being auto-hidden
223 // rather than explicitly closed by the user. 223 // rather than explicitly closed by the user.
(...skipping 75 matching lines...) Expand 10 before | Expand all | Expand 10 after
299 } 299 }
300 300
301 void DownloadShelfGtk::MaybeShowMoreDownloadItems() { 301 void DownloadShelfGtk::MaybeShowMoreDownloadItems() {
302 // Show all existing download items. It'll trigger "size-allocate" signal, 302 // Show all existing download items. It'll trigger "size-allocate" signal,
303 // which will hide download items that don't have enough space to show. 303 // which will hide download items that don't have enough space to show.
304 gtk_widget_show_all(items_hbox_.get()); 304 gtk_widget_show_all(items_hbox_.get());
305 } 305 }
306 306
307 void DownloadShelfGtk::OnButtonClick(GtkWidget* button) { 307 void DownloadShelfGtk::OnButtonClick(GtkWidget* button) {
308 if (button == close_button_->widget()) { 308 if (button == close_button_->widget()) {
309 Close(); 309 Close(USER_ACTION);
310 } else { 310 } else {
311 // The link button was clicked. 311 // The link button was clicked.
312 chrome::ShowDownloads(browser_); 312 chrome::ShowDownloads(browser_);
313 } 313 }
314 } 314 }
315 315
316 void DownloadShelfGtk::AutoCloseIfPossible() { 316 void DownloadShelfGtk::AutoCloseIfPossible() {
317 for (std::vector<DownloadItemGtk*>::iterator iter = download_items_.begin(); 317 for (std::vector<DownloadItemGtk*>::iterator iter = download_items_.begin();
318 iter != download_items_.end(); ++iter) { 318 iter != download_items_.end(); ++iter) {
319 if (!(*iter)->download()->GetOpened()) 319 if (!(*iter)->download()->GetOpened())
(...skipping 69 matching lines...) Expand 10 before | Expand all | Expand 10 after
389 bounds.Inset(gfx::Insets(-kShelfAuraSize, 0, 0, 0)); 389 bounds.Inset(gfx::Insets(-kShelfAuraSize, 0, 0, 0));
390 390
391 return bounds.Contains(cursor_screen_coords); 391 return bounds.Contains(cursor_screen_coords);
392 } 392 }
393 393
394 void DownloadShelfGtk::MouseLeftShelf() { 394 void DownloadShelfGtk::MouseLeftShelf() {
395 DCHECK(close_on_mouse_out_); 395 DCHECK(close_on_mouse_out_);
396 396
397 MessageLoop::current()->PostDelayedTask( 397 MessageLoop::current()->PostDelayedTask(
398 FROM_HERE, 398 FROM_HERE,
399 base::Bind(&DownloadShelfGtk::Close, weak_factory_.GetWeakPtr()), 399 base::Bind(&DownloadShelfGtk::Close, weak_factory_.GetWeakPtr(),
400 AUTOMATIC),
400 base::TimeDelta::FromMilliseconds(kAutoCloseDelayMs)); 401 base::TimeDelta::FromMilliseconds(kAutoCloseDelayMs));
401 } 402 }
402 403
403 void DownloadShelfGtk::MouseEnteredShelf() { 404 void DownloadShelfGtk::MouseEnteredShelf() {
404 weak_factory_.InvalidateWeakPtrs(); 405 weak_factory_.InvalidateWeakPtrs();
405 } 406 }
OLDNEW
« no previous file with comments | « chrome/browser/ui/gtk/download/download_shelf_gtk.h ('k') | chrome/browser/ui/views/download/download_shelf_view.h » ('j') | no next file with comments »

Powered by Google App Engine
This is Rietveld 408576698