This source file includes following definitions.
- Create
- IsCommandIdVisible
- ExecuteCommand
#include "chrome/browser/ui/views/renderer_context_menu/render_view_context_menu_win.h"
#include "chrome/app/chrome_command_ids.h"
#include "chrome/browser/chrome_notification_types.h"
#include "chrome/browser/profiles/profile.h"
#include "chrome/browser/tab_contents/retargeting_details.h"
#include "chrome/browser/ui/browser_finder.h"
#include "chrome/browser/ui/tabs/tab_strip_model.h"
#include "content/public/browser/web_contents.h"
#include "win8/util/win8_util.h"
using content::WebContents;
RenderViewContextMenuWin::RenderViewContextMenuWin(
content::RenderFrameHost* render_frame_host,
const content::ContextMenuParams& params)
: RenderViewContextMenuViews(render_frame_host, params) {
}
RenderViewContextMenuWin::~RenderViewContextMenuWin() {
}
RenderViewContextMenuViews* RenderViewContextMenuViews::Create(
content::RenderFrameHost* render_frame_host,
const content::ContextMenuParams& params) {
return new RenderViewContextMenuWin(render_frame_host, params);
}
bool RenderViewContextMenuWin::IsCommandIdVisible(int command_id) const {
if (win8::IsSingleWindowMetroMode() && !profile_->IsOffTheRecord() &&
command_id == IDC_CONTENT_CONTEXT_OPENLINKNEWWINDOW) {
return false;
}
return RenderViewContextMenu::IsCommandIdVisible(command_id);
}
void RenderViewContextMenuWin::ExecuteCommand(int command_id,
int event_flags) {
if (win8::IsSingleWindowMetroMode() &&
command_id == IDC_CONTENT_CONTEXT_OPENLINKNEWWINDOW) {
DCHECK(profile_->IsOffTheRecord());
Browser* browser =
chrome::FindTabbedBrowser(profile_->GetOriginalProfile(),
false,
chrome::HOST_DESKTOP_TYPE_NATIVE);
if (browser) {
content::OpenURLParams url_params(
params_.link_url,
content::Referrer(params_.frame_url.is_empty() ?
params_.page_url : params_.frame_url,
params_.referrer_policy),
NEW_FOREGROUND_TAB,
content::PAGE_TRANSITION_LINK,
false);
WebContents* source_web_contents =
browser->tab_strip_model()->GetActiveWebContents();
WebContents* new_contents = source_web_contents->OpenURL(url_params);
DCHECK(new_contents);
return;
}
}
RenderViewContextMenu::ExecuteCommand(command_id, event_flags);
}