| 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 <string> | 9 #include <string> |
| 10 #include <vector> | 10 #include <vector> |
| (...skipping 1317 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 1328 // Child views are traversed in the order they are added. Make sure the order | 1328 // Child views are traversed in the order they are added. Make sure the order |
| 1329 // they are added matches the visual order. | 1329 // they are added matches the visual order. |
| 1330 overflow_button_ = CreateOverflowButton(); | 1330 overflow_button_ = CreateOverflowButton(); |
| 1331 AddChildView(overflow_button_); | 1331 AddChildView(overflow_button_); |
| 1332 | 1332 |
| 1333 other_bookmarked_button_ = CreateOtherBookmarkedButton(); | 1333 other_bookmarked_button_ = CreateOtherBookmarkedButton(); |
| 1334 // We'll re-enable when the model is loaded. | 1334 // We'll re-enable when the model is loaded. |
| 1335 other_bookmarked_button_->SetEnabled(false); | 1335 other_bookmarked_button_->SetEnabled(false); |
| 1336 AddChildView(other_bookmarked_button_); | 1336 AddChildView(other_bookmarked_button_); |
| 1337 | 1337 |
| 1338 managed_bookmarks_button_ = CreateOtherBookmarkedButton(); | 1338 managed_bookmarks_button_ = CreateManagedBookmarksButton(); |
| 1339 // Also re-enabled when the model is loaded. | 1339 // Also re-enabled when the model is loaded. |
| 1340 managed_bookmarks_button_->SetEnabled(false); | 1340 managed_bookmarks_button_->SetEnabled(false); |
| 1341 AddChildView(managed_bookmarks_button_); | 1341 AddChildView(managed_bookmarks_button_); |
| 1342 | 1342 |
| 1343 apps_page_shortcut_ = CreateAppsPageShortcutButton(); | 1343 apps_page_shortcut_ = CreateAppsPageShortcutButton(); |
| 1344 AddChildView(apps_page_shortcut_); | 1344 AddChildView(apps_page_shortcut_); |
| 1345 profile_pref_registrar_.Init(browser_->profile()->GetPrefs()); | 1345 profile_pref_registrar_.Init(browser_->profile()->GetPrefs()); |
| 1346 profile_pref_registrar_.Add( | 1346 profile_pref_registrar_.Add( |
| 1347 prefs::kShowAppsShortcutInBookmarkBar, | 1347 prefs::kShowAppsShortcutInBookmarkBar, |
| 1348 base::Bind(&BookmarkBarView::OnAppsPageShortcutVisibilityPrefChanged, | 1348 base::Bind(&BookmarkBarView::OnAppsPageShortcutVisibilityPrefChanged, |
| (...skipping 63 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 1412 button->set_context_menu_controller(this); | 1412 button->set_context_menu_controller(this); |
| 1413 button->set_tag(kOtherFolderButtonTag); | 1413 button->set_tag(kOtherFolderButtonTag); |
| 1414 return button; | 1414 return button; |
| 1415 } | 1415 } |
| 1416 | 1416 |
| 1417 MenuButton* BookmarkBarView::CreateManagedBookmarksButton() { | 1417 MenuButton* BookmarkBarView::CreateManagedBookmarksButton() { |
| 1418 // Title is set in Loaded. | 1418 // Title is set in Loaded. |
| 1419 MenuButton* button = | 1419 MenuButton* button = |
| 1420 new BookmarkFolderButton(this, base::string16(), this, false); | 1420 new BookmarkFolderButton(this, base::string16(), this, false); |
| 1421 button->set_id(VIEW_ID_MANAGED_BOOKMARKS); | 1421 button->set_id(VIEW_ID_MANAGED_BOOKMARKS); |
| 1422 // TODO(joaodasilva): replace with a "managed folder" icon. | 1422 ui::ResourceBundle* rb = &ui::ResourceBundle::GetSharedInstance(); |
| 1423 // http://crbug.com/49598 | 1423 gfx::ImageSkia* image = |
| 1424 button->SetImage(views::Button::STATE_NORMAL, GetFolderIcon()); | 1424 rb->GetImageSkiaNamed(IDR_BOOKMARK_BAR_FOLDER_MANAGED); |
| 1425 button->SetImage(views::Button::STATE_NORMAL, *image); |
| 1425 button->set_context_menu_controller(this); | 1426 button->set_context_menu_controller(this); |
| 1426 button->set_tag(kManagedFolderButtonTag); | 1427 button->set_tag(kManagedFolderButtonTag); |
| 1427 return button; | 1428 return button; |
| 1428 } | 1429 } |
| 1429 | 1430 |
| 1430 MenuButton* BookmarkBarView::CreateOverflowButton() { | 1431 MenuButton* BookmarkBarView::CreateOverflowButton() { |
| 1431 ui::ResourceBundle* rb = &ui::ResourceBundle::GetSharedInstance(); | 1432 ui::ResourceBundle* rb = &ui::ResourceBundle::GetSharedInstance(); |
| 1432 MenuButton* button = new OverFlowButton(this); | 1433 MenuButton* button = new OverFlowButton(this); |
| 1433 button->SetImage(views::Button::STATE_NORMAL, | 1434 button->SetImage(views::Button::STATE_NORMAL, |
| 1434 *rb->GetImageSkiaNamed(IDR_BOOKMARK_BAR_CHEVRONS)); | 1435 *rb->GetImageSkiaNamed(IDR_BOOKMARK_BAR_CHEVRONS)); |
| (...skipping 512 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 1947 DCHECK(apps_page_shortcut_); | 1948 DCHECK(apps_page_shortcut_); |
| 1948 // Only perform layout if required. | 1949 // Only perform layout if required. |
| 1949 bool visible = chrome::ShouldShowAppsShortcutInBookmarkBar( | 1950 bool visible = chrome::ShouldShowAppsShortcutInBookmarkBar( |
| 1950 browser_->profile(), browser_->host_desktop_type()); | 1951 browser_->profile(), browser_->host_desktop_type()); |
| 1951 if (apps_page_shortcut_->visible() == visible) | 1952 if (apps_page_shortcut_->visible() == visible) |
| 1952 return; | 1953 return; |
| 1953 apps_page_shortcut_->SetVisible(visible); | 1954 apps_page_shortcut_->SetVisible(visible); |
| 1954 UpdateBookmarksSeparatorVisibility(); | 1955 UpdateBookmarksSeparatorVisibility(); |
| 1955 Layout(); | 1956 Layout(); |
| 1956 } | 1957 } |
| OLD | NEW |