Upstream version 7.36.149.0
[platform/framework/web/crosswalk.git] / src / chrome / browser / ui / views / bookmarks / bookmark_bar_view.cc
index aa4a15b..08973c8 100644 (file)
 #include "base/prefs/pref_service.h"
 #include "base/strings/string_util.h"
 #include "base/strings/utf_string_conversions.h"
-#include "chrome/browser/bookmarks/bookmark_model.h"
 #include "chrome/browser/bookmarks/bookmark_model_factory.h"
 #include "chrome/browser/browser_process.h"
 #include "chrome/browser/chrome_notification_types.h"
 #include "chrome/browser/defaults.h"
-#include "chrome/browser/extensions/extension_service.h"
 #include "chrome/browser/profiles/profile.h"
 #include "chrome/browser/search/search.h"
 #include "chrome/browser/sync/profile_sync_service.h"
@@ -49,6 +47,7 @@
 #include "chrome/common/extensions/extension_constants.h"
 #include "chrome/common/pref_names.h"
 #include "chrome/common/url_constants.h"
+#include "components/bookmarks/core/browser/bookmark_model.h"
 #include "content/public/browser/notification_details.h"
 #include "content/public/browser/notification_source.h"
 #include "content/public/browser/page_navigator.h"
@@ -57,6 +56,9 @@
 #include "content/public/browser/user_metrics.h"
 #include "content/public/browser/web_contents.h"
 #include "content/public/common/page_transition_types.h"
+#include "extensions/browser/extension_registry.h"
+#include "extensions/common/extension.h"
+#include "extensions/common/extension_set.h"
 #include "grit/generated_resources.h"
 #include "grit/theme_resources.h"
 #include "grit/ui_resources.h"
@@ -73,7 +75,6 @@
 #include "ui/views/button_drag_utils.h"
 #include "ui/views/controls/button/menu_button.h"
 #include "ui/views/controls/label.h"
-#include "ui/views/controls/menu/menu_item_view.h"
 #include "ui/views/drag_utils.h"
 #include "ui/views/metrics.h"
 #include "ui/views/view_constants.h"
@@ -88,7 +89,6 @@ using content::Referrer;
 using ui::DropTargetEvent;
 using views::CustomButton;
 using views::MenuButton;
-using views::MenuItemView;
 using views::View;
 
 // Margins around the content.
@@ -311,9 +311,9 @@ class OverFlowButton : public views::MenuButton {
 };
 
 void RecordAppLaunch(Profile* profile, GURL url) {
-  DCHECK(profile->GetExtensionService());
   const extensions::Extension* extension =
-      profile->GetExtensionService()->GetInstalledApp(url);
+      extensions::ExtensionRegistry::Get(profile)
+          ->enabled_extensions().GetAppByURL(url);
   if (!extension)
     return;
 
@@ -565,11 +565,11 @@ views::MenuButton* BookmarkBarView::GetMenuButtonForNode(
 
 void BookmarkBarView::GetAnchorPositionForButton(
     views::MenuButton* button,
-    MenuItemView::AnchorPosition* anchor) {
+    views::MenuAnchorPosition* anchor) {
   if (button == other_bookmarked_button_ || button == overflow_button_)
-    *anchor = MenuItemView::TOPRIGHT;
+    *anchor = views::MENU_ANCHOR_TOPRIGHT;
   else
-    *anchor = MenuItemView::TOPLEFT;
+    *anchor = views::MENU_ANCHOR_TOPLEFT;
 }
 
 views::MenuItemView* BookmarkBarView::GetMenu() {
@@ -1024,14 +1024,17 @@ void BookmarkBarView::BookmarkNodeAdded(BookmarkModel* model,
 void BookmarkBarView::BookmarkNodeRemoved(BookmarkModel* model,
                                           const BookmarkNode* parent,
                                           int old_index,
-                                          const BookmarkNode* node) {
+                                          const BookmarkNode* node,
+                                          const std::set<GURL>& removed_urls) {
   // Close the menu if the menu is showing for the deleted node.
   if (bookmark_menu_ && bookmark_menu_->node() == node)
     bookmark_menu_->Cancel();
   BookmarkNodeRemovedImpl(model, parent, old_index);
 }
 
-void BookmarkBarView::BookmarkAllNodesRemoved(BookmarkModel* model) {
+void BookmarkBarView::BookmarkAllNodesRemoved(
+    BookmarkModel* model,
+    const std::set<GURL>& removed_urls) {
   UpdateOtherBookmarksVisibility();
 
   StopThrobbing(true);
@@ -1538,7 +1541,8 @@ void BookmarkBarView::CalculateDropLocation(const DropTargetEvent& event,
   } else if (!GetBookmarkButtonCount()) {
     // No bookmarks, accept the drop.
     location->index = 0;
-    int ops = data.GetFirstNode(profile) ? ui::DragDropTypes::DRAG_MOVE :
+    int ops = data.GetFirstNode(model_, profile->GetPath()) ?
+        ui::DragDropTypes::DRAG_MOVE :
         ui::DragDropTypes::DRAG_COPY | ui::DragDropTypes::DRAG_LINK;
     location->operation = chrome::GetPreferredBookmarkDropOperation(
         event.source_operations(), ops);
@@ -1604,13 +1608,13 @@ void BookmarkBarView::CalculateDropLocation(const DropTargetEvent& event,
     location->operation = chrome::GetBookmarkDropOperation(
         profile, event, data, parent, parent->child_count());
     if (!location->operation && !data.has_single_url() &&
-        data.GetFirstNode(profile) == parent) {
+        data.GetFirstNode(model_, profile->GetPath()) == parent) {
       // Don't open a menu if the node being dragged is the menu to open.
       location->on = false;
     }
   } else {
-    location->operation = chrome::GetBookmarkDropOperation(profile, event,
-        data, model_->bookmark_bar_node(), location->index);
+    location->operation = chrome::GetBookmarkDropOperation(
+        profile, event, data, model_->bookmark_bar_node(), location->index);
   }
 }
 
@@ -1618,7 +1622,7 @@ void BookmarkBarView::WriteBookmarkDragData(const BookmarkNode* node,
                                             ui::OSExchangeData* data) {
   DCHECK(node && data);
   BookmarkNodeData drag_data(node);
-  drag_data.Write(browser_->profile(), data);
+  drag_data.Write(browser_->profile()->GetPath(), data);
 }
 
 void BookmarkBarView::StartThrobbing(const BookmarkNode* node,