| OLD | NEW |
| 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 "chrome/browser/tab_contents/render_view_context_menu_win.h" | 5 #include "chrome/browser/tab_contents/render_view_context_menu_win.h" |
| 6 | 6 |
| 7 #include "base/win/metro.h" | 7 #include "base/win/metro.h" |
| 8 #include "chrome/app/chrome_command_ids.h" | 8 #include "chrome/app/chrome_command_ids.h" |
| 9 #include "chrome/browser/profiles/profile.h" | 9 #include "chrome/browser/profiles/profile.h" |
| 10 #include "chrome/browser/tab_contents/retargeting_details.h" | 10 #include "chrome/browser/tab_contents/retargeting_details.h" |
| (...skipping 14 matching lines...) Expand all Loading... |
| 25 | 25 |
| 26 // static | 26 // static |
| 27 RenderViewContextMenuViews* RenderViewContextMenuViews::Create( | 27 RenderViewContextMenuViews* RenderViewContextMenuViews::Create( |
| 28 content::WebContents* tab_contents, | 28 content::WebContents* tab_contents, |
| 29 const content::ContextMenuParams& params) { | 29 const content::ContextMenuParams& params) { |
| 30 return new RenderViewContextMenuWin(tab_contents, params); | 30 return new RenderViewContextMenuWin(tab_contents, params); |
| 31 } | 31 } |
| 32 | 32 |
| 33 bool RenderViewContextMenuWin::IsCommandIdVisible(int command_id) const { | 33 bool RenderViewContextMenuWin::IsCommandIdVisible(int command_id) const { |
| 34 // In windows 8 metro mode no new window option on normal browser windows. | 34 // In windows 8 metro mode no new window option on normal browser windows. |
| 35 if (base::win::GetMetroModule() && !profile_->IsOffTheRecord() && | 35 if (base::win::IsMetroProcess() && !profile_->IsOffTheRecord() && |
| 36 command_id == IDC_CONTENT_CONTEXT_OPENLINKNEWWINDOW) { | 36 command_id == IDC_CONTENT_CONTEXT_OPENLINKNEWWINDOW) { |
| 37 return false; | 37 return false; |
| 38 } | 38 } |
| 39 return RenderViewContextMenu::IsCommandIdVisible(command_id); | 39 return RenderViewContextMenu::IsCommandIdVisible(command_id); |
| 40 } | 40 } |
| 41 | 41 |
| 42 void RenderViewContextMenuWin::ExecuteCommand(int command_id) { | 42 void RenderViewContextMenuWin::ExecuteCommand(int command_id) { |
| 43 ExecuteCommand(command_id, 0); | 43 ExecuteCommand(command_id, 0); |
| 44 } | 44 } |
| 45 | 45 |
| 46 void RenderViewContextMenuWin::ExecuteCommand(int command_id, | 46 void RenderViewContextMenuWin::ExecuteCommand(int command_id, |
| 47 int event_flags) { | 47 int event_flags) { |
| 48 if (base::win::GetMetroModule() && | 48 if (base::win::IsMetroProcess() && |
| 49 command_id == IDC_CONTENT_CONTEXT_OPENLINKNEWWINDOW) { | 49 command_id == IDC_CONTENT_CONTEXT_OPENLINKNEWWINDOW) { |
| 50 // The open link in new window command should only be enabled for | 50 // The open link in new window command should only be enabled for |
| 51 // incognito windows in metro mode. | 51 // incognito windows in metro mode. |
| 52 DCHECK(profile_->IsOffTheRecord()); | 52 DCHECK(profile_->IsOffTheRecord()); |
| 53 // We directly go to the Browser object to open the url in effect | 53 // We directly go to the Browser object to open the url in effect |
| 54 // bypassing the delegate. Currently the Browser is the only class which | 54 // bypassing the delegate. Currently the Browser is the only class which |
| 55 // implements the delegate for the context menu. This would break if there | 55 // implements the delegate for the context menu. This would break if there |
| 56 // are other delegates for the context menu. This is ok for now as this | 56 // are other delegates for the context menu. This is ok for now as this |
| 57 // code only executes for Windows 8 metro mode. | 57 // code only executes for Windows 8 metro mode. |
| 58 Browser* browser = browser::FindTabbedBrowser( | 58 Browser* browser = browser::FindTabbedBrowser( |
| (...skipping 12 matching lines...) Expand all Loading... |
| 71 DCHECK(new_contents); | 71 DCHECK(new_contents); |
| 72 return; | 72 return; |
| 73 } | 73 } |
| 74 } | 74 } |
| 75 RenderViewContextMenu::ExecuteCommand(command_id, event_flags); | 75 RenderViewContextMenu::ExecuteCommand(command_id, event_flags); |
| 76 } | 76 } |
| 77 | 77 |
| 78 void RenderViewContextMenuWin::SetExternal() { | 78 void RenderViewContextMenuWin::SetExternal() { |
| 79 external_ = true; | 79 external_ = true; |
| 80 } | 80 } |
| OLD | NEW |