OLD | NEW |
1 // Copyright (c) 2012 The Chromium Authors. All rights reserved. | 1 // Copyright (c) 2012 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 432 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
443 DISALLOW_COPY_AND_ASSIGN(ButtonSeparatorView); | 443 DISALLOW_COPY_AND_ASSIGN(ButtonSeparatorView); |
444 }; | 444 }; |
445 | 445 |
446 // BookmarkBarView ------------------------------------------------------------ | 446 // BookmarkBarView ------------------------------------------------------------ |
447 | 447 |
448 // static | 448 // static |
449 const int BookmarkBarView::kMaxButtonWidth = 150; | 449 const int BookmarkBarView::kMaxButtonWidth = 150; |
450 const int BookmarkBarView::kNewtabHorizontalPadding = 8; | 450 const int BookmarkBarView::kNewtabHorizontalPadding = 8; |
451 const int BookmarkBarView::kNewtabVerticalPadding = 12; | 451 const int BookmarkBarView::kNewtabVerticalPadding = 12; |
452 | 452 |
453 // Returns the image to use for starred folders. | 453 static const gfx::ImageSkia& GetDefaultFavicon() { |
| 454 if (!kDefaultFavicon) { |
| 455 ui::ResourceBundle& rb = ui::ResourceBundle::GetSharedInstance(); |
| 456 kDefaultFavicon = rb.GetImageSkiaNamed(IDR_DEFAULT_FAVICON); |
| 457 } |
| 458 return *kDefaultFavicon; |
| 459 } |
| 460 |
454 static const gfx::ImageSkia& GetFolderIcon() { | 461 static const gfx::ImageSkia& GetFolderIcon() { |
455 if (!kFolderIcon) { | 462 if (!kFolderIcon) { |
456 ui::ResourceBundle& rb = ui::ResourceBundle::GetSharedInstance(); | 463 ui::ResourceBundle& rb = ui::ResourceBundle::GetSharedInstance(); |
457 kFolderIcon = rb.GetImageSkiaNamed(IDR_BOOKMARK_BAR_FOLDER); | 464 kFolderIcon = rb.GetImageSkiaNamed(IDR_BOOKMARK_BAR_FOLDER); |
458 } | 465 } |
459 return *kFolderIcon; | 466 return *kFolderIcon; |
460 } | 467 } |
461 | 468 |
462 BookmarkBarView::BookmarkBarView(Browser* browser, BrowserView* browser_view) | 469 BookmarkBarView::BookmarkBarView(Browser* browser, BrowserView* browser_view) |
463 : page_navigator_(NULL), | 470 : page_navigator_(NULL), |
(...skipping 787 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
1251 parent, nodes, close_on_remove)); | 1258 parent, nodes, close_on_remove)); |
1252 context_menu_->RunMenuAt(point); | 1259 context_menu_->RunMenuAt(point); |
1253 } | 1260 } |
1254 | 1261 |
1255 void BookmarkBarView::Init() { | 1262 void BookmarkBarView::Init() { |
1256 // Note that at this point we're not in a hierarchy so GetThemeProvider() will | 1263 // Note that at this point we're not in a hierarchy so GetThemeProvider() will |
1257 // return NULL. When we're inserted into a hierarchy, we'll call | 1264 // return NULL. When we're inserted into a hierarchy, we'll call |
1258 // UpdateColors(), which will set the appropriate colors for all the objects | 1265 // UpdateColors(), which will set the appropriate colors for all the objects |
1259 // added in this function. | 1266 // added in this function. |
1260 | 1267 |
1261 ui::ResourceBundle& rb = ui::ResourceBundle::GetSharedInstance(); | |
1262 | |
1263 if (!kDefaultFavicon) | |
1264 kDefaultFavicon = rb.GetImageSkiaNamed(IDR_DEFAULT_FAVICON); | |
1265 | |
1266 // Child views are traversed in the order they are added. Make sure the order | 1268 // Child views are traversed in the order they are added. Make sure the order |
1267 // they are added matches the visual order. | 1269 // they are added matches the visual order. |
1268 overflow_button_ = CreateOverflowButton(); | 1270 overflow_button_ = CreateOverflowButton(); |
1269 AddChildView(overflow_button_); | 1271 AddChildView(overflow_button_); |
1270 | 1272 |
1271 other_bookmarked_button_ = CreateOtherBookmarkedButton(); | 1273 other_bookmarked_button_ = CreateOtherBookmarkedButton(); |
1272 // We'll re-enable when the model is loaded. | 1274 // We'll re-enable when the model is loaded. |
1273 other_bookmarked_button_->SetEnabled(false); | 1275 other_bookmarked_button_->SetEnabled(false); |
1274 AddChildView(other_bookmarked_button_); | 1276 AddChildView(other_bookmarked_button_); |
1275 | 1277 |
(...skipping 131 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
1407 } | 1409 } |
1408 | 1410 |
1409 button->ClearMaxTextSize(); | 1411 button->ClearMaxTextSize(); |
1410 button->set_context_menu_controller(this); | 1412 button->set_context_menu_controller(this); |
1411 button->set_drag_controller(this); | 1413 button->set_drag_controller(this); |
1412 if (node->is_url()) { | 1414 if (node->is_url()) { |
1413 const gfx::Image& favicon = model_->GetFavicon(node); | 1415 const gfx::Image& favicon = model_->GetFavicon(node); |
1414 if (!favicon.IsEmpty()) | 1416 if (!favicon.IsEmpty()) |
1415 button->SetIcon(*favicon.ToImageSkia()); | 1417 button->SetIcon(*favicon.ToImageSkia()); |
1416 else | 1418 else |
1417 button->SetIcon(*kDefaultFavicon); | 1419 button->SetIcon(GetDefaultFavicon()); |
1418 } | 1420 } |
1419 button->set_max_width(kMaxButtonWidth); | 1421 button->set_max_width(kMaxButtonWidth); |
1420 } | 1422 } |
1421 | 1423 |
1422 void BookmarkBarView::BookmarkNodeAddedImpl(BookmarkModel* model, | 1424 void BookmarkBarView::BookmarkNodeAddedImpl(BookmarkModel* model, |
1423 const BookmarkNode* parent, | 1425 const BookmarkNode* parent, |
1424 int index) { | 1426 int index) { |
1425 UpdateOtherBookmarksVisibility(); | 1427 UpdateOtherBookmarksVisibility(); |
1426 if (parent != model_->bookmark_bar_node()) { | 1428 if (parent != model_->bookmark_bar_node()) { |
1427 // We only care about nodes on the bookmark bar. | 1429 // We only care about nodes on the bookmark bar. |
(...skipping 447 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
1875 return; | 1877 return; |
1876 apps_page_shortcut_->SetVisible(visible); | 1878 apps_page_shortcut_->SetVisible(visible); |
1877 UpdateBookmarksSeparatorVisibility(); | 1879 UpdateBookmarksSeparatorVisibility(); |
1878 Layout(); | 1880 Layout(); |
1879 } | 1881 } |
1880 | 1882 |
1881 void BookmarkBarView::OnAppLauncherEnabledCompleted(bool app_launcher_enabled) { | 1883 void BookmarkBarView::OnAppLauncherEnabledCompleted(bool app_launcher_enabled) { |
1882 // Disregard |app_launcher_enabled|, use apps::WasAppLauncherEnable instead. | 1884 // Disregard |app_launcher_enabled|, use apps::WasAppLauncherEnable instead. |
1883 OnAppsPageShortcutVisibilityPrefChanged(); | 1885 OnAppsPageShortcutVisibilityPrefChanged(); |
1884 } | 1886 } |
OLD | NEW |