OLD | NEW |
1 // Copyright (c) 2011 The Chromium Authors. All rights reserved. | 1 // Copyright (c) 2011 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 "base/bind.h" | 5 #include "base/bind.h" |
6 #include "base/callback.h" | 6 #include "base/callback.h" |
7 #include "base/compiler_specific.h" | 7 #include "base/compiler_specific.h" |
8 #include "base/string_number_conversions.h" | 8 #include "base/string_number_conversions.h" |
9 #include "base/utf_string_conversions.h" | 9 #include "base/utf_string_conversions.h" |
10 #include "chrome/app/chrome_command_ids.h" | 10 #include "chrome/app/chrome_command_ids.h" |
11 #include "chrome/browser/automation/ui_controls.h" | 11 #include "chrome/browser/automation/ui_controls.h" |
12 #include "chrome/browser/bookmarks/bookmark_model.h" | 12 #include "chrome/browser/bookmarks/bookmark_model.h" |
13 #include "chrome/browser/bookmarks/bookmark_utils.h" | 13 #include "chrome/browser/bookmarks/bookmark_utils.h" |
14 #include "chrome/browser/prefs/pref_service.h" | 14 #include "chrome/browser/prefs/pref_service.h" |
15 #include "chrome/browser/profiles/profile.h" | 15 #include "chrome/browser/profiles/profile.h" |
16 #include "chrome/browser/ui/browser.h" | 16 #include "chrome/browser/ui/browser.h" |
17 #include "chrome/browser/ui/views/bookmarks/bookmark_bar_view.h" | 17 #include "chrome/browser/ui/views/bookmarks/bookmark_bar_view.h" |
18 #include "chrome/common/chrome_notification_types.h" | 18 #include "chrome/common/chrome_notification_types.h" |
19 #include "chrome/common/pref_names.h" | 19 #include "chrome/common/pref_names.h" |
20 #include "chrome/test/base/testing_browser_process.h" | 20 #include "chrome/test/base/testing_browser_process.h" |
21 #include "chrome/test/base/testing_profile.h" | 21 #include "chrome/test/base/testing_profile.h" |
22 #include "chrome/test/base/ui_test_utils.h" | 22 #include "chrome/test/base/ui_test_utils.h" |
23 #include "chrome/test/base/view_event_test_base.h" | 23 #include "chrome/test/base/view_event_test_base.h" |
24 #include "content/browser/tab_contents/page_navigator.h" | 24 #include "content/browser/tab_contents/page_navigator.h" |
25 #include "content/common/notification_service.h" | 25 #include "content/public/browser/notification_service.h" |
26 #include "grit/generated_resources.h" | 26 #include "grit/generated_resources.h" |
27 #include "ui/base/accessibility/accessibility_types.h" | 27 #include "ui/base/accessibility/accessibility_types.h" |
28 #include "ui/base/clipboard/clipboard.h" | 28 #include "ui/base/clipboard/clipboard.h" |
29 #include "ui/base/keycodes/keyboard_codes.h" | 29 #include "ui/base/keycodes/keyboard_codes.h" |
30 #include "views/controls/button/menu_button.h" | 30 #include "views/controls/button/menu_button.h" |
31 #include "views/controls/button/text_button.h" | 31 #include "views/controls/button/text_button.h" |
32 #include "views/controls/menu/menu_controller.h" | 32 #include "views/controls/menu/menu_controller.h" |
33 #include "views/controls/menu/menu_item_view.h" | 33 #include "views/controls/menu/menu_item_view.h" |
34 #include "views/controls/menu/submenu_view.h" | 34 #include "views/controls/menu/submenu_view.h" |
35 #include "views/views_delegate.h" | 35 #include "views/views_delegate.h" |
(...skipping 436 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
472 | 472 |
473 // Observer that posts task upon the context menu creation. | 473 // Observer that posts task upon the context menu creation. |
474 // This is necessary for Linux as the context menu has to check | 474 // This is necessary for Linux as the context menu has to check |
475 // the clipboard, which invokes the event loop. | 475 // the clipboard, which invokes the event loop. |
476 class ContextMenuNotificationObserver : public content::NotificationObserver { | 476 class ContextMenuNotificationObserver : public content::NotificationObserver { |
477 public: | 477 public: |
478 explicit ContextMenuNotificationObserver(const base::Closure& task) | 478 explicit ContextMenuNotificationObserver(const base::Closure& task) |
479 : task_(task) { | 479 : task_(task) { |
480 registrar_.Add(this, | 480 registrar_.Add(this, |
481 chrome::NOTIFICATION_BOOKMARK_CONTEXT_MENU_SHOWN, | 481 chrome::NOTIFICATION_BOOKMARK_CONTEXT_MENU_SHOWN, |
482 NotificationService::AllSources()); | 482 content::NotificationService::AllSources()); |
483 } | 483 } |
484 | 484 |
485 virtual void Observe(int type, | 485 virtual void Observe(int type, |
486 const content::NotificationSource& source, | 486 const content::NotificationSource& source, |
487 const content::NotificationDetails& details) { | 487 const content::NotificationDetails& details) { |
488 MessageLoop::current()->PostTask(FROM_HERE, task_); | 488 MessageLoop::current()->PostTask(FROM_HERE, task_); |
489 } | 489 } |
490 | 490 |
491 // Sets the task that is posted when the context menu is shown. | 491 // Sets the task that is posted when the context menu is shown. |
492 void set_task(const base::Closure& task) { task_ = task; } | 492 void set_task(const base::Closure& task) { task_ = task; } |
(...skipping 1083 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
1576 ASSERT_TRUE(menu != NULL); | 1576 ASSERT_TRUE(menu != NULL); |
1577 ASSERT_TRUE(menu->GetSubmenu()->IsShowing()); | 1577 ASSERT_TRUE(menu->GetSubmenu()->IsShowing()); |
1578 | 1578 |
1579 menu->GetMenuController()->CancelAll(); | 1579 menu->GetMenuController()->CancelAll(); |
1580 | 1580 |
1581 Done(); | 1581 Done(); |
1582 } | 1582 } |
1583 }; | 1583 }; |
1584 | 1584 |
1585 VIEW_TEST(BookmarkBarViewTest19, SiblingMenu) | 1585 VIEW_TEST(BookmarkBarViewTest19, SiblingMenu) |
OLD | NEW |