OLD | NEW |
1 // Copyright (c) 2010 The Chromium Authors. All rights reserved. | 1 // Copyright (c) 2010 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 "app/menus/menu_model.h" | 5 #include "app/menus/menu_model.h" |
6 #include "base/utf_string_conversions.h" | 6 #include "base/utf_string_conversions.h" |
7 #include "chrome/app/chrome_command_ids.h" | 7 #include "chrome/app/chrome_command_ids.h" |
8 #include "chrome/browser/browser_list.h" | 8 #include "chrome/browser/browser_list.h" |
9 #include "chrome/browser/extensions/extension_browsertest.h" | 9 #include "chrome/browser/extensions/extension_browsertest.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/extensions_service.h" | 11 #include "chrome/browser/extensions/extension_service.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/tab_contents/tab_contents.h" | 14 #include "chrome/browser/tab_contents/tab_contents.h" |
15 #include "chrome/browser/ui/browser.h" | 15 #include "chrome/browser/ui/browser.h" |
16 #include "chrome/common/chrome_switches.h" | 16 #include "chrome/common/chrome_switches.h" |
17 #include "chrome/test/ui_test_utils.h" | 17 #include "chrome/test/ui_test_utils.h" |
18 #include "net/base/mock_host_resolver.h" | 18 #include "net/base/mock_host_resolver.h" |
19 #include "third_party/WebKit/WebKit/chromium/public/WebContextMenuData.h" | 19 #include "third_party/WebKit/WebKit/chromium/public/WebContextMenuData.h" |
20 #include "webkit/glue/context_menu.h" | 20 #include "webkit/glue/context_menu.h" |
21 | 21 |
(...skipping 117 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
139 params.page_url = page_url; | 139 params.page_url = page_url; |
140 params.link_url = link_url; | 140 params.link_url = link_url; |
141 TestRenderViewContextMenu* menu = | 141 TestRenderViewContextMenu* menu = |
142 new TestRenderViewContextMenu(tab_contents, params); | 142 new TestRenderViewContextMenu(tab_contents, params); |
143 menu->Init(); | 143 menu->Init(); |
144 return menu; | 144 return menu; |
145 } | 145 } |
146 | 146 |
147 // Shortcut to return the current ExtensionMenuManager. | 147 // Shortcut to return the current ExtensionMenuManager. |
148 ExtensionMenuManager* menu_manager() { | 148 ExtensionMenuManager* menu_manager() { |
149 return browser()->profile()->GetExtensionsService()->menu_manager(); | 149 return browser()->profile()->GetExtensionService()->menu_manager(); |
150 } | 150 } |
151 | 151 |
152 // Returns a pointer to the currently loaded extension with |name|, or null | 152 // Returns a pointer to the currently loaded extension with |name|, or null |
153 // if not found. | 153 // if not found. |
154 const Extension* GetExtensionNamed(std::string name) { | 154 const Extension* GetExtensionNamed(std::string name) { |
155 const ExtensionList* extensions = | 155 const ExtensionList* extensions = |
156 browser()->profile()->GetExtensionsService()->extensions(); | 156 browser()->profile()->GetExtensionService()->extensions(); |
157 ExtensionList::const_iterator i; | 157 ExtensionList::const_iterator i; |
158 for (i = extensions->begin(); i != extensions->end(); ++i) { | 158 for (i = extensions->begin(); i != extensions->end(); ++i) { |
159 if ((*i)->name() == name) { | 159 if ((*i)->name() == name) { |
160 return *i; | 160 return *i; |
161 } | 161 } |
162 } | 162 } |
163 return NULL; | 163 return NULL; |
164 } | 164 } |
165 | 165 |
166 // This gets all the items that any extension has registered for possible | 166 // This gets all the items that any extension has registered for possible |
(...skipping 254 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
421 // Wait for the extension's script to tell us its onclick fired. Ensure | 421 // Wait for the extension's script to tell us its onclick fired. Ensure |
422 // that the incognito version doesn't fire until we explicitly click the | 422 // that the incognito version doesn't fire until we explicitly click the |
423 // incognito menu item. | 423 // incognito menu item. |
424 ASSERT_TRUE(onclick.WaitUntilSatisfied()); | 424 ASSERT_TRUE(onclick.WaitUntilSatisfied()); |
425 EXPECT_FALSE(onclick_incognito.was_satisfied()); | 425 EXPECT_FALSE(onclick_incognito.was_satisfied()); |
426 | 426 |
427 ASSERT_TRUE(menu_incognito->IsCommandIdEnabled(command_id)); | 427 ASSERT_TRUE(menu_incognito->IsCommandIdEnabled(command_id)); |
428 menu_incognito->ExecuteCommand(command_id); | 428 menu_incognito->ExecuteCommand(command_id); |
429 ASSERT_TRUE(onclick_incognito.WaitUntilSatisfied()); | 429 ASSERT_TRUE(onclick_incognito.WaitUntilSatisfied()); |
430 } | 430 } |
OLD | NEW |