| OLD | NEW | 
|---|
| 1 // Copyright (c) 2011 The Chromium Authors. All rights reserved. | 1 // Copyright (c) 2011 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 "chrome/browser/download/download_item.h" | 9 #include "chrome/browser/download/download_item.h" | 
| 10 #include "chrome/browser/download/download_item_model.h" | 10 #include "chrome/browser/download/download_item_model.h" | 
| 11 #include "chrome/browser/download/download_util.h" | 11 #include "chrome/browser/download/download_util.h" | 
| 12 #include "chrome/browser/ui/browser.h" | 12 #include "chrome/browser/ui/browser.h" | 
| 13 #include "chrome/browser/ui/gtk/browser_window_gtk.h" | 13 #include "chrome/browser/ui/gtk/browser_window_gtk.h" | 
| 14 #include "chrome/browser/ui/gtk/custom_button.h" | 14 #include "chrome/browser/ui/gtk/custom_button.h" | 
| 15 #include "chrome/browser/ui/gtk/download/download_item_gtk.h" | 15 #include "chrome/browser/ui/gtk/download/download_item_gtk.h" | 
| 16 #include "chrome/browser/ui/gtk/gtk_chrome_link_button.h" | 16 #include "chrome/browser/ui/gtk/gtk_chrome_link_button.h" | 
| 17 #include "chrome/browser/ui/gtk/gtk_chrome_shrinkable_hbox.h" | 17 #include "chrome/browser/ui/gtk/gtk_chrome_shrinkable_hbox.h" | 
| 18 #include "chrome/browser/ui/gtk/gtk_theme_service.h" | 18 #include "chrome/browser/ui/gtk/gtk_theme_service.h" | 
| 19 #include "chrome/browser/ui/gtk/gtk_util.h" | 19 #include "chrome/browser/ui/gtk/gtk_util.h" | 
|  | 20 #include "chrome/common/chrome_notification_types.h" | 
| 20 #include "content/common/notification_service.h" | 21 #include "content/common/notification_service.h" | 
| 21 #include "grit/generated_resources.h" | 22 #include "grit/generated_resources.h" | 
| 22 #include "grit/theme_resources.h" | 23 #include "grit/theme_resources.h" | 
| 23 #include "grit/theme_resources_standard.h" | 24 #include "grit/theme_resources_standard.h" | 
| 24 #include "ui/base/l10n/l10n_util.h" | 25 #include "ui/base/l10n/l10n_util.h" | 
| 25 #include "ui/base/resource/resource_bundle.h" | 26 #include "ui/base/resource/resource_bundle.h" | 
| 26 #include "ui/gfx/gtk_util.h" | 27 #include "ui/gfx/gtk_util.h" | 
| 27 #include "ui/gfx/image/image.h" | 28 #include "ui/gfx/image/image.h" | 
| 28 #include "ui/gfx/insets.h" | 29 #include "ui/gfx/insets.h" | 
| 29 #include "ui/gfx/point.h" | 30 #include "ui/gfx/point.h" | 
| (...skipping 105 matching lines...) Expand 10 before | Expand all | Expand 10 after  Loading... | 
| 135   // Pack the link and the icon in outer hbox. | 136   // Pack the link and the icon in outer hbox. | 
| 136   gtk_util::CenterWidgetInHBox(outer_hbox, link_button_, true, 0); | 137   gtk_util::CenterWidgetInHBox(outer_hbox, link_button_, true, 0); | 
| 137   gtk_util::CenterWidgetInHBox(outer_hbox, download_image, true, 0); | 138   gtk_util::CenterWidgetInHBox(outer_hbox, download_image, true, 0); | 
| 138 | 139 | 
| 139   slide_widget_.reset(new SlideAnimatorGtk(shelf_.get(), | 140   slide_widget_.reset(new SlideAnimatorGtk(shelf_.get(), | 
| 140                                            SlideAnimatorGtk::UP, | 141                                            SlideAnimatorGtk::UP, | 
| 141                                            kShelfAnimationDurationMs, | 142                                            kShelfAnimationDurationMs, | 
| 142                                            false, true, this)); | 143                                            false, true, this)); | 
| 143 | 144 | 
| 144   theme_service_->InitThemesFor(this); | 145   theme_service_->InitThemesFor(this); | 
| 145   registrar_.Add(this, NotificationType::BROWSER_THEME_CHANGED, | 146   registrar_.Add(this, chrome::NOTIFICATION_BROWSER_THEME_CHANGED, | 
| 146                  Source<ThemeService>(theme_service_)); | 147                  Source<ThemeService>(theme_service_)); | 
| 147 | 148 | 
| 148   gtk_widget_show_all(shelf_.get()); | 149   gtk_widget_show_all(shelf_.get()); | 
| 149 | 150 | 
| 150   // Stick ourselves at the bottom of the parent browser. | 151   // Stick ourselves at the bottom of the parent browser. | 
| 151   gtk_box_pack_end(GTK_BOX(parent), slide_widget_->widget(), | 152   gtk_box_pack_end(GTK_BOX(parent), slide_widget_->widget(), | 
| 152                    FALSE, FALSE, 0); | 153                    FALSE, FALSE, 0); | 
| 153   // Make sure we are at the very end. | 154   // Make sure we are at the very end. | 
| 154   gtk_box_reorder_child(GTK_BOX(parent), slide_widget_->widget(), 0); | 155   gtk_box_reorder_child(GTK_BOX(parent), slide_widget_->widget(), 0); | 
| 155   Show(); | 156   Show(); | 
| (...skipping 57 matching lines...) Expand 10 before | Expand all | Expand 10 after  Loading... | 
| 213       RemoveDownloadItem(download_items_[i]); | 214       RemoveDownloadItem(download_items_[i]); | 
| 214     } else { | 215     } else { | 
| 215       // We set all remaining items as "opened", so that the shelf will auto- | 216       // We set all remaining items as "opened", so that the shelf will auto- | 
| 216       // close in the future without the user clicking on them. | 217       // close in the future without the user clicking on them. | 
| 217       download->set_opened(true); | 218       download->set_opened(true); | 
| 218       ++i; | 219       ++i; | 
| 219     } | 220     } | 
| 220   } | 221   } | 
| 221 } | 222 } | 
| 222 | 223 | 
| 223 void DownloadShelfGtk::Observe(NotificationType type, | 224 void DownloadShelfGtk::Observe(int type, | 
| 224                                const NotificationSource& source, | 225                                const NotificationSource& source, | 
| 225                                const NotificationDetails& details) { | 226                                const NotificationDetails& details) { | 
| 226   if (type == NotificationType::BROWSER_THEME_CHANGED) { | 227   if (type == chrome::NOTIFICATION_BROWSER_THEME_CHANGED) { | 
| 227     GdkColor color = theme_service_->GetGdkColor( | 228     GdkColor color = theme_service_->GetGdkColor( | 
| 228         ThemeService::COLOR_TOOLBAR); | 229         ThemeService::COLOR_TOOLBAR); | 
| 229     gtk_widget_modify_bg(padding_bg_, GTK_STATE_NORMAL, &color); | 230     gtk_widget_modify_bg(padding_bg_, GTK_STATE_NORMAL, &color); | 
| 230 | 231 | 
| 231     color = theme_service_->GetBorderColor(); | 232     color = theme_service_->GetBorderColor(); | 
| 232     gtk_widget_modify_bg(top_border_, GTK_STATE_NORMAL, &color); | 233     gtk_widget_modify_bg(top_border_, GTK_STATE_NORMAL, &color); | 
| 233 | 234 | 
| 234     // When using a non-standard, non-gtk theme, we make the link color match | 235     // When using a non-standard, non-gtk theme, we make the link color match | 
| 235     // the bookmark text color. Otherwise, standard link blue can look very | 236     // the bookmark text color. Otherwise, standard link blue can look very | 
| 236     // bad for some dark themes. | 237     // bad for some dark themes. | 
| (...skipping 131 matching lines...) Expand 10 before | Expand all | Expand 10 after  Loading... | 
| 368 | 369 | 
| 369   MessageLoop::current()->PostDelayedTask( | 370   MessageLoop::current()->PostDelayedTask( | 
| 370       FROM_HERE, | 371       FROM_HERE, | 
| 371       auto_close_factory_.NewRunnableMethod(&DownloadShelfGtk::Close), | 372       auto_close_factory_.NewRunnableMethod(&DownloadShelfGtk::Close), | 
| 372       kAutoCloseDelayMs); | 373       kAutoCloseDelayMs); | 
| 373 } | 374 } | 
| 374 | 375 | 
| 375 void DownloadShelfGtk::MouseEnteredShelf() { | 376 void DownloadShelfGtk::MouseEnteredShelf() { | 
| 376   auto_close_factory_.RevokeAll(); | 377   auto_close_factory_.RevokeAll(); | 
| 377 } | 378 } | 
| OLD | NEW | 
|---|