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 "base/strings/utf_string_conversions.h" | 5 #include "base/strings/utf_string_conversions.h" |
6 #include "chrome/app/chrome_command_ids.h" | 6 #include "chrome/app/chrome_command_ids.h" |
7 #include "chrome/browser/extensions/extension_browsertest.h" | 7 #include "chrome/browser/extensions/extension_browsertest.h" |
8 #include "chrome/browser/extensions/extension_service.h" | 8 #include "chrome/browser/extensions/extension_service.h" |
9 #include "chrome/browser/extensions/extension_system.h" | 9 #include "chrome/browser/extensions/extension_system.h" |
10 #include "chrome/browser/extensions/extension_test_message_listener.h" | 10 #include "chrome/browser/extensions/extension_test_message_listener.h" |
11 #include "chrome/browser/extensions/lazy_background_page_test_util.h" | 11 #include "chrome/browser/extensions/lazy_background_page_test_util.h" |
12 #include "chrome/browser/profiles/profile.h" | 12 #include "chrome/browser/profiles/profile.h" |
13 #include "chrome/browser/tab_contents/render_view_context_menu.h" | 13 #include "chrome/browser/tab_contents/render_view_context_menu.h" |
14 #include "chrome/browser/ui/browser.h" | 14 #include "chrome/browser/ui/browser.h" |
15 #include "chrome/browser/ui/tabs/tab_strip_model.h" | 15 #include "chrome/browser/ui/tabs/tab_strip_model.h" |
16 #include "chrome/test/base/ui_test_utils.h" | 16 #include "chrome/test/base/ui_test_utils.h" |
17 #include "content/public/common/context_menu_params.h" | 17 #include "content/public/common/context_menu_params.h" |
18 #include "extensions/browser/test_management_policy.h" | 18 #include "extensions/browser/test_management_policy.h" |
| 19 #include "extensions/common/extension_set.h" |
19 #include "extensions/common/switches.h" | 20 #include "extensions/common/switches.h" |
20 #include "net/dns/mock_host_resolver.h" | 21 #include "net/dns/mock_host_resolver.h" |
21 #include "ui/base/models/menu_model.h" | 22 #include "ui/base/models/menu_model.h" |
22 | 23 |
23 using content::WebContents; | 24 using content::WebContents; |
24 using extensions::MenuItem; | 25 using extensions::MenuItem; |
25 using ui::MenuModel; | 26 using ui::MenuModel; |
26 | 27 |
27 namespace { | 28 namespace { |
28 // This test class helps us sidestep platform-specific issues with popping up a | 29 // This test class helps us sidestep platform-specific issues with popping up a |
(...skipping 97 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
126 } | 127 } |
127 | 128 |
128 // Shortcut to return the current MenuManager. | 129 // Shortcut to return the current MenuManager. |
129 extensions::MenuManager* menu_manager() { | 130 extensions::MenuManager* menu_manager() { |
130 return extensions::MenuManager::Get(browser()->profile()); | 131 return extensions::MenuManager::Get(browser()->profile()); |
131 } | 132 } |
132 | 133 |
133 // Returns a pointer to the currently loaded extension with |name|, or null | 134 // Returns a pointer to the currently loaded extension with |name|, or null |
134 // if not found. | 135 // if not found. |
135 const extensions::Extension* GetExtensionNamed(std::string name) { | 136 const extensions::Extension* GetExtensionNamed(std::string name) { |
136 const ExtensionSet* extensions = | 137 const extensions::ExtensionSet* extensions = |
137 browser()->profile()->GetExtensionService()->extensions(); | 138 browser()->profile()->GetExtensionService()->extensions(); |
138 ExtensionSet::const_iterator i; | 139 for (extensions::ExtensionSet::const_iterator i = extensions->begin(); |
139 for (i = extensions->begin(); i != extensions->end(); ++i) { | 140 i != extensions->end(); ++i) { |
140 if ((*i)->name() == name) { | 141 if ((*i)->name() == name) { |
141 return i->get(); | 142 return i->get(); |
142 } | 143 } |
143 } | 144 } |
144 return NULL; | 145 return NULL; |
145 } | 146 } |
146 | 147 |
147 // This gets all the items that any extension has registered for possible | 148 // This gets all the items that any extension has registered for possible |
148 // inclusion in context menus. | 149 // inclusion in context menus. |
149 MenuItem::List GetItems() { | 150 MenuItem::List GetItems() { |
(...skipping 509 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
659 ASSERT_TRUE(LoadContextMenuExtensionIncognito("incognito")); | 660 ASSERT_TRUE(LoadContextMenuExtensionIncognito("incognito")); |
660 | 661 |
661 // Wait for the extension's processes to tell us they've created an item. | 662 // Wait for the extension's processes to tell us they've created an item. |
662 ASSERT_TRUE(created.WaitUntilSatisfied()); | 663 ASSERT_TRUE(created.WaitUntilSatisfied()); |
663 ASSERT_TRUE(created_incognito.WaitUntilSatisfied()); | 664 ASSERT_TRUE(created_incognito.WaitUntilSatisfied()); |
664 ASSERT_EQ(2u, GetItems().size()); | 665 ASSERT_EQ(2u, GetItems().size()); |
665 | 666 |
666 browser()->profile()->DestroyOffTheRecordProfile(); | 667 browser()->profile()->DestroyOffTheRecordProfile(); |
667 ASSERT_EQ(1u, GetItems().size()); | 668 ASSERT_EQ(1u, GetItems().size()); |
668 } | 669 } |
OLD | NEW |