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/ui/views/tab_contents/render_view_context_menu_win.h" | 5 #include "chrome/browser/ui/views/tab_contents/render_view_context_menu_win.h" |
6 | 6 |
7 #include "base/win/metro.h" | |
8 #include "chrome/app/chrome_command_ids.h" | 7 #include "chrome/app/chrome_command_ids.h" |
9 #include "chrome/browser/profiles/profile.h" | 8 #include "chrome/browser/profiles/profile.h" |
10 #include "chrome/browser/tab_contents/retargeting_details.h" | 9 #include "chrome/browser/tab_contents/retargeting_details.h" |
11 #include "chrome/browser/ui/browser_finder.h" | 10 #include "chrome/browser/ui/browser_finder.h" |
12 #include "chrome/browser/ui/browser_tabstrip.h" | 11 #include "chrome/browser/ui/browser_tabstrip.h" |
13 #include "chrome/common/chrome_notification_types.h" | 12 #include "chrome/common/chrome_notification_types.h" |
14 #include "content/public/browser/web_contents.h" | 13 #include "content/public/browser/web_contents.h" |
| 14 #include "win8/util/win8_util.h" |
15 | 15 |
16 using content::WebContents; | 16 using content::WebContents; |
17 | 17 |
18 RenderViewContextMenuWin::RenderViewContextMenuWin( | 18 RenderViewContextMenuWin::RenderViewContextMenuWin( |
19 WebContents* web_contents, | 19 WebContents* web_contents, |
20 const content::ContextMenuParams& params) | 20 const content::ContextMenuParams& params) |
21 : RenderViewContextMenuViews(web_contents, params) { | 21 : RenderViewContextMenuViews(web_contents, params) { |
22 } | 22 } |
23 | 23 |
24 RenderViewContextMenuWin::~RenderViewContextMenuWin() { | 24 RenderViewContextMenuWin::~RenderViewContextMenuWin() { |
25 } | 25 } |
26 | 26 |
27 // static | 27 // static |
28 RenderViewContextMenuViews* RenderViewContextMenuViews::Create( | 28 RenderViewContextMenuViews* RenderViewContextMenuViews::Create( |
29 content::WebContents* tab_contents, | 29 content::WebContents* tab_contents, |
30 const content::ContextMenuParams& params) { | 30 const content::ContextMenuParams& params) { |
31 return new RenderViewContextMenuWin(tab_contents, params); | 31 return new RenderViewContextMenuWin(tab_contents, params); |
32 } | 32 } |
33 | 33 |
34 bool RenderViewContextMenuWin::IsCommandIdVisible(int command_id) const { | 34 bool RenderViewContextMenuWin::IsCommandIdVisible(int command_id) const { |
35 // In windows 8 metro mode no new window option on normal browser windows. | 35 // In windows 8 metro mode no new window option on normal browser windows. |
36 if (base::win::IsMetroProcess() && !profile_->IsOffTheRecord() && | 36 if (win8::IsSingleWindowMetroMode() && !profile_->IsOffTheRecord() && |
37 command_id == IDC_CONTENT_CONTEXT_OPENLINKNEWWINDOW) { | 37 command_id == IDC_CONTENT_CONTEXT_OPENLINKNEWWINDOW) { |
38 return false; | 38 return false; |
39 } | 39 } |
40 return RenderViewContextMenu::IsCommandIdVisible(command_id); | 40 return RenderViewContextMenu::IsCommandIdVisible(command_id); |
41 } | 41 } |
42 | 42 |
43 void RenderViewContextMenuWin::ExecuteCommand(int command_id) { | 43 void RenderViewContextMenuWin::ExecuteCommand(int command_id) { |
44 ExecuteCommand(command_id, 0); | 44 ExecuteCommand(command_id, 0); |
45 } | 45 } |
46 | 46 |
47 void RenderViewContextMenuWin::ExecuteCommand(int command_id, | 47 void RenderViewContextMenuWin::ExecuteCommand(int command_id, |
48 int event_flags) { | 48 int event_flags) { |
49 if (base::win::IsMetroProcess() && | 49 if (win8::IsSingleWindowMetroMode() && |
50 command_id == IDC_CONTENT_CONTEXT_OPENLINKNEWWINDOW) { | 50 command_id == IDC_CONTENT_CONTEXT_OPENLINKNEWWINDOW) { |
51 // The open link in new window command should only be enabled for | 51 // The open link in new window command should only be enabled for |
52 // incognito windows in metro mode. | 52 // incognito windows in metro mode. |
53 DCHECK(profile_->IsOffTheRecord()); | 53 DCHECK(profile_->IsOffTheRecord()); |
54 // We directly go to the Browser object to open the url in effect | 54 // We directly go to the Browser object to open the url in effect |
55 // bypassing the delegate. Currently the Browser is the only class which | 55 // bypassing the delegate. Currently the Browser is the only class which |
56 // implements the delegate for the context menu. This would break if there | 56 // implements the delegate for the context menu. This would break if there |
57 // are other delegates for the context menu. This is ok for now as this | 57 // are other delegates for the context menu. This is ok for now as this |
58 // code only executes for Windows 8 metro mode. | 58 // code only executes for Windows 8 metro mode. |
59 // TODO(robertshield): FTB - Switch this to HOST_DESKTOP_TYPE_ASH when | 59 // TODO(robertshield): FTB - Switch this to HOST_DESKTOP_TYPE_ASH when |
(...skipping 16 matching lines...) Expand all Loading... |
76 DCHECK(new_contents); | 76 DCHECK(new_contents); |
77 return; | 77 return; |
78 } | 78 } |
79 } | 79 } |
80 RenderViewContextMenu::ExecuteCommand(command_id, event_flags); | 80 RenderViewContextMenu::ExecuteCommand(command_id, event_flags); |
81 } | 81 } |
82 | 82 |
83 void RenderViewContextMenuWin::SetExternal() { | 83 void RenderViewContextMenuWin::SetExternal() { |
84 external_ = true; | 84 external_ = true; |
85 } | 85 } |
OLD | NEW |