| 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/bookmarks/bookmark_context_menu_controller_vie
ws_win.h" | 5 #include "chrome/browser/ui/views/bookmarks/bookmark_context_menu_controller_vie
ws_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/bookmarks/bookmark_utils.h" | 8 #include "chrome/browser/bookmarks/bookmark_utils.h" |
| 10 #include "chrome/browser/profiles/profile.h" | 9 #include "chrome/browser/profiles/profile.h" |
| 11 #include "chrome/browser/ui/bookmarks/bookmark_utils.h" | 10 #include "chrome/browser/ui/bookmarks/bookmark_utils.h" |
| 12 #include "chrome/browser/ui/browser.h" | 11 #include "chrome/browser/ui/browser.h" |
| 13 #include "chrome/browser/ui/browser_finder.h" | 12 #include "chrome/browser/ui/browser_finder.h" |
| 14 #include "chrome/browser/ui/browser_tabstrip.h" | 13 #include "chrome/browser/ui/browser_tabstrip.h" |
| 15 #include "chrome/browser/ui/browser_window.h" | 14 #include "chrome/browser/ui/browser_window.h" |
| 16 #include "content/public/browser/page_navigator.h" | 15 #include "content/public/browser/page_navigator.h" |
| 17 #include "content/public/browser/user_metrics.h" | 16 #include "content/public/browser/user_metrics.h" |
| 18 #include "content/public/browser/web_contents.h" | 17 #include "content/public/browser/web_contents.h" |
| 19 #include "grit/generated_resources.h" | 18 #include "grit/generated_resources.h" |
| 20 #include "ui/views/widget/widget.h" | 19 #include "ui/views/widget/widget.h" |
| 20 #include "win8/util/win8_util.h" |
| 21 | 21 |
| 22 using content::OpenURLParams; | 22 using content::OpenURLParams; |
| 23 using content::UserMetricsAction; | 23 using content::UserMetricsAction; |
| 24 using content::WebContents; | 24 using content::WebContents; |
| 25 | 25 |
| 26 namespace { | 26 namespace { |
| 27 | 27 |
| 28 // A PageNavigator implementation that creates a new Browser. This is used when | 28 // A PageNavigator implementation that creates a new Browser. This is used when |
| 29 // opening a url and there is no Browser open. The Browser is created the first | 29 // opening a url and there is no Browser open. The Browser is created the first |
| 30 // time the PageNavigator method is invoked. | 30 // time the PageNavigator method is invoked. |
| (...skipping 56 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 87 : BookmarkContextMenuControllerViews(parent_widget, delegate, browser, | 87 : BookmarkContextMenuControllerViews(parent_widget, delegate, browser, |
| 88 profile, navigator, parent, | 88 profile, navigator, parent, |
| 89 selection) { | 89 selection) { |
| 90 } | 90 } |
| 91 | 91 |
| 92 BookmarkContextMenuControllerViewsWin | 92 BookmarkContextMenuControllerViewsWin |
| 93 ::~BookmarkContextMenuControllerViewsWin() { | 93 ::~BookmarkContextMenuControllerViewsWin() { |
| 94 } | 94 } |
| 95 | 95 |
| 96 void BookmarkContextMenuControllerViewsWin::ExecuteCommand(int id) { | 96 void BookmarkContextMenuControllerViewsWin::ExecuteCommand(int id) { |
| 97 if (base::win::IsMetroProcess()) { | 97 if (win8::IsSingleWindowMetroMode()) { |
| 98 switch (id) { | 98 switch (id) { |
| 99 // We need to handle the open in new window and open in incognito window | 99 // We need to handle the open in new window and open in incognito window |
| 100 // commands to ensure that they first look for an existing browser object | 100 // commands to ensure that they first look for an existing browser object |
| 101 // to handle the request. If we find one then a new foreground tab is | 101 // to handle the request. If we find one then a new foreground tab is |
| 102 // opened, else a new browser object is created. | 102 // opened, else a new browser object is created. |
| 103 case IDC_BOOKMARK_BAR_OPEN_ALL_NEW_WINDOW: | 103 case IDC_BOOKMARK_BAR_OPEN_ALL_NEW_WINDOW: |
| 104 case IDC_BOOKMARK_BAR_OPEN_ALL_INCOGNITO: { | 104 case IDC_BOOKMARK_BAR_OPEN_ALL_INCOGNITO: { |
| 105 Profile* profile_to_use = profile(); | 105 Profile* profile_to_use = profile(); |
| 106 if (id == IDC_BOOKMARK_BAR_OPEN_ALL_NEW_WINDOW) { | 106 if (id == IDC_BOOKMARK_BAR_OPEN_ALL_NEW_WINDOW) { |
| 107 if (profile_to_use->IsOffTheRecord()) | 107 if (profile_to_use->IsOffTheRecord()) |
| (...skipping 35 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 143 default: | 143 default: |
| 144 break; | 144 break; |
| 145 } | 145 } |
| 146 } | 146 } |
| 147 BookmarkContextMenuControllerViews::ExecuteCommand(id); | 147 BookmarkContextMenuControllerViews::ExecuteCommand(id); |
| 148 } | 148 } |
| 149 | 149 |
| 150 bool BookmarkContextMenuControllerViewsWin::IsCommandEnabled(int id) const { | 150 bool BookmarkContextMenuControllerViewsWin::IsCommandEnabled(int id) const { |
| 151 // In Windows 8 metro mode no new window option on a regular chrome window | 151 // In Windows 8 metro mode no new window option on a regular chrome window |
| 152 // and no new incognito window option on an incognito chrome window. | 152 // and no new incognito window option on an incognito chrome window. |
| 153 if (base::win::IsMetroProcess()) { | 153 if (win8::IsSingleWindowMetroMode()) { |
| 154 if (id == IDC_BOOKMARK_BAR_OPEN_ALL_NEW_WINDOW && | 154 if (id == IDC_BOOKMARK_BAR_OPEN_ALL_NEW_WINDOW && |
| 155 !profile()->IsOffTheRecord()) { | 155 !profile()->IsOffTheRecord()) { |
| 156 return false; | 156 return false; |
| 157 } else if (id == IDC_BOOKMARK_BAR_OPEN_ALL_INCOGNITO && | 157 } else if (id == IDC_BOOKMARK_BAR_OPEN_ALL_INCOGNITO && |
| 158 profile()->IsOffTheRecord()) { | 158 profile()->IsOffTheRecord()) { |
| 159 return false; | 159 return false; |
| 160 } | 160 } |
| 161 } | 161 } |
| 162 return BookmarkContextMenuControllerViews::IsCommandEnabled(id); | 162 return BookmarkContextMenuControllerViews::IsCommandEnabled(id); |
| 163 } | 163 } |
| OLD | NEW |