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

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

Issue 2232353002: Call GetBrowser() from RenderViewContextMenu::IsRouteMediaEnabled() (Closed) Base URL: https://chromium.googlesource.com/chromium/src.git@master
Patch Set: Address Istiaque's comment Created 4 years, 4 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 | « no previous file | 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/renderer_context_menu/render_view_context_menu.h" 5 #include "chrome/browser/renderer_context_menu/render_view_context_menu.h"
6 6
7 #include <stddef.h> 7 #include <stddef.h>
8 8
9 #include <algorithm> 9 #include <algorithm>
10 #include <set> 10 #include <set>
(...skipping 2080 matching lines...) Expand 10 before | Expand all | Expand 10 after
2091 } 2091 }
2092 2092
2093 Browser* browser = GetBrowser(); 2093 Browser* browser = GetBrowser();
2094 return browser && chrome::CanPrint(browser); 2094 return browser && chrome::CanPrint(browser);
2095 } 2095 }
2096 2096
2097 bool RenderViewContextMenu::IsRouteMediaEnabled() const { 2097 bool RenderViewContextMenu::IsRouteMediaEnabled() const {
2098 if (!media_router::MediaRouterEnabled(browser_context_)) 2098 if (!media_router::MediaRouterEnabled(browser_context_))
2099 return false; 2099 return false;
2100 2100
2101 Browser* browser = chrome::FindBrowserWithWebContents(source_web_contents_); 2101 Browser* browser = GetBrowser();
2102 if (!browser) 2102 if (!browser)
2103 return false; 2103 return false;
2104 2104
2105 // Disable the command if there is an active modal dialog. 2105 // Disable the command if there is an active modal dialog.
2106 // We don't use |source_web_contents_| here because it could be the 2106 // We don't use |source_web_contents_| here because it could be the
2107 // WebContents for something that's not the current tab (e.g., WebUI 2107 // WebContents for something that's not the current tab (e.g., WebUI
2108 // modal dialog). 2108 // modal dialog).
2109 WebContents* web_contents = 2109 WebContents* web_contents =
2110 browser->tab_strip_model()->GetActiveWebContents(); 2110 browser->tab_strip_model()->GetActiveWebContents();
2111 if (!web_contents) 2111 if (!web_contents)
(...skipping 258 matching lines...) Expand 10 before | Expand all | Expand 10 after
2370 GetPrefs(browser_context_)->GetBoolean(prefs::kPrintPreviewDisabled), 2370 GetPrefs(browser_context_)->GetBoolean(prefs::kPrintPreviewDisabled),
2371 !params_.selection_text.empty()); 2371 !params_.selection_text.empty());
2372 #endif // defined(ENABLE_PRINTING) 2372 #endif // defined(ENABLE_PRINTING)
2373 } 2373 }
2374 2374
2375 void RenderViewContextMenu::ExecRouteMedia() { 2375 void RenderViewContextMenu::ExecRouteMedia() {
2376 #if defined(ENABLE_MEDIA_ROUTER) 2376 #if defined(ENABLE_MEDIA_ROUTER)
2377 if (!media_router::MediaRouterEnabled(browser_context_)) 2377 if (!media_router::MediaRouterEnabled(browser_context_))
2378 return; 2378 return;
2379 2379
2380 Browser* browser =
2381 chrome::FindBrowserWithWebContents(source_web_contents_);
2382 DCHECK(browser);
2383
2384 media_router::MediaRouterDialogController* dialog_controller = 2380 media_router::MediaRouterDialogController* dialog_controller =
2385 media_router::MediaRouterDialogController::GetOrCreateForWebContents( 2381 media_router::MediaRouterDialogController::GetOrCreateForWebContents(
2386 source_web_contents_); 2382 embedder_web_contents_);
2387 if (!dialog_controller) 2383 if (!dialog_controller)
2388 return; 2384 return;
2389 2385
2390 dialog_controller->ShowMediaRouterDialog(); 2386 dialog_controller->ShowMediaRouterDialog();
2391 media_router::MediaRouterMetrics::RecordMediaRouterDialogOrigin( 2387 media_router::MediaRouterMetrics::RecordMediaRouterDialogOrigin(
2392 media_router::MediaRouterDialogOpenOrigin::CONTEXTUAL_MENU); 2388 media_router::MediaRouterDialogOpenOrigin::CONTEXTUAL_MENU);
2393 #endif // defined(ENABLE_MEDIA_ROUTER) 2389 #endif // defined(ENABLE_MEDIA_ROUTER)
2394 } 2390 }
2395 2391
2396 void RenderViewContextMenu::ExecTranslate() { 2392 void RenderViewContextMenu::ExecTranslate() {
(...skipping 56 matching lines...) Expand 10 before | Expand all | Expand 10 after
2453 void RenderViewContextMenu::PluginActionAt( 2449 void RenderViewContextMenu::PluginActionAt(
2454 const gfx::Point& location, 2450 const gfx::Point& location,
2455 const WebPluginAction& action) { 2451 const WebPluginAction& action) {
2456 source_web_contents_->GetRenderViewHost()-> 2452 source_web_contents_->GetRenderViewHost()->
2457 ExecutePluginActionAtLocation(location, action); 2453 ExecutePluginActionAtLocation(location, action);
2458 } 2454 }
2459 2455
2460 Browser* RenderViewContextMenu::GetBrowser() const { 2456 Browser* RenderViewContextMenu::GetBrowser() const {
2461 return chrome::FindBrowserWithWebContents(embedder_web_contents_); 2457 return chrome::FindBrowserWithWebContents(embedder_web_contents_);
2462 } 2458 }
OLDNEW
« no previous file with comments | « no previous file | no next file » | no next file with comments »

Powered by Google App Engine
This is Rietveld 408576698