| 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 <stdint.h> | 7 #include <stdint.h> |
| 8 | 8 |
| 9 #include <algorithm> | 9 #include <algorithm> |
| 10 #include <limits> | 10 #include <limits> |
| 11 #include <string> | 11 #include <string> |
| 12 #include <vector> | 12 #include <vector> |
| 13 | 13 |
| 14 #include "base/bind.h" | 14 #include "base/bind.h" |
| 15 #include "base/i18n/rtl.h" | 15 #include "base/i18n/rtl.h" |
| 16 #include "base/macros.h" | 16 #include "base/macros.h" |
| 17 #include "base/memory/ptr_util.h" | 17 #include "base/memory/ptr_util.h" |
| 18 #include "base/metrics/histogram_macros.h" | 18 #include "base/metrics/histogram_macros.h" |
| 19 #include "base/metrics/user_metrics.h" |
| 19 #include "base/single_thread_task_runner.h" | 20 #include "base/single_thread_task_runner.h" |
| 20 #include "base/strings/string_util.h" | 21 #include "base/strings/string_util.h" |
| 21 #include "base/strings/utf_string_conversions.h" | 22 #include "base/strings/utf_string_conversions.h" |
| 22 #include "base/threading/thread_task_runner_handle.h" | 23 #include "base/threading/thread_task_runner_handle.h" |
| 23 #include "build/build_config.h" | 24 #include "build/build_config.h" |
| 24 #include "chrome/app/vector_icons/vector_icons.h" | 25 #include "chrome/app/vector_icons/vector_icons.h" |
| 25 #include "chrome/browser/bookmarks/bookmark_model_factory.h" | 26 #include "chrome/browser/bookmarks/bookmark_model_factory.h" |
| 26 #include "chrome/browser/bookmarks/managed_bookmark_service_factory.h" | 27 #include "chrome/browser/bookmarks/managed_bookmark_service_factory.h" |
| 27 #include "chrome/browser/browser_process.h" | 28 #include "chrome/browser/browser_process.h" |
| 28 #include "chrome/browser/defaults.h" | 29 #include "chrome/browser/defaults.h" |
| (...skipping 27 matching lines...) Expand all Loading... |
| 56 #include "components/bookmarks/browser/bookmark_model.h" | 57 #include "components/bookmarks/browser/bookmark_model.h" |
| 57 #include "components/bookmarks/browser/bookmark_utils.h" | 58 #include "components/bookmarks/browser/bookmark_utils.h" |
| 58 #include "components/bookmarks/common/bookmark_pref_names.h" | 59 #include "components/bookmarks/common/bookmark_pref_names.h" |
| 59 #include "components/bookmarks/managed/managed_bookmark_service.h" | 60 #include "components/bookmarks/managed/managed_bookmark_service.h" |
| 60 #include "components/browser_sync/profile_sync_service.h" | 61 #include "components/browser_sync/profile_sync_service.h" |
| 61 #include "components/metrics/metrics_service.h" | 62 #include "components/metrics/metrics_service.h" |
| 62 #include "components/omnibox/browser/omnibox_popup_model.h" | 63 #include "components/omnibox/browser/omnibox_popup_model.h" |
| 63 #include "components/omnibox/browser/omnibox_view.h" | 64 #include "components/omnibox/browser/omnibox_view.h" |
| 64 #include "components/prefs/pref_service.h" | 65 #include "components/prefs/pref_service.h" |
| 65 #include "components/url_formatter/elide_url.h" | 66 #include "components/url_formatter/elide_url.h" |
| 66 #include "content/public/browser/user_metrics.h" | |
| 67 #include "extensions/browser/extension_registry.h" | 67 #include "extensions/browser/extension_registry.h" |
| 68 #include "extensions/common/extension.h" | 68 #include "extensions/common/extension.h" |
| 69 #include "extensions/common/extension_set.h" | 69 #include "extensions/common/extension_set.h" |
| 70 #include "ui/accessibility/ax_node_data.h" | 70 #include "ui/accessibility/ax_node_data.h" |
| 71 #include "ui/base/dragdrop/drag_utils.h" | 71 #include "ui/base/dragdrop/drag_utils.h" |
| 72 #include "ui/base/dragdrop/os_exchange_data.h" | 72 #include "ui/base/dragdrop/os_exchange_data.h" |
| 73 #include "ui/base/l10n/l10n_util.h" | 73 #include "ui/base/l10n/l10n_util.h" |
| 74 #include "ui/base/page_transition_types.h" | 74 #include "ui/base/page_transition_types.h" |
| 75 #include "ui/base/resource/resource_bundle.h" | 75 #include "ui/base/resource/resource_bundle.h" |
| 76 #include "ui/base/theme_provider.h" | 76 #include "ui/base/theme_provider.h" |
| (...skipping 1123 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 1200 parent_node = root->GetChild(index); | 1200 parent_node = root->GetChild(index); |
| 1201 index = parent_node->child_count(); | 1201 index = parent_node->child_count(); |
| 1202 } else { | 1202 } else { |
| 1203 parent_node = root; | 1203 parent_node = root; |
| 1204 } | 1204 } |
| 1205 const BookmarkNodeData data = drop_info_->data; | 1205 const BookmarkNodeData data = drop_info_->data; |
| 1206 DCHECK(data.is_valid()); | 1206 DCHECK(data.is_valid()); |
| 1207 bool copy = drop_info_->location.operation == ui::DragDropTypes::DRAG_COPY; | 1207 bool copy = drop_info_->location.operation == ui::DragDropTypes::DRAG_COPY; |
| 1208 drop_info_.reset(); | 1208 drop_info_.reset(); |
| 1209 | 1209 |
| 1210 content::RecordAction(base::UserMetricsAction("BookmarkBar_DragEnd")); | 1210 base::RecordAction(base::UserMetricsAction("BookmarkBar_DragEnd")); |
| 1211 return chrome::DropBookmarks( | 1211 return chrome::DropBookmarks( |
| 1212 browser_->profile(), data, parent_node, index, copy); | 1212 browser_->profile(), data, parent_node, index, copy); |
| 1213 } | 1213 } |
| 1214 | 1214 |
| 1215 void BookmarkBarView::OnThemeChanged() { | 1215 void BookmarkBarView::OnThemeChanged() { |
| 1216 UpdateAppearanceForTheme(); | 1216 UpdateAppearanceForTheme(); |
| 1217 } | 1217 } |
| 1218 | 1218 |
| 1219 const char* BookmarkBarView::GetClassName() const { | 1219 const char* BookmarkBarView::GetClassName() const { |
| 1220 return kViewClassName; | 1220 return kViewClassName; |
| (...skipping 165 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 1386 } | 1386 } |
| 1387 | 1387 |
| 1388 void BookmarkBarView::BookmarkNodeFaviconChanged(BookmarkModel* model, | 1388 void BookmarkBarView::BookmarkNodeFaviconChanged(BookmarkModel* model, |
| 1389 const BookmarkNode* node) { | 1389 const BookmarkNode* node) { |
| 1390 BookmarkNodeChangedImpl(model, node); | 1390 BookmarkNodeChangedImpl(model, node); |
| 1391 } | 1391 } |
| 1392 | 1392 |
| 1393 void BookmarkBarView::WriteDragDataForView(View* sender, | 1393 void BookmarkBarView::WriteDragDataForView(View* sender, |
| 1394 const gfx::Point& press_pt, | 1394 const gfx::Point& press_pt, |
| 1395 ui::OSExchangeData* data) { | 1395 ui::OSExchangeData* data) { |
| 1396 content::RecordAction(UserMetricsAction("BookmarkBar_DragButton")); | 1396 base::RecordAction(UserMetricsAction("BookmarkBar_DragButton")); |
| 1397 | 1397 |
| 1398 for (int i = 0; i < GetBookmarkButtonCount(); ++i) { | 1398 for (int i = 0; i < GetBookmarkButtonCount(); ++i) { |
| 1399 if (sender == GetBookmarkButton(i)) { | 1399 if (sender == GetBookmarkButton(i)) { |
| 1400 const BookmarkNode* node = model_->bookmark_bar_node()->GetChild(i); | 1400 const BookmarkNode* node = model_->bookmark_bar_node()->GetChild(i); |
| 1401 gfx::ImageSkia icon; | 1401 gfx::ImageSkia icon; |
| 1402 views::Widget* widget = sender->GetWidget(); | 1402 views::Widget* widget = sender->GetWidget(); |
| 1403 if (node->is_url()) { | 1403 if (node->is_url()) { |
| 1404 const gfx::Image& image = model_->GetFavicon(node); | 1404 const gfx::Image& image = model_->GetFavicon(node); |
| 1405 icon = image.IsEmpty() ? *GetImageSkiaNamed(IDR_DEFAULT_FAVICON) | 1405 icon = image.IsEmpty() ? *GetImageSkiaNamed(IDR_DEFAULT_FAVICON) |
| 1406 : image.AsImageSkia(); | 1406 : image.AsImageSkia(); |
| (...skipping 740 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 2147 return; | 2147 return; |
| 2148 apps_page_shortcut_->SetVisible(visible); | 2148 apps_page_shortcut_->SetVisible(visible); |
| 2149 UpdateBookmarksSeparatorVisibility(); | 2149 UpdateBookmarksSeparatorVisibility(); |
| 2150 LayoutAndPaint(); | 2150 LayoutAndPaint(); |
| 2151 } | 2151 } |
| 2152 | 2152 |
| 2153 void BookmarkBarView::OnShowManagedBookmarksPrefChanged() { | 2153 void BookmarkBarView::OnShowManagedBookmarksPrefChanged() { |
| 2154 if (UpdateOtherAndManagedButtonsVisibility()) | 2154 if (UpdateOtherAndManagedButtonsVisibility()) |
| 2155 LayoutAndPaint(); | 2155 LayoutAndPaint(); |
| 2156 } | 2156 } |
| OLD | NEW |