| 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/bookmarks/bookmark_bar_gtk.h" | 5 #include "chrome/browser/ui/gtk/bookmarks/bookmark_bar_gtk.h" |
| 6 | 6 |
| 7 #include <vector> | 7 #include <vector> |
| 8 | 8 |
| 9 #include "base/metrics/histogram.h" | 9 #include "base/metrics/histogram.h" |
| 10 #include "base/utf_string_conversions.h" | 10 #include "base/utf_string_conversions.h" |
| (...skipping 15 matching lines...) Expand all Loading... |
| 26 #include "chrome/browser/ui/gtk/custom_button.h" | 26 #include "chrome/browser/ui/gtk/custom_button.h" |
| 27 #include "chrome/browser/ui/gtk/gtk_chrome_button.h" | 27 #include "chrome/browser/ui/gtk/gtk_chrome_button.h" |
| 28 #include "chrome/browser/ui/gtk/gtk_theme_service.h" | 28 #include "chrome/browser/ui/gtk/gtk_theme_service.h" |
| 29 #include "chrome/browser/ui/gtk/gtk_util.h" | 29 #include "chrome/browser/ui/gtk/gtk_util.h" |
| 30 #include "chrome/browser/ui/gtk/hover_controller_gtk.h" | 30 #include "chrome/browser/ui/gtk/hover_controller_gtk.h" |
| 31 #include "chrome/browser/ui/gtk/menu_gtk.h" | 31 #include "chrome/browser/ui/gtk/menu_gtk.h" |
| 32 #include "chrome/browser/ui/gtk/rounded_window.h" | 32 #include "chrome/browser/ui/gtk/rounded_window.h" |
| 33 #include "chrome/browser/ui/gtk/tabs/tab_strip_gtk.h" | 33 #include "chrome/browser/ui/gtk/tabs/tab_strip_gtk.h" |
| 34 #include "chrome/browser/ui/gtk/tabstrip_origin_provider.h" | 34 #include "chrome/browser/ui/gtk/tabstrip_origin_provider.h" |
| 35 #include "chrome/browser/ui/gtk/view_id_util.h" | 35 #include "chrome/browser/ui/gtk/view_id_util.h" |
| 36 #include "chrome/common/chrome_notification_types.h" |
| 36 #include "chrome/common/extensions/extension_constants.h" | 37 #include "chrome/common/extensions/extension_constants.h" |
| 37 #include "chrome/common/pref_names.h" | 38 #include "chrome/common/pref_names.h" |
| 38 #include "content/browser/tab_contents/tab_contents.h" | 39 #include "content/browser/tab_contents/tab_contents.h" |
| 39 #include "content/browser/tab_contents/tab_contents_view.h" | 40 #include "content/browser/tab_contents/tab_contents_view.h" |
| 40 #include "content/browser/user_metrics.h" | 41 #include "content/browser/user_metrics.h" |
| 41 #include "content/common/notification_service.h" | 42 #include "content/common/notification_service.h" |
| 42 #include "grit/generated_resources.h" | 43 #include "grit/generated_resources.h" |
| 43 #include "grit/theme_resources.h" | 44 #include "grit/theme_resources.h" |
| 44 #include "grit/ui_resources.h" | 45 #include "grit/ui_resources.h" |
| 45 #include "ui/base/dragdrop/gtk_dnd_util.h" | 46 #include "ui/base/dragdrop/gtk_dnd_util.h" |
| (...skipping 103 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 149 sync_service_->AddObserver(this); | 150 sync_service_->AddObserver(this); |
| 150 } | 151 } |
| 151 | 152 |
| 152 Init(profile); | 153 Init(profile); |
| 153 SetProfile(profile); | 154 SetProfile(profile); |
| 154 // Force an update by simulating being in the wrong state. | 155 // Force an update by simulating being in the wrong state. |
| 155 // BrowserWindowGtk sets our true state after we're created. | 156 // BrowserWindowGtk sets our true state after we're created. |
| 156 SetBookmarkBarState(BookmarkBar::SHOW, | 157 SetBookmarkBarState(BookmarkBar::SHOW, |
| 157 BookmarkBar::DONT_ANIMATE_STATE_CHANGE); | 158 BookmarkBar::DONT_ANIMATE_STATE_CHANGE); |
| 158 | 159 |
| 159 registrar_.Add(this, NotificationType::BROWSER_THEME_CHANGED, | 160 registrar_.Add(this, chrome::NOTIFICATION_BROWSER_THEME_CHANGED, |
| 160 Source<ThemeService>(theme_service_)); | 161 Source<ThemeService>(theme_service_)); |
| 161 | 162 |
| 162 edit_bookmarks_enabled_.Init(prefs::kEditBookmarksEnabled, | 163 edit_bookmarks_enabled_.Init(prefs::kEditBookmarksEnabled, |
| 163 profile_->GetPrefs(), this); | 164 profile_->GetPrefs(), this); |
| 164 OnEditBookmarksEnabledChanged(); | 165 OnEditBookmarksEnabledChanged(); |
| 165 } | 166 } |
| 166 | 167 |
| 167 BookmarkBarGtk::~BookmarkBarGtk() { | 168 BookmarkBarGtk::~BookmarkBarGtk() { |
| 168 RemoveAllBookmarkButtons(); | 169 RemoveAllBookmarkButtons(); |
| 169 bookmark_toolbar_.Destroy(); | 170 bookmark_toolbar_.Destroy(); |
| (...skipping 752 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 922 void BookmarkBarGtk::BookmarkNodeChildrenReordered(BookmarkModel* model, | 923 void BookmarkBarGtk::BookmarkNodeChildrenReordered(BookmarkModel* model, |
| 923 const BookmarkNode* node) { | 924 const BookmarkNode* node) { |
| 924 if (node != model_->GetBookmarkBarNode()) | 925 if (node != model_->GetBookmarkBarNode()) |
| 925 return; // We only care about reordering of the bookmark bar node. | 926 return; // We only care about reordering of the bookmark bar node. |
| 926 | 927 |
| 927 // Purge and rebuild the bar. | 928 // Purge and rebuild the bar. |
| 928 RemoveAllBookmarkButtons(); | 929 RemoveAllBookmarkButtons(); |
| 929 CreateAllBookmarkButtons(); | 930 CreateAllBookmarkButtons(); |
| 930 } | 931 } |
| 931 | 932 |
| 932 void BookmarkBarGtk::Observe(NotificationType type, | 933 void BookmarkBarGtk::Observe(int type, |
| 933 const NotificationSource& source, | 934 const NotificationSource& source, |
| 934 const NotificationDetails& details) { | 935 const NotificationDetails& details) { |
| 935 if (type == NotificationType::BROWSER_THEME_CHANGED) { | 936 if (type == chrome::NOTIFICATION_BROWSER_THEME_CHANGED) { |
| 936 if (model_ && model_->IsLoaded()) { | 937 if (model_ && model_->IsLoaded()) { |
| 937 // Regenerate the bookmark bar with all new objects with their theme | 938 // Regenerate the bookmark bar with all new objects with their theme |
| 938 // properties set correctly for the new theme. | 939 // properties set correctly for the new theme. |
| 939 RemoveAllBookmarkButtons(); | 940 RemoveAllBookmarkButtons(); |
| 940 CreateAllBookmarkButtons(); | 941 CreateAllBookmarkButtons(); |
| 941 } | 942 } |
| 942 | 943 |
| 943 UpdateEventBoxPaintability(); | 944 UpdateEventBoxPaintability(); |
| 944 | 945 |
| 945 GdkColor paint_box_color = | 946 GdkColor paint_box_color = |
| 946 theme_service_->GetGdkColor(ThemeService::COLOR_TOOLBAR); | 947 theme_service_->GetGdkColor(ThemeService::COLOR_TOOLBAR); |
| 947 gtk_widget_modify_bg(paint_box_, GTK_STATE_NORMAL, &paint_box_color); | 948 gtk_widget_modify_bg(paint_box_, GTK_STATE_NORMAL, &paint_box_color); |
| 948 | 949 |
| 949 if (bookmark_bar_state_ == BookmarkBar::DETACHED) { | 950 if (bookmark_bar_state_ == BookmarkBar::DETACHED) { |
| 950 GdkColor stroke_color = theme_service_->UsingNativeTheme() ? | 951 GdkColor stroke_color = theme_service_->UsingNativeTheme() ? |
| 951 theme_service_->GetBorderColor() : | 952 theme_service_->GetBorderColor() : |
| 952 theme_service_->GetGdkColor(ThemeService::COLOR_NTP_HEADER); | 953 theme_service_->GetGdkColor(ThemeService::COLOR_NTP_HEADER); |
| 953 gtk_util::SetRoundedWindowBorderColor(paint_box_, stroke_color); | 954 gtk_util::SetRoundedWindowBorderColor(paint_box_, stroke_color); |
| 954 } | 955 } |
| 955 | 956 |
| 956 SetOverflowButtonAppearance(); | 957 SetOverflowButtonAppearance(); |
| 957 } else if (type == NotificationType::PREF_CHANGED) { | 958 } else if (type == chrome::NOTIFICATION_PREF_CHANGED) { |
| 958 const std::string& pref_name = *Details<std::string>(details).ptr(); | 959 const std::string& pref_name = *Details<std::string>(details).ptr(); |
| 959 if (pref_name == prefs::kEditBookmarksEnabled) | 960 if (pref_name == prefs::kEditBookmarksEnabled) |
| 960 OnEditBookmarksEnabledChanged(); | 961 OnEditBookmarksEnabledChanged(); |
| 961 } | 962 } |
| 962 } | 963 } |
| 963 | 964 |
| 964 GtkWidget* BookmarkBarGtk::CreateBookmarkButton(const BookmarkNode* node) { | 965 GtkWidget* BookmarkBarGtk::CreateBookmarkButton(const BookmarkNode* node) { |
| 965 GtkWidget* button = theme_service_->BuildChromeButton(); | 966 GtkWidget* button = theme_service_->BuildChromeButton(); |
| 966 bookmark_utils::ConfigureButtonForNode(node, model_, button, theme_service_); | 967 bookmark_utils::ConfigureButtonForNode(node, model_, button, theme_service_); |
| 967 | 968 |
| (...skipping 476 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 1444 void BookmarkBarGtk::OnEditBookmarksEnabledChanged() { | 1445 void BookmarkBarGtk::OnEditBookmarksEnabledChanged() { |
| 1445 GtkDestDefaults dest_defaults = | 1446 GtkDestDefaults dest_defaults = |
| 1446 *edit_bookmarks_enabled_ ? GTK_DEST_DEFAULT_ALL : | 1447 *edit_bookmarks_enabled_ ? GTK_DEST_DEFAULT_ALL : |
| 1447 GTK_DEST_DEFAULT_DROP; | 1448 GTK_DEST_DEFAULT_DROP; |
| 1448 gtk_drag_dest_set(overflow_button_, dest_defaults, NULL, 0, kDragAction); | 1449 gtk_drag_dest_set(overflow_button_, dest_defaults, NULL, 0, kDragAction); |
| 1449 gtk_drag_dest_set(other_bookmarks_button_, dest_defaults, | 1450 gtk_drag_dest_set(other_bookmarks_button_, dest_defaults, |
| 1450 NULL, 0, kDragAction); | 1451 NULL, 0, kDragAction); |
| 1451 ui::SetDestTargetList(overflow_button_, kDestTargetList); | 1452 ui::SetDestTargetList(overflow_button_, kDestTargetList); |
| 1452 ui::SetDestTargetList(other_bookmarks_button_, kDestTargetList); | 1453 ui::SetDestTargetList(other_bookmarks_button_, kDestTargetList); |
| 1453 } | 1454 } |
| OLD | NEW |