| OLD | NEW |
| 1 // Copyright (c) 2006-2008 The Chromium Authors. All rights reserved. | 1 // Copyright (c) 2006-2008 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/views/bookmark_bar_view.h" | 5 #include "chrome/browser/views/bookmark_bar_view.h" |
| 6 | 6 |
| 7 #include <limits> | 7 #include <limits> |
| 8 | 8 |
| 9 #include "base/string_util.h" | 9 #include "base/string_util.h" |
| 10 #include "base/base_drag_source.h" | 10 #include "base/base_drag_source.h" |
| (...skipping 399 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 410 | 410 |
| 411 // Returns the bitmap to use for starred groups. | 411 // Returns the bitmap to use for starred groups. |
| 412 static const SkBitmap& GetGroupIcon() { | 412 static const SkBitmap& GetGroupIcon() { |
| 413 if (!kFolderIcon) { | 413 if (!kFolderIcon) { |
| 414 kFolderIcon = ResourceBundle::GetSharedInstance(). | 414 kFolderIcon = ResourceBundle::GetSharedInstance(). |
| 415 GetBitmapNamed(IDR_BOOKMARK_BAR_FOLDER); | 415 GetBitmapNamed(IDR_BOOKMARK_BAR_FOLDER); |
| 416 } | 416 } |
| 417 return *kFolderIcon; | 417 return *kFolderIcon; |
| 418 } | 418 } |
| 419 | 419 |
| 420 // static | |
| 421 void BookmarkBarView::ToggleWhenVisible(Profile* profile) { | |
| 422 PrefService* prefs = profile->GetPrefs(); | |
| 423 const bool always_show = !prefs->GetBoolean(prefs::kShowBookmarkBar); | |
| 424 | |
| 425 // The user changed when the bookmark bar is shown, update the preferences. | |
| 426 prefs->SetBoolean(prefs::kShowBookmarkBar, always_show); | |
| 427 prefs->ScheduleSavePersistentPrefs(g_browser_process->file_thread()); | |
| 428 | |
| 429 // And notify the notification service. | |
| 430 Source<Profile> source(profile); | |
| 431 NotificationService::current()->Notify( | |
| 432 NotificationType::BOOKMARK_BAR_VISIBILITY_PREF_CHANGED, | |
| 433 source, | |
| 434 NotificationService::NoDetails()); | |
| 435 } | |
| 436 | |
| 437 // static | |
| 438 void BookmarkBarView::RegisterUserPrefs(PrefService* prefs) { | |
| 439 prefs->RegisterBooleanPref(prefs::kShowBookmarkBar, false); | |
| 440 } | |
| 441 | |
| 442 BookmarkBarView::BookmarkBarView(Profile* profile, Browser* browser) | 420 BookmarkBarView::BookmarkBarView(Profile* profile, Browser* browser) |
| 443 : profile_(NULL), | 421 : profile_(NULL), |
| 444 browser_(browser), | 422 browser_(browser), |
| 445 page_navigator_(NULL), | 423 page_navigator_(NULL), |
| 446 model_(NULL), | 424 model_(NULL), |
| 447 bookmark_menu_(NULL), | 425 bookmark_menu_(NULL), |
| 448 bookmark_drop_menu_(NULL), | 426 bookmark_drop_menu_(NULL), |
| 449 other_bookmarked_button_(NULL), | 427 other_bookmarked_button_(NULL), |
| 450 model_changed_listener_(NULL), | 428 model_changed_listener_(NULL), |
| 451 show_folder_drop_menu_task_(NULL), | 429 show_folder_drop_menu_task_(NULL), |
| (...skipping 890 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 1342 } | 1320 } |
| 1343 button->set_max_width(kMaxButtonWidth); | 1321 button->set_max_width(kMaxButtonWidth); |
| 1344 } | 1322 } |
| 1345 | 1323 |
| 1346 bool BookmarkBarView::IsItemChecked(int id) const { | 1324 bool BookmarkBarView::IsItemChecked(int id) const { |
| 1347 DCHECK(id == kAlwaysShowCommandID); | 1325 DCHECK(id == kAlwaysShowCommandID); |
| 1348 return profile_->GetPrefs()->GetBoolean(prefs::kShowBookmarkBar); | 1326 return profile_->GetPrefs()->GetBoolean(prefs::kShowBookmarkBar); |
| 1349 } | 1327 } |
| 1350 | 1328 |
| 1351 void BookmarkBarView::ExecuteCommand(int id) { | 1329 void BookmarkBarView::ExecuteCommand(int id) { |
| 1352 ToggleWhenVisible(profile_); | 1330 bookmark_utils::ToggleWhenVisible(profile_); |
| 1353 } | 1331 } |
| 1354 | 1332 |
| 1355 void BookmarkBarView::Observe(NotificationType type, | 1333 void BookmarkBarView::Observe(NotificationType type, |
| 1356 const NotificationSource& source, | 1334 const NotificationSource& source, |
| 1357 const NotificationDetails& details) { | 1335 const NotificationDetails& details) { |
| 1358 DCHECK(profile_); | 1336 DCHECK(profile_); |
| 1359 switch (type.value) { | 1337 switch (type.value) { |
| 1360 case NotificationType::BOOKMARK_BAR_VISIBILITY_PREF_CHANGED: | 1338 case NotificationType::BOOKMARK_BAR_VISIBILITY_PREF_CHANGED: |
| 1361 if (IsAlwaysShown()) { | 1339 if (IsAlwaysShown()) { |
| 1362 size_animation_->Show(); | 1340 size_animation_->Show(); |
| (...skipping 301 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 1664 } | 1642 } |
| 1665 | 1643 |
| 1666 void BookmarkBarView::StopThrobbing(bool immediate) { | 1644 void BookmarkBarView::StopThrobbing(bool immediate) { |
| 1667 if (!throbbing_view_) | 1645 if (!throbbing_view_) |
| 1668 return; | 1646 return; |
| 1669 | 1647 |
| 1670 // If not immediate, cycle through 2 more complete cycles. | 1648 // If not immediate, cycle through 2 more complete cycles. |
| 1671 throbbing_view_->StartThrobbing(immediate ? 0 : 4); | 1649 throbbing_view_->StartThrobbing(immediate ? 0 : 4); |
| 1672 throbbing_view_ = NULL; | 1650 throbbing_view_ = NULL; |
| 1673 } | 1651 } |
| OLD | NEW |