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 378 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
421 profile_ = profile; | 422 profile_ = profile; |
422 | 423 |
423 if (model_) | 424 if (model_) |
424 model_->RemoveObserver(this); | 425 model_->RemoveObserver(this); |
425 | 426 |
426 // Disable the other bookmarked button, we'll re-enable when the model is | 427 // Disable the other bookmarked button, we'll re-enable when the model is |
427 // loaded. | 428 // loaded. |
428 other_bookmarked_button_->SetEnabled(false); | 429 other_bookmarked_button_->SetEnabled(false); |
429 | 430 |
430 Source<Profile> ns_source(profile_->GetOriginalProfile()); | 431 Source<Profile> ns_source(profile_->GetOriginalProfile()); |
431 registrar_.Add(this, NotificationType::BOOKMARK_BUBBLE_SHOWN, ns_source); | 432 registrar_.Add(this, chrome::NOTIFICATION_BOOKMARK_BUBBLE_SHOWN, ns_source); |
432 registrar_.Add(this, NotificationType::BOOKMARK_BUBBLE_HIDDEN, ns_source); | 433 registrar_.Add(this, chrome::NOTIFICATION_BOOKMARK_BUBBLE_HIDDEN, ns_source); |
433 | 434 |
434 // Remove any existing bookmark buttons. | 435 // Remove any existing bookmark buttons. |
435 while (GetBookmarkButtonCount()) | 436 while (GetBookmarkButtonCount()) |
436 delete GetChildViewAt(0); | 437 delete GetChildViewAt(0); |
437 | 438 |
438 model_ = profile_->GetBookmarkModel(); | 439 model_ = profile_->GetBookmarkModel(); |
439 if (model_) { | 440 if (model_) { |
440 model_->AddObserver(this); | 441 model_->AddObserver(this); |
441 if (model_->IsLoaded()) | 442 if (model_->IsLoaded()) |
442 Loaded(model_); | 443 Loaded(model_); |
(...skipping 695 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
1138 PageNavigator* navigator = | 1139 PageNavigator* navigator = |
1139 browser() ? browser()->GetSelectedTabContents() : NULL; | 1140 browser() ? browser()->GetSelectedTabContents() : NULL; |
1140 bool close_on_remove = | 1141 bool close_on_remove = |
1141 (parent == profile_->GetBookmarkModel()->other_node() && | 1142 (parent == profile_->GetBookmarkModel()->other_node() && |
1142 parent->child_count() == 1); | 1143 parent->child_count() == 1); |
1143 BookmarkContextMenu controller(GetWidget()->GetNativeWindow(), profile_, | 1144 BookmarkContextMenu controller(GetWidget()->GetNativeWindow(), profile_, |
1144 navigator, parent, nodes, close_on_remove); | 1145 navigator, parent, nodes, close_on_remove); |
1145 controller.RunMenuAt(p); | 1146 controller.RunMenuAt(p); |
1146 } | 1147 } |
1147 | 1148 |
1148 void BookmarkBarView::Observe(NotificationType type, | 1149 void BookmarkBarView::Observe(int type, |
1149 const NotificationSource& source, | 1150 const NotificationSource& source, |
1150 const NotificationDetails& details) { | 1151 const NotificationDetails& details) { |
1151 DCHECK(profile_); | 1152 DCHECK(profile_); |
1152 switch (type.value) { | 1153 switch (type) { |
1153 case NotificationType::BOOKMARK_BUBBLE_SHOWN: { | 1154 case chrome::NOTIFICATION_BOOKMARK_BUBBLE_SHOWN: { |
1154 StopThrobbing(true); | 1155 StopThrobbing(true); |
1155 GURL url = *(Details<GURL>(details).ptr()); | 1156 GURL url = *(Details<GURL>(details).ptr()); |
1156 const BookmarkNode* node = model_->GetMostRecentlyAddedNodeForURL(url); | 1157 const BookmarkNode* node = model_->GetMostRecentlyAddedNodeForURL(url); |
1157 if (!node) | 1158 if (!node) |
1158 return; // Generally shouldn't happen. | 1159 return; // Generally shouldn't happen. |
1159 StartThrobbing(node, false); | 1160 StartThrobbing(node, false); |
1160 break; | 1161 break; |
1161 } | 1162 } |
1162 case NotificationType::BOOKMARK_BUBBLE_HIDDEN: | 1163 case chrome::NOTIFICATION_BOOKMARK_BUBBLE_HIDDEN: |
1163 StopThrobbing(false); | 1164 StopThrobbing(false); |
1164 break; | 1165 break; |
1165 | 1166 |
1166 default: | 1167 default: |
1167 NOTREACHED(); | 1168 NOTREACHED(); |
1168 break; | 1169 break; |
1169 } | 1170 } |
1170 } | 1171 } |
1171 | 1172 |
1172 void BookmarkBarView::Init() { | 1173 void BookmarkBarView::Init() { |
(...skipping 581 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
1754 (1 - size_animation_->GetCurrentValue()))); | 1755 (1 - size_animation_->GetCurrentValue()))); |
1755 } else { | 1756 } else { |
1756 prefsize.set_height( | 1757 prefsize.set_height( |
1757 static_cast<int>( | 1758 static_cast<int>( |
1758 browser_defaults::kBookmarkBarHeight * | 1759 browser_defaults::kBookmarkBarHeight * |
1759 size_animation_->GetCurrentValue())); | 1760 size_animation_->GetCurrentValue())); |
1760 } | 1761 } |
1761 } | 1762 } |
1762 return prefsize; | 1763 return prefsize; |
1763 } | 1764 } |
OLD | NEW |