OLD | NEW |
1 // Copyright 2014 The Chromium Authors. All rights reserved. | 1 // Copyright 2014 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_context_menu.h" | 5 #include "chrome/browser/ui/views/bookmarks/bookmark_context_menu.h" |
6 | 6 |
7 #include <stddef.h> | 7 #include <stddef.h> |
8 | 8 |
9 #include <memory> | 9 #include <memory> |
10 #include <string> | 10 #include <string> |
| 11 #include <utility> |
11 #include <vector> | 12 #include <vector> |
12 | 13 |
13 #include "base/compiler_specific.h" | 14 #include "base/compiler_specific.h" |
14 #include "base/strings/utf_string_conversions.h" | 15 #include "base/strings/utf_string_conversions.h" |
15 #include "base/threading/sequenced_worker_pool.h" | 16 #include "base/threading/sequenced_worker_pool.h" |
16 #include "base/values.h" | 17 #include "base/values.h" |
17 #include "build/build_config.h" | 18 #include "build/build_config.h" |
18 #include "chrome/app/chrome_command_ids.h" | 19 #include "chrome/app/chrome_command_ids.h" |
19 #include "chrome/browser/bookmarks/bookmark_model_factory.h" | 20 #include "chrome/browser/bookmarks/bookmark_model_factory.h" |
20 #include "chrome/browser/bookmarks/managed_bookmark_service_factory.h" | 21 #include "chrome/browser/bookmarks/managed_bookmark_service_factory.h" |
(...skipping 330 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
351 controller->IsCommandVisible(IDC_BOOKMARK_BAR_SHOW_MANAGED_BOOKMARKS)); | 352 controller->IsCommandVisible(IDC_BOOKMARK_BAR_SHOW_MANAGED_BOOKMARKS)); |
352 views::MenuItemView* menu = controller->menu(); | 353 views::MenuItemView* menu = controller->menu(); |
353 EXPECT_FALSE(menu->GetMenuItemByID(IDC_BOOKMARK_BAR_SHOW_MANAGED_BOOKMARKS) | 354 EXPECT_FALSE(menu->GetMenuItemByID(IDC_BOOKMARK_BAR_SHOW_MANAGED_BOOKMARKS) |
354 ->visible()); | 355 ->visible()); |
355 | 356 |
356 // Other options are not affected. | 357 // Other options are not affected. |
357 EXPECT_TRUE(controller->IsCommandVisible(IDC_BOOKMARK_BAR_NEW_FOLDER)); | 358 EXPECT_TRUE(controller->IsCommandVisible(IDC_BOOKMARK_BAR_NEW_FOLDER)); |
358 EXPECT_TRUE(menu->GetMenuItemByID(IDC_BOOKMARK_BAR_NEW_FOLDER)->visible()); | 359 EXPECT_TRUE(menu->GetMenuItemByID(IDC_BOOKMARK_BAR_NEW_FOLDER)->visible()); |
359 | 360 |
360 // Now set the managed bookmarks policy. | 361 // Now set the managed bookmarks policy. |
361 base::DictionaryValue* dict = new base::DictionaryValue; | 362 std::unique_ptr<base::DictionaryValue> dict(new base::DictionaryValue); |
362 dict->SetString("name", "Google"); | 363 dict->SetString("name", "Google"); |
363 dict->SetString("url", "http://google.com"); | 364 dict->SetString("url", "http://google.com"); |
364 base::ListValue list; | 365 base::ListValue list; |
365 list.Append(dict); | 366 list.Append(std::move(dict)); |
366 EXPECT_TRUE(managed->managed_node()->empty()); | 367 EXPECT_TRUE(managed->managed_node()->empty()); |
367 profile_->GetPrefs()->Set(bookmarks::prefs::kManagedBookmarks, list); | 368 profile_->GetPrefs()->Set(bookmarks::prefs::kManagedBookmarks, list); |
368 EXPECT_FALSE(managed->managed_node()->empty()); | 369 EXPECT_FALSE(managed->managed_node()->empty()); |
369 | 370 |
370 // New context menus now show the "Show managed bookmarks" option. | 371 // New context menus now show the "Show managed bookmarks" option. |
371 controller.reset(new BookmarkContextMenu( | 372 controller.reset(new BookmarkContextMenu( |
372 NULL, NULL, profile_.get(), NULL, nodes[0]->parent(), nodes, false)); | 373 NULL, NULL, profile_.get(), NULL, nodes[0]->parent(), nodes, false)); |
373 EXPECT_TRUE(controller->IsCommandVisible(IDC_BOOKMARK_BAR_NEW_FOLDER)); | 374 EXPECT_TRUE(controller->IsCommandVisible(IDC_BOOKMARK_BAR_NEW_FOLDER)); |
374 EXPECT_TRUE( | 375 EXPECT_TRUE( |
375 controller->IsCommandVisible(IDC_BOOKMARK_BAR_SHOW_MANAGED_BOOKMARKS)); | 376 controller->IsCommandVisible(IDC_BOOKMARK_BAR_SHOW_MANAGED_BOOKMARKS)); |
376 menu = controller->menu(); | 377 menu = controller->menu(); |
377 EXPECT_TRUE(menu->GetMenuItemByID(IDC_BOOKMARK_BAR_NEW_FOLDER)->visible()); | 378 EXPECT_TRUE(menu->GetMenuItemByID(IDC_BOOKMARK_BAR_NEW_FOLDER)->visible()); |
378 EXPECT_TRUE(menu->GetMenuItemByID(IDC_BOOKMARK_BAR_SHOW_MANAGED_BOOKMARKS) | 379 EXPECT_TRUE(menu->GetMenuItemByID(IDC_BOOKMARK_BAR_SHOW_MANAGED_BOOKMARKS) |
379 ->visible()); | 380 ->visible()); |
380 } | 381 } |
OLD | NEW |