| 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/views/bookmarks/bookmark_bar_view.h" | 5 #include "chrome/browser/ui/views/bookmarks/bookmark_bar_view.h" |
| 6 | 6 |
| 7 #include <algorithm> | 7 #include <algorithm> |
| 8 #include <limits> | 8 #include <limits> |
| 9 #include <set> | 9 #include <set> |
| 10 #include <vector> | 10 #include <vector> |
| (...skipping 12 matching lines...) Expand all Loading... |
| 23 #include "chrome/browser/sync/sync_ui_util.h" | 23 #include "chrome/browser/sync/sync_ui_util.h" |
| 24 #include "chrome/browser/themes/theme_service.h" | 24 #include "chrome/browser/themes/theme_service.h" |
| 25 #include "chrome/browser/ui/bookmarks/bookmark_tab_helper.h" | 25 #include "chrome/browser/ui/bookmarks/bookmark_tab_helper.h" |
| 26 #include "chrome/browser/ui/browser.h" | 26 #include "chrome/browser/ui/browser.h" |
| 27 #include "chrome/browser/ui/tab_contents/tab_contents_wrapper.h" | 27 #include "chrome/browser/ui/tab_contents/tab_contents_wrapper.h" |
| 28 #include "chrome/browser/ui/view_ids.h" | 28 #include "chrome/browser/ui/view_ids.h" |
| 29 #include "chrome/browser/ui/views/bookmarks/bookmark_context_menu.h" | 29 #include "chrome/browser/ui/views/bookmarks/bookmark_context_menu.h" |
| 30 #include "chrome/browser/ui/views/event_utils.h" | 30 #include "chrome/browser/ui/views/event_utils.h" |
| 31 #include "chrome/browser/ui/views/frame/browser_view.h" | 31 #include "chrome/browser/ui/views/frame/browser_view.h" |
| 32 #include "chrome/browser/ui/views/location_bar/location_bar_view.h" | 32 #include "chrome/browser/ui/views/location_bar/location_bar_view.h" |
| 33 #include "chrome/common/chrome_notification_types.h" |
| 33 #include "chrome/common/chrome_switches.h" | 34 #include "chrome/common/chrome_switches.h" |
| 34 #include "chrome/common/extensions/extension_constants.h" | 35 #include "chrome/common/extensions/extension_constants.h" |
| 35 #include "chrome/common/pref_names.h" | 36 #include "chrome/common/pref_names.h" |
| 36 #include "content/browser/renderer_host/render_view_host.h" | 37 #include "content/browser/renderer_host/render_view_host.h" |
| 37 #include "content/browser/renderer_host/render_widget_host_view.h" | 38 #include "content/browser/renderer_host/render_widget_host_view.h" |
| 38 #include "content/browser/tab_contents/page_navigator.h" | 39 #include "content/browser/tab_contents/page_navigator.h" |
| 39 #include "content/browser/tab_contents/tab_contents.h" | 40 #include "content/browser/tab_contents/tab_contents.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 "content/common/page_transition_types.h" | 43 #include "content/common/page_transition_types.h" |
| (...skipping 370 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 413 profile_ = profile; | 414 profile_ = profile; |
| 414 | 415 |
| 415 if (model_) | 416 if (model_) |
| 416 model_->RemoveObserver(this); | 417 model_->RemoveObserver(this); |
| 417 | 418 |
| 418 // Disable the other bookmarked button, we'll re-enable when the model is | 419 // Disable the other bookmarked button, we'll re-enable when the model is |
| 419 // loaded. | 420 // loaded. |
| 420 other_bookmarked_button_->SetEnabled(false); | 421 other_bookmarked_button_->SetEnabled(false); |
| 421 | 422 |
| 422 Source<Profile> ns_source(profile_->GetOriginalProfile()); | 423 Source<Profile> ns_source(profile_->GetOriginalProfile()); |
| 423 registrar_.Add(this, NotificationType::BOOKMARK_BUBBLE_SHOWN, ns_source); | 424 registrar_.Add(this, chrome::NOTIFICATION_BOOKMARK_BUBBLE_SHOWN, ns_source); |
| 424 registrar_.Add(this, NotificationType::BOOKMARK_BUBBLE_HIDDEN, ns_source); | 425 registrar_.Add(this, chrome::NOTIFICATION_BOOKMARK_BUBBLE_HIDDEN, ns_source); |
| 425 | 426 |
| 426 // Remove any existing bookmark buttons. | 427 // Remove any existing bookmark buttons. |
| 427 while (GetBookmarkButtonCount()) | 428 while (GetBookmarkButtonCount()) |
| 428 delete GetChildViewAt(0); | 429 delete GetChildViewAt(0); |
| 429 | 430 |
| 430 model_ = profile_->GetBookmarkModel(); | 431 model_ = profile_->GetBookmarkModel(); |
| 431 if (model_) { | 432 if (model_) { |
| 432 model_->AddObserver(this); | 433 model_->AddObserver(this); |
| 433 if (model_->IsLoaded()) | 434 if (model_->IsLoaded()) |
| 434 Loaded(model_); | 435 Loaded(model_); |
| (...skipping 695 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 1130 PageNavigator* navigator = | 1131 PageNavigator* navigator = |
| 1131 browser() ? browser()->GetSelectedTabContents() : NULL; | 1132 browser() ? browser()->GetSelectedTabContents() : NULL; |
| 1132 bool close_on_remove = | 1133 bool close_on_remove = |
| 1133 (parent == profile_->GetBookmarkModel()->other_node() && | 1134 (parent == profile_->GetBookmarkModel()->other_node() && |
| 1134 parent->child_count() == 1); | 1135 parent->child_count() == 1); |
| 1135 BookmarkContextMenu controller(GetWidget()->GetNativeWindow(), profile_, | 1136 BookmarkContextMenu controller(GetWidget()->GetNativeWindow(), profile_, |
| 1136 navigator, parent, nodes, close_on_remove); | 1137 navigator, parent, nodes, close_on_remove); |
| 1137 controller.RunMenuAt(p); | 1138 controller.RunMenuAt(p); |
| 1138 } | 1139 } |
| 1139 | 1140 |
| 1140 void BookmarkBarView::Observe(NotificationType type, | 1141 void BookmarkBarView::Observe(int type, |
| 1141 const NotificationSource& source, | 1142 const NotificationSource& source, |
| 1142 const NotificationDetails& details) { | 1143 const NotificationDetails& details) { |
| 1143 DCHECK(profile_); | 1144 DCHECK(profile_); |
| 1144 switch (type.value) { | 1145 switch (type) { |
| 1145 case NotificationType::BOOKMARK_BUBBLE_SHOWN: { | 1146 case chrome::NOTIFICATION_BOOKMARK_BUBBLE_SHOWN: { |
| 1146 StopThrobbing(true); | 1147 StopThrobbing(true); |
| 1147 GURL url = *(Details<GURL>(details).ptr()); | 1148 GURL url = *(Details<GURL>(details).ptr()); |
| 1148 const BookmarkNode* node = model_->GetMostRecentlyAddedNodeForURL(url); | 1149 const BookmarkNode* node = model_->GetMostRecentlyAddedNodeForURL(url); |
| 1149 if (!node) | 1150 if (!node) |
| 1150 return; // Generally shouldn't happen. | 1151 return; // Generally shouldn't happen. |
| 1151 StartThrobbing(node, false); | 1152 StartThrobbing(node, false); |
| 1152 break; | 1153 break; |
| 1153 } | 1154 } |
| 1154 case NotificationType::BOOKMARK_BUBBLE_HIDDEN: | 1155 case chrome::NOTIFICATION_BOOKMARK_BUBBLE_HIDDEN: |
| 1155 StopThrobbing(false); | 1156 StopThrobbing(false); |
| 1156 break; | 1157 break; |
| 1157 | 1158 |
| 1158 default: | 1159 default: |
| 1159 NOTREACHED(); | 1160 NOTREACHED(); |
| 1160 break; | 1161 break; |
| 1161 } | 1162 } |
| 1162 } | 1163 } |
| 1163 | 1164 |
| 1164 void BookmarkBarView::Init() { | 1165 void BookmarkBarView::Init() { |
| (...skipping 581 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 1746 (1 - size_animation_->GetCurrentValue()))); | 1747 (1 - size_animation_->GetCurrentValue()))); |
| 1747 } else { | 1748 } else { |
| 1748 prefsize.set_height( | 1749 prefsize.set_height( |
| 1749 static_cast<int>( | 1750 static_cast<int>( |
| 1750 browser_defaults::kBookmarkBarHeight * | 1751 browser_defaults::kBookmarkBarHeight * |
| 1751 size_animation_->GetCurrentValue())); | 1752 size_animation_->GetCurrentValue())); |
| 1752 } | 1753 } |
| 1753 } | 1754 } |
| 1754 return prefsize; | 1755 return prefsize; |
| 1755 } | 1756 } |
| OLD | NEW |