summaryrefslogtreecommitdiffstats
diff options
context:
space:
mode:
authoracolwell@chromium.org <acolwell@chromium.org@0039d316-1c4b-4281-b951-d872f2087c98>2012-06-04 23:48:09 +0000
committeracolwell@chromium.org <acolwell@chromium.org@0039d316-1c4b-4281-b951-d872f2087c98>2012-06-04 23:48:09 +0000
commit2544cbb6491bd95c76e477b8777496c966c7db9d (patch)
tree106b3acfb21444f6236f618b29d83050978bb96c
parentc564ba125806be99271dbd6ce3a6f70f6170c6c1 (diff)
downloadchromium_src-2544cbb6491bd95c76e477b8777496c966c7db9d.zip
chromium_src-2544cbb6491bd95c76e477b8777496c966c7db9d.tar.gz
chromium_src-2544cbb6491bd95c76e477b8777496c966c7db9d.tar.bz2
Revert 140426 - Ensure that the new window context menu option does not show up in windows 8 metro mode.
Reverted because it breaks ChromeOS builds. When the new window option is executed from the incognito window, we find an existing normal browser window and open the url in a new tab. BUG=124404 R=sky Review URL: https://chromiumcodereview.appspot.com/10442119 TBR=ananta@chromium.org Review URL: https://chromiumcodereview.appspot.com/10529003 git-svn-id: svn://svn.chromium.org/chrome/trunk/src@140432 0039d316-1c4b-4281-b951-d872f2087c98
-rw-r--r--chrome/browser/external_tab/external_tab_container_win.cc9
-rw-r--r--chrome/browser/tab_contents/render_view_context_menu_win.cc80
-rw-r--r--chrome/browser/tab_contents/render_view_context_menu_win.h35
-rw-r--r--chrome/browser/ui/views/tab_contents/chrome_web_contents_view_delegate_views.cc3
-rw-r--r--chrome/browser/ui/views/tab_contents/render_view_context_menu_views.cc15
-rw-r--r--chrome/browser/ui/views/tab_contents/render_view_context_menu_views.h16
-rw-r--r--chrome/chrome_browser.gypi2
-rw-r--r--ui/views/controls/menu/menu_model_adapter.cc6
8 files changed, 21 insertions, 145 deletions
diff --git a/chrome/browser/external_tab/external_tab_container_win.cc b/chrome/browser/external_tab/external_tab_container_win.cc
index 227c656..9c06ad8 100644
--- a/chrome/browser/external_tab/external_tab_container_win.cc
+++ b/chrome/browser/external_tab/external_tab_container_win.cc
@@ -26,7 +26,6 @@
#include "chrome/browser/infobars/infobar_tab_helper.h"
#include "chrome/browser/profiles/profile.h"
#include "chrome/browser/repost_form_warning_controller.h"
-#include "chrome/browser/tab_contents/render_view_context_menu_win.h"
#include "chrome/browser/themes/theme_service.h"
#include "chrome/browser/ui/app_modal_dialogs/javascript_dialog_creator.h"
#include "chrome/browser/ui/blocked_content/blocked_content_tab_helper.h"
@@ -35,6 +34,7 @@
#include "chrome/browser/ui/browser_window.h"
#include "chrome/browser/ui/tab_contents/tab_contents_wrapper.h"
#include "chrome/browser/ui/views/infobars/infobar_container_view.h"
+#include "chrome/browser/ui/views/tab_contents/render_view_context_menu_views.h"
#include "chrome/common/automation_messages.h"
#include "chrome/common/chrome_constants.h"
#include "chrome/common/chrome_notification_types.h"
@@ -625,10 +625,9 @@ bool ExternalTabContainer::HandleContextMenu(
NOTREACHED();
return false;
}
- external_context_menu_.reset(RenderViewContextMenuViews::Create(
- web_contents(), params));
- static_cast<RenderViewContextMenuWin*>(
- external_context_menu_.get())->SetExternal();
+ external_context_menu_.reset(
+ new RenderViewContextMenuViews(web_contents(), params));
+ external_context_menu_->SetExternal();
external_context_menu_->Init();
external_context_menu_->UpdateMenuItemStates();
diff --git a/chrome/browser/tab_contents/render_view_context_menu_win.cc b/chrome/browser/tab_contents/render_view_context_menu_win.cc
deleted file mode 100644
index 8493a23..0000000
--- a/chrome/browser/tab_contents/render_view_context_menu_win.cc
+++ /dev/null
@@ -1,80 +0,0 @@
-// Copyright (c) 2012 The Chromium Authors. All rights reserved.
-// Use of this source code is governed by a BSD-style license that can be
-// found in the LICENSE file.
-
-#include "chrome/browser/tab_contents/render_view_context_menu_win.h"
-
-#include "base/win/metro.h"
-#include "chrome/app/chrome_command_ids.h"
-#include "chrome/browser/profiles/profile.h"
-#include "chrome/browser/tab_contents/retargeting_details.h"
-#include "chrome/browser/ui/browser_finder.h"
-#include "chrome/common/chrome_notification_types.h"
-#include "content/public/browser/web_contents.h"
-
-using content::WebContents;
-
-RenderViewContextMenuWin::RenderViewContextMenuWin(
- WebContents* web_contents,
- const content::ContextMenuParams& params)
- : RenderViewContextMenuViews(web_contents, params) {
-}
-
-RenderViewContextMenuWin::~RenderViewContextMenuWin() {
-}
-
-// static
-RenderViewContextMenuViews* RenderViewContextMenuViews::Create(
- content::WebContents* tab_contents,
- const content::ContextMenuParams& params) {
- return new RenderViewContextMenuWin(tab_contents, params);
-}
-
-bool RenderViewContextMenuWin::IsCommandIdVisible(int command_id) const {
- // In windows 8 metro mode no new window option on normal browser windows.
- if (base::win::GetMetroModule() && !profile_->IsOffTheRecord() &&
- command_id == IDC_CONTENT_CONTEXT_OPENLINKNEWWINDOW) {
- return false;
- }
- return RenderViewContextMenu::IsCommandIdVisible(command_id);
-}
-
-void RenderViewContextMenuWin::ExecuteCommand(int command_id) {
- ExecuteCommand(command_id, 0);
-}
-
-void RenderViewContextMenuWin::ExecuteCommand(int command_id,
- int event_flags) {
- if (base::win::GetMetroModule() &&
- command_id == IDC_CONTENT_CONTEXT_OPENLINKNEWWINDOW) {
- // The open link in new window command should only be enabled for
- // incognito windows in metro mode.
- DCHECK(profile_->IsOffTheRecord());
- // We directly go to the Browser object to open the url in effect
- // bypassing the delegate. Currently the Browser is the only class which
- // implements the delegate for the context menu. This would break if there
- // are other delegates for the context menu. This is ok for now as this
- // code only executes for Windows 8 metro mode.
- Browser* browser = browser::FindTabbedBrowser(
- profile_->GetOriginalProfile(), false);
- 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->GetSelectedWebContents();
- WebContents* new_contents = source_web_contents->OpenURL(url_params);
- DCHECK(new_contents);
- return;
- }
- }
- RenderViewContextMenu::ExecuteCommand(command_id, event_flags);
-}
-
-void RenderViewContextMenuWin::SetExternal() {
- external_ = true;
-}
diff --git a/chrome/browser/tab_contents/render_view_context_menu_win.h b/chrome/browser/tab_contents/render_view_context_menu_win.h
deleted file mode 100644
index d6309b9..0000000
--- a/chrome/browser/tab_contents/render_view_context_menu_win.h
+++ /dev/null
@@ -1,35 +0,0 @@
-// Copyright (c) 2012 The Chromium Authors. All rights reserved.
-// Use of this source code is governed by a BSD-style license that can be
-// found in the LICENSE file.
-
-#ifndef CHROME_BROWSER_TAB_CONTENTS_RENDER_VIEW_CONTEXT_MENU_WIN_H_
-#define CHROME_BROWSER_TAB_CONTENTS_RENDER_VIEW_CONTEXT_MENU_WIN_H_
-#pragma once
-
-#include "chrome/browser/ui/views/tab_contents/render_view_context_menu_views.h"
-
-namespace content {
-class WebContents;
-}
-
-// Windows specific implementation of the render view context menu.
-class RenderViewContextMenuWin : public RenderViewContextMenuViews {
- public:
- RenderViewContextMenuWin(content::WebContents* web_contents,
- const content::ContextMenuParams& params);
- virtual ~RenderViewContextMenuWin();
-
- // Set this menu to show for an external tab contents. This
- // only has an effect before Init() is called.
- void SetExternal();
-
- // SimpleMenuModel::Delegate implementation.
- virtual bool IsCommandIdVisible(int command_id) const OVERRIDE;
- virtual void ExecuteCommand(int command_id) OVERRIDE;
- virtual void ExecuteCommand(int command_id, int event_flags) OVERRIDE;
-
- private:
- DISALLOW_COPY_AND_ASSIGN(RenderViewContextMenuWin);
-};
-
-#endif // CHROME_BROWSER_TAB_CONTENTS_RENDER_VIEW_CONTEXT_MENU_WIN_H_
diff --git a/chrome/browser/ui/views/tab_contents/chrome_web_contents_view_delegate_views.cc b/chrome/browser/ui/views/tab_contents/chrome_web_contents_view_delegate_views.cc
index fa2e0af..da6f030 100644
--- a/chrome/browser/ui/views/tab_contents/chrome_web_contents_view_delegate_views.cc
+++ b/chrome/browser/ui/views/tab_contents/chrome_web_contents_view_delegate_views.cc
@@ -125,8 +125,7 @@ void ChromeWebContentsViewDelegateViews::RestoreFocus() {
void ChromeWebContentsViewDelegateViews::ShowContextMenu(
const content::ContextMenuParams& params) {
- context_menu_.reset(
- RenderViewContextMenuViews::Create(web_contents_, params));
+ context_menu_.reset(new RenderViewContextMenuViews(web_contents_, params));
context_menu_->Init();
// Don't show empty menus.
diff --git a/chrome/browser/ui/views/tab_contents/render_view_context_menu_views.cc b/chrome/browser/ui/views/tab_contents/render_view_context_menu_views.cc
index 6a8f360..056178d 100644
--- a/chrome/browser/ui/views/tab_contents/render_view_context_menu_views.cc
+++ b/chrome/browser/ui/views/tab_contents/render_view_context_menu_views.cc
@@ -33,15 +33,6 @@ RenderViewContextMenuViews::RenderViewContextMenuViews(
RenderViewContextMenuViews::~RenderViewContextMenuViews() {
}
-#if !defined(OS_WIN)
-// static
-RenderViewContextMenuViews* RenderViewContextMenuViews::Create
- content::WebContents* tab_contents,
- const content::ContextMenuParams& params) {
- return new RenderViewContextMenuViews(tab_contents, params);
-}
-#endif // OS_WIN
-
void RenderViewContextMenuViews::RunMenuAt(views::Widget* parent,
const gfx::Point& point) {
if (menu_runner_->RunMenuAt(parent, NULL, gfx::Rect(point, gfx::Size()),
@@ -50,6 +41,12 @@ void RenderViewContextMenuViews::RunMenuAt(views::Widget* parent,
return;
}
+#if defined(OS_WIN)
+void RenderViewContextMenuViews::SetExternal() {
+ external_ = true;
+}
+#endif
+
void RenderViewContextMenuViews::UpdateMenuItemStates() {
menu_delegate_->BuildMenu(menu_);
}
diff --git a/chrome/browser/ui/views/tab_contents/render_view_context_menu_views.h b/chrome/browser/ui/views/tab_contents/render_view_context_menu_views.h
index d9ff728..24e7d15 100644
--- a/chrome/browser/ui/views/tab_contents/render_view_context_menu_views.h
+++ b/chrome/browser/ui/views/tab_contents/render_view_context_menu_views.h
@@ -24,15 +24,19 @@ class Widget;
class RenderViewContextMenuViews : public RenderViewContextMenu {
public:
- virtual ~RenderViewContextMenuViews();
+ RenderViewContextMenuViews(content::WebContents* tab_contents,
+ const content::ContextMenuParams& params);
- // Factory function to create an instance.
- static RenderViewContextMenuViews* Create(
- content::WebContents* tab_contents,
- const content::ContextMenuParams& params);
+ virtual ~RenderViewContextMenuViews();
void RunMenuAt(views::Widget* parent, const gfx::Point& point);
+#if defined(OS_WIN)
+ // Set this menu to show for an external tab contents. This
+ // only has an effect before Init() is called.
+ void SetExternal();
+#endif
+
void UpdateMenuItemStates();
// RenderViewContextMenuDelegate implementation.
@@ -42,8 +46,6 @@ class RenderViewContextMenuViews : public RenderViewContextMenu {
const string16& title) OVERRIDE;
protected:
- RenderViewContextMenuViews(content::WebContents* tab_contents,
- const content::ContextMenuParams& params);
// RenderViewContextMenu implementation.
virtual void PlatformInit() OVERRIDE;
virtual void PlatformCancel() OVERRIDE;
diff --git a/chrome/chrome_browser.gypi b/chrome/chrome_browser.gypi
index 5e4e5a0..631e837 100644
--- a/chrome/chrome_browser.gypi
+++ b/chrome/chrome_browser.gypi
@@ -2224,8 +2224,6 @@
'browser/tab_contents/render_view_context_menu_gtk.h',
'browser/tab_contents/render_view_context_menu_mac.h',
'browser/tab_contents/render_view_context_menu_mac.mm',
- 'browser/tab_contents/render_view_context_menu_win.cc',
- 'browser/tab_contents/render_view_context_menu_win.h',
'browser/tab_contents/render_view_context_menu_observer.cc',
'browser/tab_contents/render_view_context_menu_observer.h',
'browser/tab_contents/retargeting_details.h',
diff --git a/ui/views/controls/menu/menu_model_adapter.cc b/ui/views/controls/menu/menu_model_adapter.cc
index 583c74a..450a579 100644
--- a/ui/views/controls/menu/menu_model_adapter.cc
+++ b/ui/views/controls/menu/menu_model_adapter.cc
@@ -1,4 +1,4 @@
-// Copyright (c) 2012 The Chromium Authors. All rights reserved.
+// Copyright (c) 2011 The Chromium Authors. All rights reserved.
// Use of this source code is governed by a BSD-style license that can be
// found in the LICENSE file.
@@ -180,13 +180,9 @@ void MenuModelAdapter::BuildMenuImpl(MenuItemView* menu, ui::MenuModel* model) {
const int item_count = model->GetItemCount();
for (int i = 0; i < item_count; ++i) {
const int index = i + model->GetFirstItemIndex(NULL);
-
MenuItemView* item = menu->AppendMenuItemFromModel(
model, index, model->GetCommandIdAt(index));
- if (item)
- item->SetVisible(model->IsVisibleAt(index));
-
if (model->GetTypeAt(index) == ui::MenuModel::TYPE_SUBMENU) {
DCHECK(item);
DCHECK_EQ(MenuItemView::SUBMENU, item->GetType());