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

Side by Side Diff: chrome/browser/guest_view/extension_options/extension_options_guest.cc

Issue 510993002: Fix the context menu positioning for ExtensionOptionsGuest (Closed) Base URL: https://chromium.googlesource.com/chromium/src.git@master
Patch Set: Created 6 years, 3 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
« no previous file with comments | « chrome/browser/guest_view/extension_options/extension_options_guest.h ('k') | no next file » | no next file with comments »
Toggle Intra-line Diffs ('i') | Expand Comments ('e') | Collapse Comments ('c') | Show Comments Hide Comments ('s')
OLDNEW
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/guest_view/extension_options/extension_options_guest.h" 5 #include "chrome/browser/guest_view/extension_options/extension_options_guest.h"
6 6
7 #include "base/values.h" 7 #include "base/values.h"
8 #include "chrome/browser/extensions/chrome_extension_web_contents_observer.h" 8 #include "chrome/browser/extensions/chrome_extension_web_contents_observer.h"
9 #include "chrome/browser/extensions/extension_tab_util.h" 9 #include "chrome/browser/extensions/extension_tab_util.h"
10 #include "chrome/browser/guest_view/extension_options/extension_options_constant s.h" 10 #include "chrome/browser/guest_view/extension_options/extension_options_constant s.h"
11 #include "chrome/browser/profiles/profile.h" 11 #include "chrome/browser/profiles/profile.h"
12 #include "chrome/browser/renderer_context_menu/render_view_context_menu.h"
12 #include "chrome/browser/ui/browser.h" 13 #include "chrome/browser/ui/browser.h"
13 #include "chrome/browser/ui/browser_finder.h" 14 #include "chrome/browser/ui/browser_finder.h"
14 #include "chrome/browser/ui/browser_window.h" 15 #include "chrome/browser/ui/browser_window.h"
15 #include "chrome/browser/ui/tabs/tab_strip_model.h" 16 #include "chrome/browser/ui/tabs/tab_strip_model.h"
16 #include "chrome/common/extensions/api/extension_options_internal.h" 17 #include "chrome/common/extensions/api/extension_options_internal.h"
17 #include "chrome/common/extensions/manifest_url_handler.h" 18 #include "chrome/common/extensions/manifest_url_handler.h"
18 #include "components/crx_file/id_util.h" 19 #include "components/crx_file/id_util.h"
20 #include "components/renderer_context_menu/context_menu_delegate.h"
19 #include "content/public/browser/render_process_host.h" 21 #include "content/public/browser/render_process_host.h"
20 #include "content/public/browser/site_instance.h" 22 #include "content/public/browser/site_instance.h"
21 #include "content/public/browser/web_contents.h" 23 #include "content/public/browser/web_contents.h"
22 #include "extensions/browser/extension_function_dispatcher.h" 24 #include "extensions/browser/extension_function_dispatcher.h"
23 #include "extensions/browser/extension_registry.h" 25 #include "extensions/browser/extension_registry.h"
24 #include "extensions/browser/guest_view/guest_view_manager.h" 26 #include "extensions/browser/guest_view/guest_view_manager.h"
25 #include "extensions/common/extension.h" 27 #include "extensions/common/extension.h"
26 #include "extensions/common/extension_messages.h" 28 #include "extensions/common/extension_messages.h"
27 #include "extensions/common/feature_switch.h" 29 #include "extensions/common/feature_switch.h"
28 #include "extensions/common/permissions/permissions_data.h" 30 #include "extensions/common/permissions/permissions_data.h"
(...skipping 157 matching lines...) Expand 10 before | Expand all | Expand 10 after
186 SetAutoSize( 188 SetAutoSize(
187 true, gfx::Size(min_width, min_height), gfx::Size(max_width, max_height)); 189 true, gfx::Size(min_width, min_height), gfx::Size(max_width, max_height));
188 } 190 }
189 191
190 void ExtensionOptionsGuest::CloseContents(content::WebContents* source) { 192 void ExtensionOptionsGuest::CloseContents(content::WebContents* source) {
191 DispatchEventToEmbedder(new extensions::GuestViewBase::Event( 193 DispatchEventToEmbedder(new extensions::GuestViewBase::Event(
192 extension_options_internal::OnClose::kEventName, 194 extension_options_internal::OnClose::kEventName,
193 make_scoped_ptr(new base::DictionaryValue()))); 195 make_scoped_ptr(new base::DictionaryValue())));
194 } 196 }
195 197
198 bool ExtensionOptionsGuest::HandleContextMenu(
199 const content::ContextMenuParams& params) {
Fady Samuel 2014/08/27 22:19:10 Could you move this code to GuestViewBase, and del
Fady Samuel 2014/08/27 22:19:54 Actually, nm, I forgot GuestViewBase moved to exte
200 ContextMenuDelegate* menu_delegate =
201 ContextMenuDelegate::FromWebContents(guest_web_contents());
202 DCHECK(menu_delegate);
203
204 scoped_ptr<RenderViewContextMenu> menu =
205 menu_delegate->BuildMenu(guest_web_contents(), params);
206 menu_delegate->ShowMenu(menu.Pass());
207 return true;
208 }
209
196 bool ExtensionOptionsGuest::ShouldCreateWebContents( 210 bool ExtensionOptionsGuest::ShouldCreateWebContents(
197 content::WebContents* web_contents, 211 content::WebContents* web_contents,
198 int route_id, 212 int route_id,
199 WindowContainerType window_container_type, 213 WindowContainerType window_container_type,
200 const base::string16& frame_name, 214 const base::string16& frame_name,
201 const GURL& target_url, 215 const GURL& target_url,
202 const std::string& partition_id, 216 const std::string& partition_id,
203 content::SessionStorageNamespace* session_storage_namespace) { 217 content::SessionStorageNamespace* session_storage_namespace) {
204 // This method handles opening links from within the guest. Since this guest 218 // This method handles opening links from within the guest. Since this guest
205 // view is used for displaying embedded extension options, we want any 219 // view is used for displaying embedded extension options, we want any
206 // external links to be opened in a new tab, not in a new guest view. 220 // external links to be opened in a new tab, not in a new guest view.
207 // Therefore we just open the URL in a new tab, and since we aren't handling 221 // Therefore we just open the URL in a new tab, and since we aren't handling
208 // the new web contents, we return false. 222 // the new web contents, we return false.
209 Browser* browser = 223 Browser* browser =
210 chrome::FindBrowserWithWebContents(embedder_web_contents()); 224 chrome::FindBrowserWithWebContents(embedder_web_contents());
211 content::OpenURLParams params(target_url, 225 content::OpenURLParams params(target_url,
212 content::Referrer(), 226 content::Referrer(),
213 NEW_FOREGROUND_TAB, 227 NEW_FOREGROUND_TAB,
214 content::PAGE_TRANSITION_LINK, 228 content::PAGE_TRANSITION_LINK,
215 false); 229 false);
216 browser->OpenURL(params); 230 browser->OpenURL(params);
217 // TODO(ericzeng): Open the tab in the background if the click was a 231 // TODO(ericzeng): Open the tab in the background if the click was a
218 // ctrl-click or middle mouse button click 232 // ctrl-click or middle mouse button click
219 return false; 233 return false;
220 } 234 }
OLDNEW
« no previous file with comments | « chrome/browser/guest_view/extension_options/extension_options_guest.h ('k') | no next file » | no next file with comments »

Powered by Google App Engine
This is Rietveld 408576698