Chromium Code Reviews
chromiumcodereview-hr@appspot.gserviceaccount.com (chromiumcodereview-hr) | Please choose your nickname with Settings | Help | Chromium Project | Gerrit Changes | Sign out
(362)

Side by Side Diff: chrome/browser/extensions/extension_context_menu_browsertest.cc

Issue 130773004: Start moving context menu code to RenderFrame. (Closed) Base URL: svn://chrome-svn/chrome/trunk/src/
Patch Set: Created 6 years, 10 months ago
Use n/p to move between diff chunks; N/P to move between comments. Draft comments are only viewable by you.
Jump to:
View unified diff | Download patch | Annotate | Revision Log
OLDNEW
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_test_message_listener.h" 9 #include "chrome/browser/extensions/extension_test_message_listener.h"
10 #include "chrome/browser/extensions/lazy_background_page_test_util.h" 10 #include "chrome/browser/extensions/lazy_background_page_test_util.h"
(...skipping 13 matching lines...) Expand all
24 using content::WebContents; 24 using content::WebContents;
25 using extensions::MenuItem; 25 using extensions::MenuItem;
26 using ui::MenuModel; 26 using ui::MenuModel;
27 27
28 namespace { 28 namespace {
29 // 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
30 // real context menu, while still running through the actual code in 30 // real context menu, while still running through the actual code in
31 // RenderViewContextMenu where extension items get added and executed. 31 // RenderViewContextMenu where extension items get added and executed.
32 class TestRenderViewContextMenu : public RenderViewContextMenu { 32 class TestRenderViewContextMenu : public RenderViewContextMenu {
33 public: 33 public:
34 TestRenderViewContextMenu(WebContents* web_contents, 34 TestRenderViewContextMenu(content::RenderFrameHost* render_frame_host,
35 const content::ContextMenuParams& params) 35 const content::ContextMenuParams& params)
36 : RenderViewContextMenu(web_contents, params) {} 36 : RenderViewContextMenu(render_frame_host, params) {}
37 37
38 virtual ~TestRenderViewContextMenu() {} 38 virtual ~TestRenderViewContextMenu() {}
39 39
40 // Searches for an menu item with |command_id|. If it's found, the return 40 // Searches for an menu item with |command_id|. If it's found, the return
41 // value is true and the model and index where it appears in that model are 41 // value is true and the model and index where it appears in that model are
42 // returned in |found_model| and |found_index|. Otherwise returns false. 42 // returned in |found_model| and |found_index|. Otherwise returns false.
43 bool GetMenuModelAndItemIndex(int command_id, 43 bool GetMenuModelAndItemIndex(int command_id,
44 MenuModel** found_model, 44 MenuModel** found_model,
45 int *found_index) { 45 int *found_index) {
46 std::vector<MenuModel*> models_to_search; 46 std::vector<MenuModel*> models_to_search;
(...skipping 67 matching lines...) Expand 10 before | Expand all | Expand 10 after
114 const GURL& page_url, 114 const GURL& page_url,
115 const GURL& link_url, 115 const GURL& link_url,
116 const GURL& frame_url) { 116 const GURL& frame_url) {
117 WebContents* web_contents = 117 WebContents* web_contents =
118 browser->tab_strip_model()->GetActiveWebContents(); 118 browser->tab_strip_model()->GetActiveWebContents();
119 content::ContextMenuParams params; 119 content::ContextMenuParams params;
120 params.page_url = page_url; 120 params.page_url = page_url;
121 params.link_url = link_url; 121 params.link_url = link_url;
122 params.frame_url = frame_url; 122 params.frame_url = frame_url;
123 TestRenderViewContextMenu* menu = 123 TestRenderViewContextMenu* menu =
124 new TestRenderViewContextMenu(web_contents, params); 124 new TestRenderViewContextMenu(web_contents->GetMainFrame(), params);
125 menu->Init(); 125 menu->Init();
126 return menu; 126 return menu;
127 } 127 }
128 128
129 // Shortcut to return the current MenuManager. 129 // Shortcut to return the current MenuManager.
130 extensions::MenuManager* menu_manager() { 130 extensions::MenuManager* menu_manager() {
131 return extensions::MenuManager::Get(browser()->profile()); 131 return extensions::MenuManager::Get(browser()->profile());
132 } 132 }
133 133
134 // 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
(...skipping 525 matching lines...) Expand 10 before | Expand all | Expand 10 after
660 ASSERT_TRUE(LoadContextMenuExtensionIncognito("incognito")); 660 ASSERT_TRUE(LoadContextMenuExtensionIncognito("incognito"));
661 661
662 // 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.
663 ASSERT_TRUE(created.WaitUntilSatisfied()); 663 ASSERT_TRUE(created.WaitUntilSatisfied());
664 ASSERT_TRUE(created_incognito.WaitUntilSatisfied()); 664 ASSERT_TRUE(created_incognito.WaitUntilSatisfied());
665 ASSERT_EQ(2u, GetItems().size()); 665 ASSERT_EQ(2u, GetItems().size());
666 666
667 browser()->profile()->DestroyOffTheRecordProfile(); 667 browser()->profile()->DestroyOffTheRecordProfile();
668 ASSERT_EQ(1u, GetItems().size()); 668 ASSERT_EQ(1u, GetItems().size());
669 } 669 }
OLDNEW

Powered by Google App Engine
This is Rietveld 408576698