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

Side by Side Diff: chrome/browser/gtk/download_item_gtk.cc

Issue 124001: Linux: fix icon theme double free on shutdown.... (Closed) Base URL: svn://chrome-svn/chrome/trunk/src/
Patch Set: '' Created 11 years, 6 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
« no previous file with comments | « chrome/browser/gtk/download_item_gtk.h ('k') | no next file » | no next file with comments »
Toggle Intra-line Diffs ('i') | Expand Comments ('e') | Collapse Comments ('c') | Show Comments Hide Comments ('s')
OLDNEW
1 // Copyright (c) 2009 The Chromium Authors. All rights reserved. 1 // Copyright (c) 2009 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/gtk/download_item_gtk.h" 5 #include "chrome/browser/gtk/download_item_gtk.h"
6 6
7 #include "app/l10n_util.h" 7 #include "app/l10n_util.h"
8 #include "app/gfx/canvas.h" 8 #include "app/gfx/canvas.h"
9 #include "app/gfx/font.h" 9 #include "app/gfx/font.h"
10 #include "app/gfx/text_elider.h" 10 #include "app/gfx/text_elider.h"
(...skipping 232 matching lines...) Expand 10 before | Expand all | Expand 10 after
243 reinterpret_cast<void*>(true)); 243 reinterpret_cast<void*>(true));
244 gtk_widget_set_size_request(menu_button_, kMenuButtonWidth, 0); 244 gtk_widget_set_size_request(menu_button_, kMenuButtonWidth, 0);
245 245
246 GtkWidget* shelf_hbox = parent_shelf->GetHBox(); 246 GtkWidget* shelf_hbox = parent_shelf->GetHBox();
247 hbox_.Own(gtk_hbox_new(FALSE, 0)); 247 hbox_.Own(gtk_hbox_new(FALSE, 0));
248 gtk_box_pack_start(GTK_BOX(hbox_.get()), body_.get(), FALSE, FALSE, 0); 248 gtk_box_pack_start(GTK_BOX(hbox_.get()), body_.get(), FALSE, FALSE, 0);
249 gtk_box_pack_start(GTK_BOX(hbox_.get()), menu_button_, FALSE, FALSE, 0); 249 gtk_box_pack_start(GTK_BOX(hbox_.get()), menu_button_, FALSE, FALSE, 0);
250 gtk_box_pack_start(GTK_BOX(shelf_hbox), hbox_.get(), FALSE, FALSE, 0); 250 gtk_box_pack_start(GTK_BOX(shelf_hbox), hbox_.get(), FALSE, FALSE, 0);
251 // Insert as the leftmost item. 251 // Insert as the leftmost item.
252 gtk_box_reorder_child(GTK_BOX(shelf_hbox), hbox_.get(), 1); 252 gtk_box_reorder_child(GTK_BOX(shelf_hbox), hbox_.get(), 1);
253 253 g_signal_connect(G_OBJECT(shelf_hbox), "size-allocate",
254 resize_handler_id_ = g_signal_connect(G_OBJECT(shelf_hbox), "size-allocate", 254 G_CALLBACK(OnShelfResized), this);
255 G_CALLBACK(OnShelfResized), this);
256 255
257 get_download()->AddObserver(this); 256 get_download()->AddObserver(this);
258 257
259 new_item_animation_.reset(new SlideAnimation(this)); 258 new_item_animation_.reset(new SlideAnimation(this));
260 new_item_animation_->SetSlideDuration(kNewItemAnimationDurationMs); 259 new_item_animation_->SetSlideDuration(kNewItemAnimationDurationMs);
261 gtk_widget_show_all(hbox_.get()); 260 gtk_widget_show_all(hbox_.get());
262 261
263 if (IsDangerous()) { 262 if (IsDangerous()) {
264 // Hide the download item components for now. 263 // Hide the download item components for now.
265 gtk_widget_hide(body_.get()); 264 gtk_widget_hide(body_.get());
(...skipping 73 matching lines...) Expand 10 before | Expand all | Expand 10 after
339 gtk_widget_size_request(dangerous_label, &req); 338 gtk_widget_size_request(dangerous_label, &req);
340 dangerous_hbox_start_width_ = dangerous_hbox_full_width_ - req.width; 339 dangerous_hbox_start_width_ = dangerous_hbox_full_width_ - req.width;
341 } 340 }
342 341
343 new_item_animation_->Show(); 342 new_item_animation_->Show();
344 } 343 }
345 344
346 DownloadItemGtk::~DownloadItemGtk() { 345 DownloadItemGtk::~DownloadItemGtk() {
347 StopDownloadProgress(); 346 StopDownloadProgress();
348 get_download()->RemoveObserver(this); 347 get_download()->RemoveObserver(this);
348 g_signal_handlers_disconnect_by_func(parent_shelf_->GetHBox(),
349 reinterpret_cast<gpointer>(OnShelfResized), this);
349 350
350 hbox_.Destroy(); 351 hbox_.Destroy();
351 progress_area_.Destroy(); 352 progress_area_.Destroy();
352 body_.Destroy(); 353 body_.Destroy();
353 } 354 }
354 355
355 void DownloadItemGtk::OnDownloadUpdated(DownloadItem* download) { 356 void DownloadItemGtk::OnDownloadUpdated(DownloadItem* download) {
356 DCHECK_EQ(download, get_download()); 357 DCHECK_EQ(download, get_download());
357 358
358 if (dangerous_prompt_ != NULL && 359 if (dangerous_prompt_ != NULL &&
359 download->safety_state() == DownloadItem::DANGEROUS_BUT_VALIDATED) { 360 download->safety_state() == DownloadItem::DANGEROUS_BUT_VALIDATED) {
360 // We have been approved. 361 // We have been approved.
361 gtk_widget_show_all(hbox_.get()); 362 gtk_widget_show_all(hbox_.get());
362 gtk_widget_destroy(dangerous_prompt_); 363 gtk_widget_destroy(dangerous_prompt_);
363 dangerous_prompt_ = NULL; 364 dangerous_prompt_ = NULL;
364 } 365 }
365 366
366 switch (download->state()) { 367 switch (download->state()) {
367 case DownloadItem::REMOVING: 368 case DownloadItem::REMOVING:
368 // We disconnect here rather than the d'tor because we don't want to
369 // explicitly disconnect if |parent_shelf_| has been destroyed.
370 g_signal_handler_disconnect(parent_shelf_->GetHBox(), resize_handler_id_);
371 parent_shelf_->RemoveDownloadItem(this); // This will delete us! 369 parent_shelf_->RemoveDownloadItem(this); // This will delete us!
372 return; 370 return;
373 case DownloadItem::CANCELLED: 371 case DownloadItem::CANCELLED:
374 StopDownloadProgress(); 372 StopDownloadProgress();
375 break; 373 break;
376 case DownloadItem::COMPLETE: 374 case DownloadItem::COMPLETE:
377 StopDownloadProgress(); 375 StopDownloadProgress();
378 complete_animation_.reset(new SlideAnimation(this)); 376 complete_animation_.reset(new SlideAnimation(this));
379 complete_animation_->SetSlideDuration(kCompleteAnimationDurationMs); 377 complete_animation_->SetSlideDuration(kCompleteAnimationDurationMs);
380 complete_animation_->SetTweenType(SlideAnimation::NONE); 378 complete_animation_->SetTweenType(SlideAnimation::NONE);
(...skipping 285 matching lines...) Expand 10 before | Expand all | Expand 10 after
666 item->get_download()); 664 item->get_download());
667 } 665 }
668 666
669 // static 667 // static
670 void DownloadItemGtk::OnDangerousDecline(GtkWidget* button, 668 void DownloadItemGtk::OnDangerousDecline(GtkWidget* button,
671 DownloadItemGtk* item) { 669 DownloadItemGtk* item) {
672 if (item->get_download()->state() == DownloadItem::IN_PROGRESS) 670 if (item->get_download()->state() == DownloadItem::IN_PROGRESS)
673 item->get_download()->Cancel(true); 671 item->get_download()->Cancel(true);
674 item->get_download()->Remove(true); 672 item->get_download()->Remove(true);
675 } 673 }
OLDNEW
« no previous file with comments | « chrome/browser/gtk/download_item_gtk.h ('k') | no next file » | no next file with comments »

Powered by Google App Engine
This is Rietveld 408576698