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

Side by Side Diff: chrome/browser/renderer_context_menu/render_view_context_menu.cc

Issue 1117893002: Moving extension code out of "components/" to avoid layering violations. (Closed) Base URL: https://chromium.googlesource.com/chromium/src.git@master
Patch Set: Changes as per review comments. Created 5 years, 7 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
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/renderer_context_menu/render_view_context_menu.h" 5 #include "chrome/browser/renderer_context_menu/render_view_context_menu.h"
6 6
7 #include <algorithm> 7 #include <algorithm>
8 #include <set> 8 #include <set>
9 #include <utility> 9 #include <utility>
10 10
(...skipping 285 matching lines...) Expand 10 before | Expand all | Expand 10 after
296 296
297 content::Referrer CreateSaveAsReferrer( 297 content::Referrer CreateSaveAsReferrer(
298 const GURL& url, 298 const GURL& url,
299 const content::ContextMenuParams& params) { 299 const content::ContextMenuParams& params) {
300 const GURL& referring_url = GetDocumentURL(params); 300 const GURL& referring_url = GetDocumentURL(params);
301 return content::Referrer::SanitizeForRequest( 301 return content::Referrer::SanitizeForRequest(
302 url, 302 url,
303 content::Referrer(referring_url.GetAsReferrer(), params.referrer_policy)); 303 content::Referrer(referring_url.GetAsReferrer(), params.referrer_policy));
304 } 304 }
305 305
306 content::WebContents* GetWebContentsToUse(content::WebContents* web_contents) {
307 // If we're viewing in a MimeHandlerViewGuest, use its embedder WebContents.
308 #if defined(ENABLE_EXTENSIONS)
309 WebContents* top_level_web_contents =
310 extensions::GuestViewBase::GetTopLevelWebContents(web_contents);
lazyboy 2015/05/05 05:16:16 GuestViewBase is too broad for this, I'd only use
Deepak 2015/05/05 06:28:22 Done.
311 if (top_level_web_contents)
312 return top_level_web_contents;
313 #endif
314 return web_contents;
315 }
316
306 bool g_custom_id_ranges_initialized = false; 317 bool g_custom_id_ranges_initialized = false;
307 318
308 const int kSpellcheckRadioGroup = 1; 319 const int kSpellcheckRadioGroup = 1;
309 320
310 } // namespace 321 } // namespace
311 322
312 // static 323 // static
313 gfx::Vector2d RenderViewContextMenu::GetOffset( 324 gfx::Vector2d RenderViewContextMenu::GetOffset(
314 RenderFrameHost* render_frame_host) { 325 RenderFrameHost* render_frame_host) {
315 gfx::Vector2d offset; 326 gfx::Vector2d offset;
(...skipping 27 matching lines...) Expand all
343 RenderViewContextMenu::RenderViewContextMenu( 354 RenderViewContextMenu::RenderViewContextMenu(
344 content::RenderFrameHost* render_frame_host, 355 content::RenderFrameHost* render_frame_host,
345 const content::ContextMenuParams& params) 356 const content::ContextMenuParams& params)
346 : RenderViewContextMenuBase(render_frame_host, params), 357 : RenderViewContextMenuBase(render_frame_host, params),
347 extension_items_(browser_context_, 358 extension_items_(browser_context_,
348 this, 359 this,
349 &menu_model_, 360 &menu_model_,
350 base::Bind(MenuItemMatchesParams, params_)), 361 base::Bind(MenuItemMatchesParams, params_)),
351 protocol_handler_submenu_model_(this), 362 protocol_handler_submenu_model_(this),
352 protocol_handler_registry_( 363 protocol_handler_registry_(
353 ProtocolHandlerRegistryFactory::GetForBrowserContext(GetProfile())) { 364 ProtocolHandlerRegistryFactory::GetForBrowserContext(GetProfile())),
365 embedder_web_contents_(GetWebContentsToUse(source_web_contents_)) {
354 if (!g_custom_id_ranges_initialized) { 366 if (!g_custom_id_ranges_initialized) {
355 g_custom_id_ranges_initialized = true; 367 g_custom_id_ranges_initialized = true;
356 SetContentCustomCommandIdRange(IDC_CONTENT_CONTEXT_CUSTOM_FIRST, 368 SetContentCustomCommandIdRange(IDC_CONTENT_CONTEXT_CUSTOM_FIRST,
357 IDC_CONTENT_CONTEXT_CUSTOM_LAST); 369 IDC_CONTENT_CONTEXT_CUSTOM_LAST);
358 } 370 }
359 set_content_type(ContextMenuContentTypeFactory::Create( 371 set_content_type(ContextMenuContentTypeFactory::Create(
360 source_web_contents_, params)); 372 source_web_contents_, params));
361 } 373 }
362 374
363 RenderViewContextMenu::~RenderViewContextMenu() { 375 RenderViewContextMenu::~RenderViewContextMenu() {
(...skipping 1473 matching lines...) Expand 10 before | Expand all | Expand 10 after
1837 source_web_contents_->GetRenderViewHost()-> 1849 source_web_contents_->GetRenderViewHost()->
1838 ExecuteMediaPlayerActionAtLocation(location, action); 1850 ExecuteMediaPlayerActionAtLocation(location, action);
1839 } 1851 }
1840 1852
1841 void RenderViewContextMenu::PluginActionAt( 1853 void RenderViewContextMenu::PluginActionAt(
1842 const gfx::Point& location, 1854 const gfx::Point& location,
1843 const WebPluginAction& action) { 1855 const WebPluginAction& action) {
1844 source_web_contents_->GetRenderViewHost()-> 1856 source_web_contents_->GetRenderViewHost()->
1845 ExecutePluginActionAtLocation(location, action); 1857 ExecutePluginActionAtLocation(location, action);
1846 } 1858 }
OLDNEW
« no previous file with comments | « chrome/browser/renderer_context_menu/render_view_context_menu.h ('k') | components/renderer_context_menu/DEPS » ('j') | no next file with comments »

Powered by Google App Engine
This is Rietveld 408576698