diff options
author | oshima@google.com <oshima@google.com@0039d316-1c4b-4281-b951-d872f2087c98> | 2011-03-16 22:33:36 +0000 |
---|---|---|
committer | oshima@google.com <oshima@google.com@0039d316-1c4b-4281-b951-d872f2087c98> | 2011-03-16 22:33:36 +0000 |
commit | 6f0e5632d7000eac113423c26167e88d199db7ea (patch) | |
tree | 86ab70fd86f9bc61e1f531e3ddb15eed4b001fde | |
parent | 230b7efa5edf3fe5964b55ea0aa801563996d4fc (diff) | |
download | chromium_src-6f0e5632d7000eac113423c26167e88d199db7ea.zip chromium_src-6f0e5632d7000eac113423c26167e88d199db7ea.tar.gz chromium_src-6f0e5632d7000eac113423c26167e88d199db7ea.tar.bz2 |
Remove WebUI menu
BUG=none
TEST=none
Review URL: http://codereview.chromium.org/6693032
git-svn-id: svn://svn.chromium.org/chrome/trunk/src@78450 0039d316-1c4b-4281-b951-d872f2087c98
18 files changed, 4 insertions, 2660 deletions
diff --git a/chrome/browser/chromeos/status/network_menu.cc b/chrome/browser/chromeos/status/network_menu.cc index 93e0906b..e42c682 100644 --- a/chrome/browser/chromeos/status/network_menu.cc +++ b/chrome/browser/chromeos/status/network_menu.cc @@ -9,7 +9,6 @@ #include "base/stringprintf.h" #include "base/utf_string_conversions.h" #include "chrome/browser/chromeos/cros/cros_library.h" -#include "chrome/browser/chromeos/webui/network_menu_ui.h" #include "chrome/browser/ui/browser.h" #include "chrome/browser/ui/browser_list.h" #include "chrome/common/url_constants.h" @@ -89,7 +88,7 @@ SkBitmap NetworkMenu::kAnimatingImagesBlack[kNumAnimatingImages]; NetworkMenu::NetworkMenu() : min_width_(-1) { - network_menu_.reset(NetworkMenuUI::CreateMenu2(this)); + network_menu_.reset(new views::Menu2(this)); } NetworkMenu::~NetworkMenu() { @@ -249,15 +248,7 @@ bool NetworkMenu::ConnectToNetworkAt(int index, // TODO(stevenjb): Show notification. } } else if (flags & FLAG_OTHER_NETWORK) { - if (MenuUI::IsEnabled()) { - // default is true - bool auto_connect_bool = auto_connect == 0 ? false : true; - cros->ConnectToWifiNetwork( - passphrase.empty() ? SECURITY_NONE : SECURITY_UNKNOWN, - ssid, passphrase, std::string(), std::string(), auto_connect_bool); - } else { - ShowOther(); - } + ShowOther(); } return true; } @@ -773,7 +764,7 @@ void NetworkMenu::InitMenuItems() { if (!oobe) { menu_items_.push_back(MenuItem()); // Separator - if (!MenuUI::IsEnabled() && connected) { + if (connected) { std::string ip_address = cros->IPAddress(); if (!ip_address.empty()) { menu_items_.push_back(MenuItem(ui::MenuModel::TYPE_COMMAND, @@ -823,17 +814,7 @@ void NetworkMenu::ActivateCellular(const CellularNetwork* cellular) const { } void NetworkMenu::ShowOther() const { - if (MenuUI::IsEnabled()) { - Browser* browser = BrowserList::GetLastActive(); - if (browser) { - std::string page = StringPrintf("%s?networkType=%d", - chrome::kInternetOptionsSubPage, - chromeos::TYPE_WIFI); - browser->ShowOptionsTab(page); - } - } else { - ShowNetworkConfigView(new NetworkConfigView()); - } + ShowNetworkConfigView(new NetworkConfigView()); } } // namespace chromeos diff --git a/chrome/browser/chromeos/views/menu_locator.cc b/chrome/browser/chromeos/views/menu_locator.cc deleted file mode 100644 index 837a7ac..0000000 --- a/chrome/browser/chromeos/views/menu_locator.cc +++ /dev/null @@ -1,313 +0,0 @@ -// 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. - -#include "chrome/browser/chromeos/views/menu_locator.h" - -#include "base/i18n/rtl.h" -#include "base/logging.h" -#include "chrome/browser/chromeos/views/webui_menu_widget.h" -#include "ui/gfx/insets.h" -#include "ui/gfx/point.h" -#include "ui/gfx/rect.h" -#include "views/screen.h" -#include "views/widget/widget.h" - -namespace { - -using chromeos::WebUIMenuWidget; - -// Menu's corner radious. -const int kMenuCornerRadius = 0; // crosbug.com/7718. -const int kSubmenuOverlapPx = 1; - -gfx::Rect GetBoundsOf(const views::Widget* widget) { - return widget->GetClientAreaScreenBounds(); -} - -// Returns the Rect of the screen that contains the point (x, y). -gfx::Rect GetScreenRectAt(int x, int y) { - return views::Screen::GetMonitorAreaNearestPoint(gfx::Point(x, y)); -} - -// Returns adjusted height of the menu that fits to the screen's -// height, and enables scrolling if necessary. -int AdjustHeight(WebUIMenuWidget* widget, - int screen_height, - int height) { - // TODO(oshima): Locator needs a preferred size so that - // 1) we can tell height == screen_rect is the result of - // locator resizing it, or preferred size happens to be - // same hight of the screen (which is rare). - // 2) when the menu is moved to place where it has more space, it can - // hide the scrollbar again. (which won't happen on chromeos now) - if (height >= screen_height) { - widget->EnableScroll(true); - return screen_height; - } - widget->EnableScroll(false); - return height; -} - -// Updates the root menu's bounds to fit to the screen. -void UpdateRootMenuBounds(WebUIMenuWidget* widget, - const gfx::Point& origin, - const gfx::Size& size, - bool align_right) { - gfx::Rect screen_rect = GetScreenRectAt(origin.x(), origin.y()); - int width = std::min(screen_rect.width(), size.width()); - int height = AdjustHeight(widget, screen_rect.height(), size.height()); - - int x = align_right ? origin.x() - width : origin.x(); - int y = origin.y(); - if (x + width > screen_rect.right()) - x = screen_rect.right() - width; - if (y + height > screen_rect.bottom()) - y = screen_rect.bottom() - height; - widget->SetBounds(gfx::Rect(x, y, width, height)); -} - -// MenuLocator for dropdown menu. -class DropDownMenuLocator : public chromeos::MenuLocator { - public: - explicit DropDownMenuLocator(const gfx::Point& origin) - : origin_(origin) { - } - - private: - virtual SubmenuDirection GetSubmenuDirection() const { - return DEFAULT; - } - - virtual void Move(WebUIMenuWidget* widget) { - // TODO(oshima): - // Dropdown Menu has to be shown above the button, which is not currently - // possible with Menu2. I'll update Menu2 and this code - // after beta. - gfx::Rect bounds = widget->GetClientAreaScreenBounds(); - UpdateRootMenuBounds(widget, origin_, bounds.size(), !base::i18n::IsRTL()); - } - - virtual void SetBounds(WebUIMenuWidget* widget, const gfx::Size& size) { - gfx::Size new_size(size); - new_size.Enlarge(0, kMenuCornerRadius); - UpdateRootMenuBounds(widget, origin_, size, !base::i18n::IsRTL()); - } - - virtual void GetInsets(gfx::Insets* insets) const { - insets->Set(0, 0, kMenuCornerRadius, 0); - } - - virtual const SkScalar* GetCorners() const { - static const SkScalar corners[] = { - 0, 0, - 0, 0, - kMenuCornerRadius, kMenuCornerRadius, - kMenuCornerRadius, kMenuCornerRadius, - }; - return corners; - } - - gfx::Point origin_; - - DISALLOW_COPY_AND_ASSIGN(DropDownMenuLocator); -}; - -// MenuLocator for context menu. -class ContextMenuLocator : public chromeos::MenuLocator { - public: - explicit ContextMenuLocator(const gfx::Point& origin) - : origin_(origin) { - } - - private: - virtual SubmenuDirection GetSubmenuDirection() const { - return DEFAULT; - } - - virtual void Move(WebUIMenuWidget* widget) { - gfx::Rect bounds = widget->GetClientAreaScreenBounds(); - UpdateRootMenuBounds(widget, origin_, bounds.size(), base::i18n::IsRTL()); - } - - virtual void SetBounds(WebUIMenuWidget* widget, const gfx::Size& size) { - gfx::Size new_size(size); - new_size.Enlarge(0, kMenuCornerRadius * 2); - UpdateRootMenuBounds(widget, origin_, new_size, base::i18n::IsRTL()); - } - - virtual const SkScalar* GetCorners() const { - static const SkScalar corners[] = { - kMenuCornerRadius, kMenuCornerRadius, - kMenuCornerRadius, kMenuCornerRadius, - kMenuCornerRadius, kMenuCornerRadius, - kMenuCornerRadius, kMenuCornerRadius, - }; - return corners; - } - - virtual void GetInsets(gfx::Insets* insets) const { - insets->Set(kMenuCornerRadius, 0, kMenuCornerRadius, 0); - } - - gfx::Point origin_; - - DISALLOW_COPY_AND_ASSIGN(ContextMenuLocator); -}; - -// MenuLocator for submenu. -class SubMenuLocator : public chromeos::MenuLocator { - public: - SubMenuLocator(const WebUIMenuWidget* parent, - MenuLocator::SubmenuDirection parent_direction, - int y) - : parent_rect_(GetBoundsOf(parent)), - parent_direction_(parent_direction), - root_y_(parent_rect_.y() + y), - corners_(NULL), - direction_(DEFAULT) { - } - - private: - virtual SubmenuDirection GetSubmenuDirection() const { - return direction_; - } - - virtual void Move(WebUIMenuWidget* widget) { - gfx::Rect bounds = widget->GetClientAreaScreenBounds(); - UpdateBounds(widget, bounds.size()); - } - - virtual void SetBounds(WebUIMenuWidget* widget, const gfx::Size& size) { - gfx::Size new_size(size); - new_size.Enlarge(0, kMenuCornerRadius * 2); - UpdateBounds(widget, new_size); - } - - virtual const SkScalar* GetCorners() const { - return corners_; - } - - virtual void GetInsets(gfx::Insets* insets) const { - insets->Set(kMenuCornerRadius, 0, kMenuCornerRadius, 0); - } - - // Rounded corner definitions for right/left attached submenu. - static const SkScalar kRightCorners[]; - static const SkScalar kLeftCorners[]; - - void UpdateBounds(WebUIMenuWidget* widget, const gfx::Size& size) { - gfx::Rect screen_rect = GetScreenRectAt(parent_rect_.x(), root_y_); - int width = std::min(screen_rect.width(), size.width()); - int height = AdjustHeight(widget, size.height(), screen_rect.height()); - - SubmenuDirection direction = parent_direction_; - if (direction == DEFAULT) { - if (base::i18n::IsRTL()) { - direction = LEFT; - } else { - direction = RIGHT; - } - } - // Adjust Y to fit the screen. - int y = root_y_; - if (root_y_ + height > screen_rect.bottom()) - y = screen_rect.bottom() - height; - // Determine the attachment. - // TODO(oshima): - // Come up with better placement when menu is wide, - // probably limit max width and let each menu scroll - // horizontally when selected. - int x = direction == RIGHT ? - ComputeXToRight(screen_rect, width) : - ComputeXToLeft(screen_rect, width); - corners_ = direction_ == RIGHT ? kRightCorners : kLeftCorners; - widget->SetBounds(gfx::Rect(x, y, width, height)); - } - - int ComputeXToRight(const gfx::Rect& screen_rect, int width) { - if (parent_rect_.right() + width > screen_rect.right()) { - if (parent_rect_.x() - width < screen_rect.x()) { - // Place on the right to fit to the screen if no space on left - direction_ = RIGHT; - return screen_rect.right() - width; - } - direction_ = LEFT; - return parent_rect_.x() - width + kSubmenuOverlapPx; - } else { - direction_ = RIGHT; - return parent_rect_.right() - kSubmenuOverlapPx; - } - } - - int ComputeXToLeft(const gfx::Rect& screen_rect, int width) { - if (parent_rect_.x() - width < screen_rect.x()) { - if (parent_rect_.right() + width > screen_rect.right()) { - // no space on right - direction_ = LEFT; - return screen_rect.x(); - } - corners_ = kRightCorners; - direction_ = RIGHT; - return parent_rect_.right() - kSubmenuOverlapPx; - } else { - corners_ = kLeftCorners; - direction_ = LEFT; - return parent_rect_.x() - width + kSubmenuOverlapPx; - } - } - - const gfx::Rect parent_rect_; - - const MenuLocator::SubmenuDirection parent_direction_; - - const int root_y_; - - SkScalar const* corners_; - - // The direction the this menu is attached to its parent. Submenu may still - // choose different direction if there is no spece for that direction - // (2nd turnaround). - SubmenuDirection direction_; - - DISALLOW_COPY_AND_ASSIGN(SubMenuLocator); -}; - -// Rounded corners of the submenu attached to right side. -const SkScalar SubMenuLocator::kRightCorners[] = { - 0, 0, - kMenuCornerRadius, kMenuCornerRadius, - kMenuCornerRadius, kMenuCornerRadius, - kMenuCornerRadius, kMenuCornerRadius, -}; - -// Rounded corners of the submenu attached to left side. -const SkScalar SubMenuLocator::kLeftCorners[] = { - kMenuCornerRadius, kMenuCornerRadius, - 0, 0, - kMenuCornerRadius, kMenuCornerRadius, - kMenuCornerRadius, kMenuCornerRadius, -}; - - -} // namespace - -namespace chromeos { - -// static -MenuLocator* MenuLocator::CreateDropDownMenuLocator(const gfx::Point& p) { - return new DropDownMenuLocator(p); -} - -MenuLocator* MenuLocator::CreateContextMenuLocator(const gfx::Point& p) { - return new ContextMenuLocator(p); -} - -MenuLocator* MenuLocator::CreateSubMenuLocator( - const WebUIMenuWidget* parent, - MenuLocator::SubmenuDirection parent_direction, - int y) { - return new SubMenuLocator(parent, parent_direction, y); -} - -} // namespace chromeos diff --git a/chrome/browser/chromeos/views/menu_locator.h b/chrome/browser/chromeos/views/menu_locator.h deleted file mode 100644 index cb2744d..0000000 --- a/chrome/browser/chromeos/views/menu_locator.h +++ /dev/null @@ -1,77 +0,0 @@ -// 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. - -#ifndef CHROME_BROWSER_CHROMEOS_VIEWS_MENU_LOCATOR_H_ -#define CHROME_BROWSER_CHROMEOS_VIEWS_MENU_LOCATOR_H_ -#pragma once - -#include "third_party/skia/include/core/SkScalar.h" - -namespace gfx { -class Insets; -class Point; -class Size; -} // namespace gfx - -namespace chromeos { - -class WebUIMenuWidget; - -// MenuLocator class contorls where the menu will be placed and -// which corners are rounded. -// TODO(oshima): support RTL. -class MenuLocator { - public: - enum SubmenuDirection { - DEFAULT, // default direction. - RIGHT, // submenu should grow to right. (not used now. reserved for RTL) - LEFT, // submenu should grow to left. - }; - - virtual ~MenuLocator() {} - - // Returns the direction that submenu should grow. - virtual SubmenuDirection GetSubmenuDirection() const = 0; - - // Move the widget to the right position. - virtual void Move(WebUIMenuWidget* widget) = 0; - - // Resize and move the widget to the right position. - virtual void SetBounds(WebUIMenuWidget* widget, - const gfx::Size& size) = 0; - - // Returns the 8 length array of SkScalar that represents 4 corner - // radious for each menu type. The objects are owned by the locator - // and should not be deleted. This can be null when SubMenu is - // still off screen (not visible). - virtual const SkScalar* GetCorners() const = 0; - - // Returns the insets to give space to draw rounded corners. - virtual void GetInsets(gfx::Insets* insets) const = 0; - - // Returns the menu locator for dropdown menu. The menu will - // positioned so that the top right corner is given by "point". - // Only bottom corners are rounded. - static MenuLocator* CreateDropDownMenuLocator(const gfx::Point& point); - - // Returns the menu locator for context menu. The menu will - // positioned so that the top left corner is given by "point" (in - // LTR). All 4 corners are rounded. - static MenuLocator* CreateContextMenuLocator(const gfx::Point& point); - - // Returns the menu locator for submenu menu. The menu will - // positioned at Y and on the right side of the widget, or on the - // left if there is no enough spaceon the right side. Once it changes the - // derection, all subsequent submenu should be positioned to the same - // direction given by |parent_direction|. 3 corners are - // rounded except for the corner that is attached to the widget. - static MenuLocator* CreateSubMenuLocator( - const WebUIMenuWidget* widget, - MenuLocator::SubmenuDirection parent_direction, - int y); -}; - -} // namespace chromeos - -#endif // CHROME_BROWSER_CHROMEOS_VIEWS_MENU_LOCATOR_H_ diff --git a/chrome/browser/chromeos/views/native_menu_webui.cc b/chrome/browser/chromeos/views/native_menu_webui.cc deleted file mode 100644 index 1bcd5fe..0000000 --- a/chrome/browser/chromeos/views/native_menu_webui.cc +++ /dev/null @@ -1,401 +0,0 @@ -// 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. - -#include "chrome/browser/chromeos/views/native_menu_webui.h" - -#include <string> - -#include "base/message_loop.h" -#include "base/string_util.h" -#include "chrome/browser/chromeos/views/menu_locator.h" -#include "chrome/browser/chromeos/views/webui_menu_widget.h" -#include "chrome/browser/chromeos/webui/menu_ui.h" -#include "chrome/browser/profiles/profile_manager.h" -#include "chrome/browser/ui/browser.h" -#include "chrome/browser/ui/browser_list.h" -#include "chrome/browser/ui/browser_window.h" -#include "chrome/common/url_constants.h" -#include "ui/base/models/menu_model.h" -#include "ui/gfx/rect.h" -#include "views/controls/menu/menu_2.h" -#include "views/controls/menu/nested_dispatcher_gtk.h" - -#if defined(TOUCH_UI) -#include "views/focus/accelerator_handler.h" -#include "views/controls/menu/native_menu_x.h" -#else -#include "views/controls/menu/native_menu_gtk.h" -#endif - -namespace { - -using chromeos::NativeMenuWebUI; -using chromeos::WebUIMenuWidget; - -// Returns true if the menu item type specified can be executed as a command. -bool MenuTypeCanExecute(ui::MenuModel::ItemType type) { - return type == ui::MenuModel::TYPE_COMMAND || - type == ui::MenuModel::TYPE_CHECK || - type == ui::MenuModel::TYPE_RADIO; -} - -gboolean Destroy(GtkWidget* widget, gpointer data) { - WebUIMenuWidget* menu_widget = static_cast<WebUIMenuWidget*>(data); - NativeMenuWebUI* webui_menu = menu_widget->webui_menu(); - // webui_menu can be NULL if widget is destroyed by signal. - if (webui_menu) - webui_menu->Hide(); - return true; -} - -// Returns the active toplevel window. -gfx::NativeWindow FindActiveToplevelWindow() { - GList* toplevels = gtk_window_list_toplevels(); - while (toplevels) { - gfx::NativeWindow window = static_cast<gfx::NativeWindow>(toplevels->data); - if (gtk_window_is_active(window)) { - return window; - } - toplevels = g_list_next(toplevels); - } - return NULL; -} - -// Currently opened menu. See RunMenuAt for reason why we need this. -NativeMenuWebUI* current_ = NULL; - -} // namespace - -namespace chromeos { - -// static -void NativeMenuWebUI::SetMenuURL(views::Menu2* menu2, const GURL& url) { - // No-op if WebUI menu is disabled. - if (!MenuUI::IsEnabled()) - return; - - gfx::NativeView native = menu2->GetNativeMenu(); - DCHECK(native); - WebUIMenuWidget* widget = WebUIMenuWidget::FindWebUIMenuWidget(native); - DCHECK(widget); - widget->webui_menu()->set_menu_url(url); -} - -//////////////////////////////////////////////////////////////////////////////// -// NativeMenuWebUI, public: - -NativeMenuWebUI::NativeMenuWebUI(ui::MenuModel* menu_model, bool root) - : parent_(NULL), - submenu_(NULL), - model_(menu_model), - menu_widget_(NULL), - menu_shown_(false), - activated_menu_(NULL), - activated_index_(-1), - menu_action_(MENU_ACTION_NONE), - menu_url_(StringPrintf("chrome://%s", chrome::kChromeUIMenu)), - on_menu_opened_called_(false), - nested_dispatcher_(NULL) { - menu_widget_ = new WebUIMenuWidget(this, root); - // Set the initial location off the screen not to show small - // window with dropshadow. - menu_widget_->Init(NULL, gfx::Rect(-10000, -10000, 1, 1)); -} - -NativeMenuWebUI::~NativeMenuWebUI() { - if (nested_dispatcher_) { - // Menu is destroyed while its in message loop. - // Let nested dispatcher know the creator is deleted. - nested_dispatcher_->CreatorDestroyed(); - Hide(); - } - if (menu_widget_) { - menu_widget_->Close(); - menu_widget_ = NULL; - } - parent_ = NULL; -} - -//////////////////////////////////////////////////////////////////////////////// -// NativeMenuWebUI, MenuWrapper implementation: - -void NativeMenuWebUI::RunMenuAt(const gfx::Point& point, int alignment) { - if (current_ != NULL) { - // This happens when there is a nested task to show menu, which is - // executed after menu is open. Since we need to enable nested task, - // this condition has to be handled here. - return; - } - current_ = this; - bool context = false; - - // TODO(oshima): This is quick hack to check if it's context menu. (in rtl) - // Fix this once we migrated. - if (alignment == views::Menu2::ALIGN_TOPLEFT) { - context = true; - } - - activated_menu_ = NULL; - activated_index_ = -1; - menu_action_ = MENU_ACTION_NONE; - - MenuLocator* locator = context ? - MenuLocator::CreateContextMenuLocator(point) : - MenuLocator::CreateDropDownMenuLocator(point); - ShowAt(locator); - DCHECK(!menu_shown_); - menu_shown_ = true; - on_menu_opened_called_ = false; - - // TODO(oshima): A menu must be deleted when parent window is - // closed. Menu2 doesn't know about the parent window, however, so - // we're using toplevel gtkwindow. This is probably sufficient, but - // I will update Menu2 to pass host view (which is necessary anyway - // to get the right position) and get a parent widnow through - // it. http://crosbug/7642 - gfx::NativeWindow parent = FindActiveToplevelWindow(); - gulong handle = 0; - if (parent) { - handle = g_signal_connect(G_OBJECT(parent), "destroy", - G_CALLBACK(&Destroy), - menu_widget_); - } - // We need to turn on nestable tasks as a renderer uses tasks internally. - // Without this, renderer cannnot finish loading page. - nested_dispatcher_ = - new views::NestedDispatcherGtk(this, true /* allow nested */); - bool deleted = nested_dispatcher_->RunAndSelfDestruct(); - current_ = NULL; // this is static and safe to access. - if (deleted) { - // The menu was destryed while menu is shown, so return immediately. - // Don't touch the instance which is already deleted. - return; - } - nested_dispatcher_ = NULL; - if (menu_shown_) { - // If this happens it means we haven't yet gotten the hide signal and - // someone else quit the message loop on us. - NOTREACHED(); - menu_shown_ = false; - } - if (handle) - g_signal_handler_disconnect(G_OBJECT(parent), handle); - - menu_widget_->Hide(); - // Close All submenus. - submenu_.reset(); - ProcessActivate(); -} - -void NativeMenuWebUI::CancelMenu() { - Hide(); -} - -void NativeMenuWebUI::Rebuild() { - activated_menu_ = NULL; - menu_widget_->ExecuteJavascript(L"modelUpdated()"); -} - -void NativeMenuWebUI::UpdateStates() { - // Update menu contnets and submenus. - Rebuild(); -} - -gfx::NativeMenu NativeMenuWebUI::GetNativeMenu() const { - return menu_widget_->GetNativeView(); -} - -NativeMenuWebUI::MenuAction NativeMenuWebUI::GetMenuAction() const { - return menu_action_; -} - -void NativeMenuWebUI::AddMenuListener(views::MenuListener* listener) { - listeners_.AddObserver(listener); -} - -void NativeMenuWebUI::RemoveMenuListener(views::MenuListener* listener) { - listeners_.RemoveObserver(listener); -} - -void NativeMenuWebUI::SetMinimumWidth(int width) { - gtk_widget_set_size_request(menu_widget_->GetNativeView(), width, 1); -} - -//////////////////////////////////////////////////////////////////////////////// -// NativeMenuWebUI, MessageLoopForUI::Dispatcher implementation: - -bool NativeMenuWebUI::Dispatch(GdkEvent* event) { - switch (event->type) { - case GDK_MOTION_NOTIFY: { - NativeMenuWebUI* target = FindMenuAt( - gfx::Point(event->motion.x_root, event->motion.y_root)); - if (target) - target->menu_widget_->EnableInput(false); - break; - } - case GDK_BUTTON_PRESS: { - NativeMenuWebUI* target = FindMenuAt( - gfx::Point(event->motion.x_root, event->motion.y_root)); - if (!target) { - Hide(); - return true; - } - break; - } - default: - break; - } - gtk_main_do_event(event); - return true; -} - -#if defined(TOUCH_UI) -base::MessagePumpGlibXDispatcher::DispatchStatus - NativeMenuWebUI::DispatchX(XEvent* xevent) { - return views::DispatchXEvent(xevent) ? - base::MessagePumpGlibXDispatcher::EVENT_PROCESSED : - base::MessagePumpGlibXDispatcher::EVENT_IGNORED; - -} -#endif - -//////////////////////////////////////////////////////////////////////////////// -// NativeMenuWebUI, MenuControl implementation: - -void NativeMenuWebUI::Activate(ui::MenuModel* model, - int index, - ActivationMode activation) { - NativeMenuWebUI* root = GetRoot(); - if (root) { - if (activation == CLOSE_AND_ACTIVATE) { - root->activated_menu_ = model; - root->activated_index_ = index; - root->menu_action_ = MENU_ACTION_SELECTED; - root->Hide(); - } else { - if (model->IsEnabledAt(index) && - MenuTypeCanExecute(model->GetTypeAt(index))) { - model->ActivatedAt(index); - } - } - } -} - -void NativeMenuWebUI::OpenSubmenu(int index, int y) { - submenu_.reset(); - // Returns the model for the submenu at the specified index. - ui::MenuModel* submenu = model_->GetSubmenuModelAt(index); - submenu_.reset(new chromeos::NativeMenuWebUI(submenu, false)); - submenu_->set_menu_url(menu_url_); - // y in menu_widget_ coordinate. - submenu_->set_parent(this); - submenu_->ShowAt( - MenuLocator::CreateSubMenuLocator( - menu_widget_, - menu_widget_->menu_locator()->GetSubmenuDirection(), - y)); -} - -void NativeMenuWebUI::CloseAll() { - NativeMenuWebUI* root = GetRoot(); - // root can be null if the submenu is detached from parent. - if (root) - root->Hide(); -} - -void NativeMenuWebUI::CloseSubmenu() { - submenu_.reset(); // This closes subsequent children. -} - -void NativeMenuWebUI::MoveInputToSubmenu() { - if (submenu_.get()) { - submenu_->menu_widget_->EnableInput(true); - } -} - -void NativeMenuWebUI::MoveInputToParent() { - if (parent_) { - parent_->menu_widget_->EnableInput(true); - } -} - -void NativeMenuWebUI::OnLoad() { - // TODO(oshima): OnLoad is no longer used, but kept in case - // we may need it. Delete this if this is not necessary to - // implement wrench/network/bookmark menus. -} - -void NativeMenuWebUI::SetSize(const gfx::Size& size) { - menu_widget_->SetSize(size); -} - -//////////////////////////////////////////////////////////////////////////////// -// NativeMenuWebUI, public: - -void NativeMenuWebUI::Hide() { - // Only root can hide and exit the message loop. - DCHECK(menu_widget_->is_root()); - DCHECK(!parent_); - if (!menu_shown_) { - // The menu has been already hidden by us and we're in the process of - // quiting the message loop.. - return; - } - CloseSubmenu(); - menu_shown_ = false; - MessageLoop::current()->Quit(); -} - -NativeMenuWebUI* NativeMenuWebUI::GetRoot() { - NativeMenuWebUI* ancestor = this; - while (ancestor->parent_) - ancestor = ancestor->parent_; - if (ancestor->menu_widget_->is_root()) - return ancestor; - else - return NULL; -} - -Profile* NativeMenuWebUI::GetProfile() { - Browser* browser = BrowserList::GetLastActive(); - // browser can be null in login screen. - if (!browser) - return ProfileManager::GetDefaultProfile(); - return browser->GetProfile(); -} - -void NativeMenuWebUI::InputIsReady() { - if (!on_menu_opened_called_) { - on_menu_opened_called_ = true; - FOR_EACH_OBSERVER(views::MenuListener, listeners_, OnMenuOpened()); - } -} - -//////////////////////////////////////////////////////////////////////////////// -// NativeMenuWebUI, private: - -void NativeMenuWebUI::ProcessActivate() { - if (activated_menu_ && - activated_menu_->IsEnabledAt(activated_index_) && - MenuTypeCanExecute(activated_menu_->GetTypeAt(activated_index_))) { - activated_menu_->ActivatedAt(activated_index_); - } -} - -void NativeMenuWebUI::ShowAt(MenuLocator* locator) { - model_->MenuWillShow(); - menu_widget_->ShowAt(locator); -} - -NativeMenuWebUI* NativeMenuWebUI::FindMenuAt(const gfx::Point& point) { - if (submenu_.get()) { - NativeMenuWebUI* found = submenu_->FindMenuAt(point); - if (found) - return found; - } - gfx::Rect bounds = menu_widget_->GetClientAreaScreenBounds(); - return bounds.Contains(point) ? this : NULL; -} - -} // namespace chromeos diff --git a/chrome/browser/chromeos/views/native_menu_webui.h b/chrome/browser/chromeos/views/native_menu_webui.h deleted file mode 100644 index 62c9b00..0000000 --- a/chrome/browser/chromeos/views/native_menu_webui.h +++ /dev/null @@ -1,166 +0,0 @@ -// 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. - -#ifndef CHROME_BROWSER_CHROMEOS_VIEWS_NATIVE_MENU_WEBUI_H_ -#define CHROME_BROWSER_CHROMEOS_VIEWS_NATIVE_MENU_WEBUI_H_ -#pragma once - -#include <vector> - -#include "base/message_loop.h" -#include "base/observer_list.h" -#include "base/scoped_ptr.h" -#include "chrome/browser/chromeos/webui_menu_control.h" -#include "googleurl/src/gurl.h" -#include "views/controls/menu/menu_wrapper.h" - -class DictionaryValue; -class Profile; -class SkBitmap; - -namespace ui { -class MenuModel; -} // namespace ui - -namespace views { -class NestedDispatcherGtk; -} // namespace views; - -#if defined(TOUCH_UI) -typedef union _XEvent XEvent; -#endif - -namespace chromeos { - -class MenuLocator; -class WebUIMenuWidget; - -// A WebUI implementation of MenuWrapper. -class NativeMenuWebUI : public views::MenuWrapper, - public WebUIMenuControl, - public MessageLoop::Dispatcher { - public: - NativeMenuWebUI(ui::MenuModel* menu_model, bool root); - virtual ~NativeMenuWebUI(); - - // Returns true if menu is currently shown. - bool is_menu_shown() { return menu_shown_; } - - // Set parent menu. - void set_parent(NativeMenuWebUI* parent) { parent_ = parent; } - - // Overridden from views::MenuWrapper: - virtual void RunMenuAt(const gfx::Point& point, int alignment); - virtual void CancelMenu(); - virtual void Rebuild(); - virtual void UpdateStates(); - virtual gfx::NativeMenu GetNativeMenu() const; - virtual MenuAction GetMenuAction() const; - virtual void AddMenuListener(views::MenuListener* listener); - virtual void RemoveMenuListener(views::MenuListener* listener); - virtual void SetMinimumWidth(int width); - - // Overridden from MessageLoopForUI::Dispatcher: - virtual bool Dispatch(GdkEvent* event); -#if defined(TOUCH_UI) - virtual base::MessagePumpGlibXDispatcher::DispatchStatus DispatchX( - XEvent* xevent); -#endif - - // Overridden from WebUIMenuControl: - virtual ui::MenuModel* GetMenuModel() { return model_; } - virtual void Activate(ui::MenuModel* model, - int index, - ActivationMode activation_mode); - virtual void CloseAll(); - virtual void CloseSubmenu(); - virtual void MoveInputToParent(); - virtual void MoveInputToSubmenu(); - virtual void OnLoad(); - virtual void OpenSubmenu(int index, int y); - virtual void SetSize(const gfx::Size& size); - - // Hide All menu (including submenus). - void Hide(); - - // Returns the root of the menu tree. Returns NULL if it cannot find - // a root. (i.e. detached from root) - NativeMenuWebUI* GetRoot(); - - // Returns the profile to create DOMView. - Profile* GetProfile(); - - // Called when the menu is ready to accept input. - // Used in interactive_ui_test to wait for menu opened. - void InputIsReady(); - - // Sets/Gets the url for the WebUI menu. - void set_menu_url(const GURL& url) { menu_url_ = url; } - const GURL& menu_url() const { return menu_url_; } - - // Sets the menu url of menu2. This has to be called before - // RunMenuAt/RunContextMenuAt is called. - static void SetMenuURL(views::Menu2* menu2, const GURL& url); - - private: - // Callback that we should really process the menu activation. - // See description above class for why we delay processing activation. - void ProcessActivate(); - - // Show the menu using given |locator|. - void ShowAt(MenuLocator* locator); - - // Find a menu object at point. - NativeMenuWebUI* FindMenuAt(const gfx::Point& point); - - // If we're a submenu, this is the parent. - NativeMenuWebUI* parent_; - - // Holds the current submenu. - scoped_ptr<NativeMenuWebUI> submenu_; - - ui::MenuModel* model_; - - // A window widget that draws the content of the menu. - WebUIMenuWidget* menu_widget_; - - // True if the menu is currently shown. - // Used only in root. - bool menu_shown_; - - // If the user selects something from the menu this is the menu they selected - // it from. When an item is selected menu_activated_ on the root ancestor is - // set to the menu the user selected and after the nested message loop exits - // Activate is invoked on this menu. - ui::MenuModel* activated_menu_; - - // The index of the item the user selected. This is set on the - // actual menu the user selects and not the root. - int activated_index_; - - // The action that took place during the call to RunMenuAt. - MenuAction menu_action_; - - // Vector of listeners to receive callbacks when the menu opens. - ObserverList<views::MenuListener> listeners_; - - // URL to invoke Menu WebUI. Default menu is chrome://menu, but - // custom menu can use different url using SetMenuURL method - // (e.g. chrome://wrench-menu for wrench menu). - GURL menu_url_; - - // A guard flag to avoid calling MenuListener::OnMenuOpened twice. - bool on_menu_opened_called_; - - // Nested dispatcher object that can outlive this object. - // This is to deal with the menu being deleted while the nested - // message loop is handled. see http://crosbug.com/7929 . - views::NestedDispatcherGtk* nested_dispatcher_; - - DISALLOW_COPY_AND_ASSIGN(NativeMenuWebUI); -}; - -} // namespace chromeos - -#endif // CHROME_BROWSER_CHROMEOS_VIEWS_NATIVE_MENU_WEBUI_H_ diff --git a/chrome/browser/chromeos/views/webui_menu_widget.cc b/chrome/browser/chromeos/views/webui_menu_widget.cc deleted file mode 100644 index 78dcc9e..0000000 --- a/chrome/browser/chromeos/views/webui_menu_widget.cc +++ /dev/null @@ -1,339 +0,0 @@ -// 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. - -#include "chrome/browser/chromeos/views/webui_menu_widget.h" - -#include <algorithm> - -#include "base/stringprintf.h" -#include "base/singleton.h" -#include "base/task.h" -#include "base/utf_string_conversions.h" -#include "chrome/browser/chromeos/views/menu_locator.h" -#include "chrome/browser/chromeos/views/native_menu_webui.h" -#include "chrome/browser/chromeos/wm_ipc.h" -#include "chrome/browser/ui/views/dom_view.h" -#include "chrome/common/url_constants.h" -#include "content/browser/renderer_host/render_view_host.h" -#include "content/browser/renderer_host/render_widget_host_view.h" -#include "content/browser/tab_contents/tab_contents.h" -#include "googleurl/src/gurl.h" -#include "third_party/cros/chromeos_wm_ipc_enums.h" -#include "third_party/skia/include/effects/SkGradientShader.h" -#include "ui/gfx/canvas_skia.h" -#include "views/border.h" -#include "views/layout/layout_manager.h" -#include "views/widget/root_view.h" - -namespace { - -// Colors for the menu's gradient background. -const SkColor kMenuStartColor = SK_ColorWHITE; -const SkColor kMenuEndColor = 0xFFEEEEEE; - -// Rounded border for menu. This draws three types of rounded border, -// for context menu, dropdown menu and submenu. Please see -// menu_locator.cc for details. -class RoundedBorder : public views::Border { - public: - explicit RoundedBorder(chromeos::MenuLocator* locator) - : menu_locator_(locator) { - } - - private: - // views::Border implementations. - virtual void Paint(const views::View& view, gfx::Canvas* canvas) const { - const SkScalar* corners = menu_locator_->GetCorners(); - // The menu is in off screen so no need to draw corners. - if (!corners) - return; - int w = view.width(); - int h = view.height(); - SkRect rect = {0, 0, w, h}; - SkPath path; - path.addRoundRect(rect, corners); - SkPaint paint; - paint.setStyle(SkPaint::kFill_Style); - paint.setFlags(SkPaint::kAntiAlias_Flag); - SkPoint p[2] = { {0, 0}, {0, h} }; - SkColor colors[2] = {kMenuStartColor, kMenuEndColor}; - SkShader* s = SkGradientShader::CreateLinear( - p, colors, NULL, 2, SkShader::kClamp_TileMode, NULL); - paint.setShader(s); - // Need to unref shader, otherwise never deleted. - s->unref(); - canvas->AsCanvasSkia()->drawPath(path, paint); - } - - virtual void GetInsets(gfx::Insets* insets) const { - DCHECK(insets); - menu_locator_->GetInsets(insets); - } - - chromeos::MenuLocator* menu_locator_; // not owned - - DISALLOW_COPY_AND_ASSIGN(RoundedBorder); -}; - -class InsetsLayout : public views::LayoutManager { - public: - InsetsLayout() : views::LayoutManager() {} - - private: - // views::LayoutManager implementations. - virtual void Layout(views::View* host) { - if (!host->has_children()) - return; - gfx::Insets insets = host->GetInsets(); - views::View* view = host->GetChildViewAt(0); - - view->SetBounds(insets.left(), insets.top(), - host->width() - insets.width(), - host->height() - insets.height()); - } - - virtual gfx::Size GetPreferredSize(views::View* host) { - DCHECK(host->child_count() == 1); - gfx::Insets insets = host->GetInsets(); - gfx::Size size = host->GetChildViewAt(0)->GetPreferredSize(); - return gfx::Size(size.width() + insets.width(), - size.height() + insets.height()); - } - - DISALLOW_COPY_AND_ASSIGN(InsetsLayout); -}; - -// A gtk widget key used to test if a given WidgetGtk instance is -// a WebUIMenuWidgetKey. -const char* kWebUIMenuWidgetKey = "__WEBUI_MENU_WIDGET__"; - -} // namespace - -namespace chromeos { - -// static -WebUIMenuWidget* WebUIMenuWidget::FindWebUIMenuWidget(gfx::NativeView native) { - DCHECK(native); - native = gtk_widget_get_toplevel(native); - if (!native) - return NULL; - return static_cast<chromeos::WebUIMenuWidget*>( - g_object_get_data(G_OBJECT(native), kWebUIMenuWidgetKey)); -} - -/////////////////////////////////////////////////////////////////////////////// -// WebUIMenuWidget public: - -WebUIMenuWidget::WebUIMenuWidget(chromeos::NativeMenuWebUI* webui_menu, - bool root) - : views::WidgetGtk(views::WidgetGtk::TYPE_POPUP), - webui_menu_(webui_menu), - dom_view_(NULL), - did_input_grab_(false), - is_root_(root) { - DCHECK(webui_menu_); - // TODO(oshima): Disabling transparent until we migrate bookmark - // menus to WebUI. See crosbug.com/7718. - // MakeTransparent(); -} - -WebUIMenuWidget::~WebUIMenuWidget() { -} - -void WebUIMenuWidget::Init(gfx::NativeView parent, const gfx::Rect& bounds) { - WidgetGtk::Init(parent, bounds); - gtk_window_set_destroy_with_parent(GTK_WINDOW(GetNativeView()), TRUE); - gtk_window_set_type_hint(GTK_WINDOW(GetNativeView()), - GDK_WINDOW_TYPE_HINT_MENU); - g_object_set_data(G_OBJECT(GetNativeView()), kWebUIMenuWidgetKey, this); -} - -void WebUIMenuWidget::Hide() { - ReleaseNativeCapture(); - WidgetGtk::Hide(); - // Clears the content. - ExecuteJavascript(L"updateModel({'items':[]})"); -} - -void WebUIMenuWidget::Close() { - if (dom_view_ != NULL) { - dom_view_->parent()->RemoveChildView(dom_view_); - delete dom_view_; - dom_view_ = NULL; - } - - // Detach the webui_menu_ which is being deleted. - webui_menu_ = NULL; - views::WidgetGtk::Close(); -} - -void WebUIMenuWidget::ReleaseNativeCapture() { - WidgetGtk::ReleaseNativeCapture(); - if (did_input_grab_) { - did_input_grab_ = false; - gdk_pointer_ungrab(GDK_CURRENT_TIME); - gdk_keyboard_ungrab(GDK_CURRENT_TIME); - - ClearGrabWidget(); - } -} - -gboolean WebUIMenuWidget::OnGrabBrokeEvent(GtkWidget* widget, - GdkEvent* event) { - did_input_grab_ = false; - Hide(); - return WidgetGtk::OnGrabBrokeEvent(widget, event); -} - -void WebUIMenuWidget::OnSizeAllocate(GtkWidget* widget, - GtkAllocation* allocation) { - views::WidgetGtk::OnSizeAllocate(widget, allocation); - // Adjust location when menu gets resized. - gfx::Rect bounds = GetClientAreaScreenBounds(); - // Don't move until the menu gets contents. - if (bounds.height() > 1) { - menu_locator_->Move(this); - webui_menu_->InputIsReady(); - } -} - -gboolean MapToFocus(GtkWidget* widget, GdkEvent* event, gpointer data) { - WebUIMenuWidget* menu_widget = WebUIMenuWidget::FindWebUIMenuWidget(widget); - if (menu_widget) { - // See EnableInput for the meaning of data. - bool select_item = data != NULL; - menu_widget->EnableInput(select_item); - } - return true; -} - -void WebUIMenuWidget::EnableScroll(bool enable) { - ExecuteJavascript(StringPrintf( - L"enableScroll(%ls)", enable ? L"true" : L"false")); -} - -void WebUIMenuWidget::EnableInput(bool select_item) { - if (!dom_view_) - return; - DCHECK(dom_view_->tab_contents()->render_view_host()); - DCHECK(dom_view_->tab_contents()->render_view_host()->view()); - GtkWidget* target = - dom_view_->tab_contents()->render_view_host()->view()->GetNativeView(); - DCHECK(target); - // Skip if the widget already own the input. - if (gtk_grab_get_current() == target) - return; - - ClearGrabWidget(); - - if (!GTK_WIDGET_REALIZED(target)) { - // Wait grabbing widget if the widget is not yet realized. - // Using data as a flag. |select_item| is false if data is NULL, - // or true otherwise. - g_signal_connect(G_OBJECT(target), "map-event", - G_CALLBACK(&MapToFocus), - select_item ? this : NULL); - return; - } - - gtk_grab_add(target); - dom_view_->tab_contents()->Focus(); - if (select_item) { - ExecuteJavascript(L"selectItem()"); - } -} - -void WebUIMenuWidget::ExecuteJavascript(const std::wstring& script) { - // Don't execute if there is no DOMView associated. This is fine because - // 1) selectItem make sense only when DOMView is associated. - // 2) updateModel will be called again when a DOMView is created/assigned. - if (!dom_view_) - return; - - DCHECK(dom_view_->tab_contents()->render_view_host()); - dom_view_->tab_contents()->render_view_host()-> - ExecuteJavascriptInWebFrame(string16(), WideToUTF16Hack(script)); -} - -void WebUIMenuWidget::ShowAt(chromeos::MenuLocator* locator) { - DCHECK(webui_menu_); - menu_locator_.reset(locator); - if (!dom_view_) { - // TODO(oshima): Replace DOMView with direct use of RVH for beta. - // DOMView should be refactored to use RVH directly, but - // it'll require a lot of change and will take time. - dom_view_ = new DOMView(); - dom_view_->Init(webui_menu_->GetProfile(), NULL); - // TODO(oshima): remove extra view to draw rounded corner. - views::View* container = new views::View(); - container->AddChildView(dom_view_); - container->set_border(new RoundedBorder(locator)); - container->SetLayoutManager(new InsetsLayout()); - SetContentsView(container); - dom_view_->LoadURL(webui_menu_->menu_url()); - } else { - webui_menu_->UpdateStates(); - dom_view_->parent()->set_border(new RoundedBorder(locator)); - menu_locator_->Move(this); - } - Show(); - - // The pointer grab is captured only on the top level menu, - // all mouse event events are delivered to submenu using gtk_add_grab. - if (is_root_) { - CaptureGrab(); - } -} - -void WebUIMenuWidget::SetSize(const gfx::Size& new_size) { - DCHECK(webui_menu_); - // Ignore the empty new_size request which is called when - // menu.html is loaded. - if (new_size.IsEmpty()) - return; - int width, height; - gtk_widget_get_size_request(GetNativeView(), &width, &height); - gfx::Size real_size(std::max(new_size.width(), width), - new_size.height()); - // Ignore the size request with the same size. - gfx::Rect bounds = GetClientAreaScreenBounds(); - if (bounds.size() == real_size) - return; - menu_locator_->SetBounds(this, real_size); -} - -/////////////////////////////////////////////////////////////////////////////// -// WebUIMenuWidget private: - -void WebUIMenuWidget::CaptureGrab() { - // Release the current grab. - ClearGrabWidget(); - - // NOTE: we do this to ensure we get mouse/keyboard events from - // other apps, a grab done with gtk_grab_add doesn't get events from - // other apps. - GdkGrabStatus pointer_grab_status = - gdk_pointer_grab(window_contents()->window, FALSE, - static_cast<GdkEventMask>( - GDK_BUTTON_PRESS_MASK | GDK_BUTTON_RELEASE_MASK | - GDK_POINTER_MOTION_MASK), - NULL, NULL, GDK_CURRENT_TIME); - GdkGrabStatus keyboard_grab_status = - gdk_keyboard_grab(window_contents()->window, FALSE, - GDK_CURRENT_TIME); - - did_input_grab_ = pointer_grab_status == GDK_GRAB_SUCCESS && - keyboard_grab_status == GDK_GRAB_SUCCESS; - DCHECK(did_input_grab_); - - EnableInput(false /* no selection */); -} - -void WebUIMenuWidget::ClearGrabWidget() { - GtkWidget* grab_widget; - while ((grab_widget = gtk_grab_get_current())) - gtk_grab_remove(grab_widget); -} - -} // namespace chromeos diff --git a/chrome/browser/chromeos/views/webui_menu_widget.h b/chrome/browser/chromeos/views/webui_menu_widget.h deleted file mode 100644 index b4d3352..0000000 --- a/chrome/browser/chromeos/views/webui_menu_widget.h +++ /dev/null @@ -1,110 +0,0 @@ -// 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. - -#ifndef CHROME_BROWSER_CHROMEOS_VIEWS_WEBUI_MENU_WIDGET_H_ -#define CHROME_BROWSER_CHROMEOS_VIEWS_WEBUI_MENU_WIDGET_H_ -#pragma once - -#include <string> - -#include "views/widget/widget_gtk.h" - -class DOMView; -class ExtensionApiTest; - -namespace chromeos { - -class MenuLocator; -class NativeMenuWebUI; - -// WebUIMenuWidget is a window widget for a Web UI based menu. -class WebUIMenuWidget : public views::WidgetGtk { - public: - // Create a Window for the NativeMenuDMOUI. |root| specifies if - // the menu is root menu. - WebUIMenuWidget(NativeMenuWebUI* webui_menu, bool root); - virtual ~WebUIMenuWidget(); - - // WidgetGtk overrides: - virtual void Init(gfx::NativeView parent, const gfx::Rect& bounds) OVERRIDE; - virtual void Hide() OVERRIDE; - virtual void Close() OVERRIDE; - virtual void ReleaseNativeCapture() OVERRIDE; - virtual gboolean OnGrabBrokeEvent(GtkWidget* widget, GdkEvent* event) - OVERRIDE; - virtual void OnSizeAllocate(GtkWidget* widget, GtkAllocation* allocation) - OVERRIDE; - - // Returns NativeMenuWebUI that owns this widget. - NativeMenuWebUI* webui_menu() const { - return webui_menu_; - } - - // Returns true if the menu widget is a root. - bool is_root() const { - return is_root_; - } - - // Returns true if the menu widget has input grab. - bool did_input_grab() const { - return did_input_grab_; - } - - // Enables/Disables menu scroll. - void EnableScroll(bool enabled); - - // Tell the gtk to send all input events (mouse, keyboard) to this - // Widget. If |selectItem| is true, it highlights the selected item - // (or select 1st selectable item if none is selected). - void EnableInput(bool select_item); - - // Executes given |javascript|. - void ExecuteJavascript(const std::wstring& javascript); - - // Show the menu using |locator|. Ownership of locator is transferred - // to this widget. - void ShowAt(MenuLocator* locator); - - // Updates the size - void SetSize(const gfx::Size& new_size); - - // Returns the menu locator owned by this widget. - const MenuLocator* menu_locator() const { - return menu_locator_.get(); - } - - // Returns WebUIMenuWidget that contains given native. This returns - // NULL if not found. - static WebUIMenuWidget* FindWebUIMenuWidget(gfx::NativeView native); - - private: - // Capture the X pointer grab. This also enables input on the widget by - // calling EnableInput(false). - void CaptureGrab(); - - // Clears GTK grab. - void ClearGrabWidget(); - - // NativeMenu object that owns this widget. - NativeMenuWebUI* webui_menu_; - - // DOMView to render the menu contents. - DOMView* dom_view_; - - // MenuLocator that controls the position of this menu widget. - scoped_ptr<chromeos::MenuLocator> menu_locator_; - - // True if the widget has input grab. - bool did_input_grab_; - - // True if the widget is for root menu (very first menu in - // submenu chain). - bool is_root_; - - DISALLOW_COPY_AND_ASSIGN(WebUIMenuWidget); -}; - -} // namespace chromeos - -#endif // CHROME_BROWSER_CHROMEOS_VIEWS_WEBUI_MENU_WIDGET_H_ diff --git a/chrome/browser/chromeos/webui/menu_ui.cc b/chrome/browser/chromeos/webui/menu_ui.cc deleted file mode 100644 index bbc5bb8..0000000 --- a/chrome/browser/chromeos/webui/menu_ui.cc +++ /dev/null @@ -1,655 +0,0 @@ -// 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. - -#include "chrome/browser/chromeos/webui/menu_ui.h" - -#include <algorithm> - -#include "base/callback.h" -#include "base/command_line.h" -#include "base/json/json_writer.h" -#include "base/message_loop.h" -#include "base/singleton.h" -#include "base/string_number_conversions.h" -#include "base/string_piece.h" -#include "base/utf_string_conversions.h" -#include "base/values.h" -#include "base/weak_ptr.h" -#include "chrome/browser/chromeos/views/native_menu_webui.h" -#include "chrome/browser/chromeos/views/webui_menu_widget.h" -#include "chrome/browser/profiles/profile.h" -#include "chrome/common/chrome_switches.h" -#include "chrome/common/jstemplate_builder.h" -#include "chrome/common/url_constants.h" -#include "content/browser/browser_thread.h" -#include "content/browser/tab_contents/tab_contents.h" -#include "content/browser/tab_contents/tab_contents_delegate.h" -#include "content/browser/webui/web_ui_util.h" -#include "grit/app_resources.h" -#include "grit/browser_resources.h" -#include "ui/base/models/menu_model.h" -#include "ui/base/resource/resource_bundle.h" -#include "ui/gfx/canvas_skia.h" -#include "ui/gfx/favicon_size.h" -#include "ui/gfx/font.h" -#include "views/accelerator.h" -#include "views/controls/menu/menu_config.h" -#include "views/controls/menu/menu_image_util_gtk.h" -#include "views/widget/widget_gtk.h" - -namespace { - -// a fake resource id for not loading extra resource. -const int kNoExtraResource = -1; - -// A utility function that generates css font property from gfx::Font. -// NOTE: Returns UTF-8. -std::string GetFontShorthand(const gfx::Font* font) { - std::string out; - if (font == NULL) { - font = &(views::MenuConfig::instance().font); - } - if (font->GetStyle() & gfx::Font::BOLD) { - out.append("bold "); - } - if (font->GetStyle() & gfx::Font::ITALIC) { - out.append("italic "); - } - if (font->GetStyle() & gfx::Font::UNDERLINED) { - out.append("underline "); - } - - // TODO(oshima): The font size from gfx::Font is too small when - // used in webkit. Figure out the reason. - out.append(base::IntToString(font->GetFontSize() + 4)); - out.append("px/"); - out.append(base::IntToString(std::max(kFaviconSize, font->GetHeight()))); - out.append("px \""); - out.append(UTF16ToUTF8(font->GetFontName())); - out.append("\",sans-serif"); - return out; -} - -// Creates scroll button's up image when |up| is true or -// down image if |up| is false. -SkBitmap CreateMenuScrollArrowImage(bool up) { - const views::MenuConfig& config = views::MenuConfig::instance(); - - int height = config.scroll_arrow_height; - gfx::CanvasSkia canvas(height * 2, height, false); - - if (!up) { - // flip the direction. - canvas.scale(1.0, -1.0); - canvas.translate(0, -height); - } - // Draw triangle. - SkPath path; - path.moveTo(height, 0); - path.lineTo(0, height); - path.lineTo(height * 2, height); - SkPaint paint; - paint.setColor(SK_ColorBLACK); - paint.setStyle(SkPaint::kFill_Style); - paint.setAntiAlias(true); - canvas.drawPath(path, paint); - return canvas.ExtractBitmap(); -} - -// Returns the scroll button's up image if |up| is true, or -// "down" image otherwise. -const std::string& GetImageDataUrlForMenuScrollArrow(bool up) { - static const std::string upImage = - web_ui_util::GetImageDataUrl(CreateMenuScrollArrowImage(true)); - static const std::string downImage = - web_ui_util::GetImageDataUrl(CreateMenuScrollArrowImage(false)); - return up ? upImage : downImage; -} - -// Returns the radio button's "on" image if |on| is true, or -// "off" image otherwise. -const std::string& GetImageDataUrlForRadio(bool on) { - static const std::string onImage = - web_ui_util::GetImageDataUrl(*views::GetRadioButtonImage(true)); - static const std::string offImage = - web_ui_util::GetImageDataUrl(*views::GetRadioButtonImage(false)); - return on ? onImage : offImage; -} - -/** - * Generates a html file that uses |menu_class| as a menu implementation. - * |menu_source_id| specifies the source that contains the definition of the - * |menu_class|, or empty string to use plain "Menu". - * - * TODO(oshima): make this template to avoid repeatedly loading the - * same source/css files. - */ -std::string GetMenuUIHTMLSourceFromString( - const chromeos::MenuSourceDelegate* delegate, - const base::StringPiece& menu_template, - const std::string& menu_class, - int menu_source_id, - int menu_css_id) { -#define SET_INTEGER_PROPERTY(prop) \ - value_config.SetInteger(#prop, menu_config.prop) - - const views::MenuConfig& menu_config = views::MenuConfig::instance(); - - DictionaryValue value_config; - value_config.SetString("radioOnUrl", GetImageDataUrlForRadio(true)); - value_config.SetString("radioOffUrl", GetImageDataUrlForRadio(false)); - value_config.SetString( - "arrowUrl", web_ui_util::GetImageDataUrlFromResource(IDR_MENU_ARROW)); - value_config.SetString( - "checkUrl", web_ui_util::GetImageDataUrlFromResource(IDR_MENU_CHECK)); - - value_config.SetString( - "scrollUpUrl", GetImageDataUrlForMenuScrollArrow(true)); - value_config.SetString( - "scrollDownUrl", GetImageDataUrlForMenuScrollArrow(false)); - - SET_INTEGER_PROPERTY(item_top_margin); - SET_INTEGER_PROPERTY(item_bottom_margin); - SET_INTEGER_PROPERTY(item_no_icon_top_margin); - SET_INTEGER_PROPERTY(item_no_icon_bottom_margin); - SET_INTEGER_PROPERTY(item_left_margin); - SET_INTEGER_PROPERTY(label_to_arrow_padding); - SET_INTEGER_PROPERTY(arrow_to_edge_padding); - SET_INTEGER_PROPERTY(icon_to_label_padding); - SET_INTEGER_PROPERTY(gutter_to_label); - SET_INTEGER_PROPERTY(check_width); - SET_INTEGER_PROPERTY(check_height); - SET_INTEGER_PROPERTY(radio_width); - SET_INTEGER_PROPERTY(radio_height); - SET_INTEGER_PROPERTY(arrow_height); - SET_INTEGER_PROPERTY(arrow_width); - SET_INTEGER_PROPERTY(gutter_width); - SET_INTEGER_PROPERTY(separator_height); - SET_INTEGER_PROPERTY(render_gutter); - SET_INTEGER_PROPERTY(show_mnemonics); - SET_INTEGER_PROPERTY(scroll_arrow_height); - SET_INTEGER_PROPERTY(label_to_accelerator_padding); - - if (delegate) - delegate->AddCustomConfigValues(&value_config); - - std::string json_config; - base::JSONWriter::Write(&value_config, false, &json_config); - - DictionaryValue strings; - - strings.SetString( - "init_script", - menu_class + ".decorate(document.getElementById('viewport'));" + - " init(" + json_config + ");"); - - if (menu_source_id == kNoExtraResource) { - strings.SetString("menu_source", ""); - } else { - base::StringPiece menu_source( - ResourceBundle::GetSharedInstance().GetRawDataResource(menu_source_id)); - strings.SetString("menu_source", menu_source.as_string()); - } - if (menu_css_id == kNoExtraResource) { - strings.SetString("menu_css", ""); - } else { - base::StringPiece menu_css( - ResourceBundle::GetSharedInstance().GetRawDataResource(menu_css_id)); - strings.SetString("menu_css", menu_css.as_string()); - } - if (delegate) - delegate->AddLocalizedStrings(&strings); - - return jstemplate_builder::GetI18nTemplateHtml(menu_template, &strings); -} - -class MenuUIHTMLSource : public ChromeURLDataManager::DataSource { - public: - MenuUIHTMLSource(const chromeos::MenuSourceDelegate* delegate, - const std::string& source_name, - const std::string& menu_class, - int menu_source_id, - int menu_css_id); - - // Called when the network layer has requested a resource underneath - // the path we registered. - virtual void StartDataRequest(const std::string& path, - bool is_off_the_record, - int request_id); - virtual std::string GetMimeType(const std::string&) const { - return "text/html"; - } - - private: - virtual ~MenuUIHTMLSource() {} - - // The menu ui the source is created for. - scoped_ptr<const chromeos::MenuSourceDelegate> delegate_; - - // The name of JS Menu class to use. - const std::string menu_class_; - - // The resource id of the JS file of the menu subclass. - int menu_source_id_; - - // The resource id of the CSS file of the menu subclass. - int menu_css_id_; - - DISALLOW_COPY_AND_ASSIGN(MenuUIHTMLSource); -}; - -// The handler for Javascript messages related to the "system" view. -class MenuHandler : public chromeos::MenuHandlerBase, - public base::SupportsWeakPtr<MenuHandler>, - public TabContentsDelegate { - public: - MenuHandler(); - virtual ~MenuHandler(); - - // WebUIMessageHandler implementation. - virtual WebUIMessageHandler* Attach(WebUI* web_ui); - virtual void RegisterMessages(); - - private: - void HandleActivate(const ListValue* values); - void HandleOpenSubmenu(const ListValue* values); - void HandleCloseSubmenu(const ListValue* values); - void HandleMoveInputToSubmenu(const ListValue* values); - void HandleMoveInputToParent(const ListValue* values); - void HandleCloseAll(const ListValue* values); - void HandleModelUpdated(const ListValue* values); - // This is a utility WebUI message to print debug message. - // Menu can't use dev tool as it lives outside of browser. - // TODO(oshima): This is inconvenient and figure out how we can use - // dev tools for menus (and other WebUI that does not belong to browser). - void HandleLog(const ListValue* values); - - // TabContentsDelegate implements: - virtual void UpdatePreferredSize(const gfx::Size& new_size); - virtual void LoadingStateChanged(TabContents* contents); - - virtual void OpenURLFromTab(TabContents* source, - const GURL& url, const GURL& referrer, - WindowOpenDisposition disposition, - PageTransition::Type transition) {} - virtual void NavigationStateChanged(const TabContents* source, - unsigned changed_flags) {} - virtual void AddNewContents(TabContents* source, - TabContents* new_contents, - WindowOpenDisposition disposition, - const gfx::Rect& initial_pos, - bool user_gesture) {} - - // TODO(oshima): Handle crash - virtual void ActivateContents(TabContents* contents) {} - virtual void DeactivateContents(TabContents* contents) {} - virtual void CloseContents(TabContents* source) {} - virtual void MoveContents(TabContents* source, const gfx::Rect& pos) {} - virtual bool IsPopup(const TabContents* source) { return false; } - virtual void ToolbarSizeChanged(TabContents* source, bool is_animating) {} - virtual void UpdateTargetURL(TabContents* source, const GURL& url) {} - virtual bool CanDownload(int request_id) { return false; } - virtual bool infobars_enabled() { return false; } - virtual bool ShouldEnablePreferredSizeNotifications() { return true; } - virtual bool CanReloadContents(TabContents* source) const { return false; } - - // True if the page is loaded. - bool loaded_; - - DISALLOW_COPY_AND_ASSIGN(MenuHandler); -}; - -//////////////////////////////////////////////////////////////////////////////// -// -// MenuUIHTMLSource -// -//////////////////////////////////////////////////////////////////////////////// - -MenuUIHTMLSource::MenuUIHTMLSource(const chromeos::MenuSourceDelegate* delegate, - const std::string& source_name, - const std::string& menu_class, - int menu_source_id, - int menu_css_id) - : DataSource(source_name, MessageLoop::current()), - delegate_(delegate), - menu_class_(menu_class), - menu_source_id_(menu_source_id), - menu_css_id_(menu_css_id) { -} - -void MenuUIHTMLSource::StartDataRequest(const std::string& path, - bool is_off_the_record, - int request_id) { - static const base::StringPiece menu_template( - ResourceBundle::GetSharedInstance().GetRawDataResource(IDR_MENU_HTML)); - - // The resource string should be pure code and should not contain - // i18n string. - const std::string menu_html = GetMenuUIHTMLSourceFromString( - delegate_.get(), menu_template, menu_class_, - menu_source_id_, menu_css_id_); - - scoped_refptr<RefCountedBytes> html_bytes(new RefCountedBytes); - - // TODO(oshima): Eliminate boilerplate code. See http://crbug.com/57583 . - html_bytes->data.resize(menu_html.size()); - std::copy(menu_html.begin(), menu_html.end(), - html_bytes->data.begin()); - SendResponse(request_id, html_bytes); -} - -//////////////////////////////////////////////////////////////////////////////// -// -// MenuHandler -// -//////////////////////////////////////////////////////////////////////////////// -MenuHandler::MenuHandler() : loaded_(false) { -} - -MenuHandler::~MenuHandler() { -} - -WebUIMessageHandler* MenuHandler::Attach(WebUI* web_ui) { - WebUIMessageHandler* handler = WebUIMessageHandler::Attach(web_ui); - web_ui->tab_contents()->set_delegate(this); - return handler; -} - -void MenuHandler::RegisterMessages() { - web_ui_->RegisterMessageCallback( - "activate", - NewCallback(this, - &MenuHandler::HandleActivate)); - web_ui_->RegisterMessageCallback( - "open_submenu", - NewCallback(this, - &MenuHandler::HandleOpenSubmenu)); - web_ui_->RegisterMessageCallback( - "close_submenu", - NewCallback(this, - &MenuHandler::HandleCloseSubmenu)); - web_ui_->RegisterMessageCallback( - "move_to_submenu", - NewCallback(this, - &MenuHandler::HandleMoveInputToSubmenu)); - web_ui_->RegisterMessageCallback( - "move_to_parent", - NewCallback(this, - &MenuHandler::HandleMoveInputToParent)); - web_ui_->RegisterMessageCallback( - "close_all", - NewCallback(this, - &MenuHandler::HandleCloseAll)); - web_ui_->RegisterMessageCallback( - "model_updated", - NewCallback(this, - &MenuHandler::HandleModelUpdated)); - web_ui_->RegisterMessageCallback( - "log", - NewCallback(this, - &MenuHandler::HandleLog)); -} - -void MenuHandler::HandleActivate(const ListValue* values) { - CHECK_EQ(2U, values->GetSize()); - std::string index_str; - bool success = values->GetString(0, &index_str); - DCHECK(success); - std::string activation; - success = values->GetString(1, &activation); - DCHECK(success); - - int index; - success = base::StringToInt(index_str, &index); - DCHECK(success); - chromeos::WebUIMenuControl* control = GetMenuControl(); - if (control) { - ui::MenuModel* model = GetMenuModel(); - DCHECK(model); - DCHECK_GE(index, 0); - DCHECK(activation == "close_and_activate" || - activation == "activate_no_close") << activation; - if (model->IsEnabledAt(index)) { - control->Activate(model, - index, - activation == "close_and_activate" ? - chromeos::WebUIMenuControl::CLOSE_AND_ACTIVATE : - chromeos::WebUIMenuControl::ACTIVATE_NO_CLOSE); - } - } -} - -void MenuHandler::HandleOpenSubmenu(const ListValue* values) { - CHECK_EQ(2U, values->GetSize()); - std::string index_str; - bool success = values->GetString(0, &index_str); - DCHECK(success); - std::string y_str; - success = values->GetString(1, &y_str); - DCHECK(success); - int index; - success = base::StringToInt(index_str, &index); - DCHECK(success); - int y; - success = base::StringToInt(y_str, &y); - DCHECK(success); - chromeos::WebUIMenuControl* control = GetMenuControl(); - if (control) - control->OpenSubmenu(index, y); -} - -void MenuHandler::HandleCloseSubmenu(const ListValue* values) { - chromeos::WebUIMenuControl* control = GetMenuControl(); - if (control) - control->CloseSubmenu(); -} - -void MenuHandler::HandleMoveInputToSubmenu(const ListValue* values) { - chromeos::WebUIMenuControl* control = GetMenuControl(); - if (control) - control->MoveInputToSubmenu(); -} - -void MenuHandler::HandleMoveInputToParent(const ListValue* values) { - chromeos::WebUIMenuControl* control = GetMenuControl(); - if (control) - control->MoveInputToParent(); -} - -void MenuHandler::HandleCloseAll(const ListValue* values) { - chromeos::WebUIMenuControl* control = GetMenuControl(); - if (control) - control->CloseAll(); -} - -void MenuHandler::HandleModelUpdated(const ListValue* values) { - ui::MenuModel* model = GetMenuModel(); - if (model) - static_cast<chromeos::MenuUI*>(web_ui_)->ModelUpdated(model); -} - -void MenuHandler::HandleLog(const ListValue* values) { - CHECK_EQ(1U, values->GetSize()); - std::string msg; - bool success = values->GetString(0, &msg); - DCHECK(success); - DVLOG(1) << msg; -} - -void MenuHandler::UpdatePreferredSize(const gfx::Size& new_size) { - if (!loaded_) - return; - chromeos::WebUIMenuControl* control = GetMenuControl(); - if (control) - control->SetSize(new_size); -} - -void MenuHandler::LoadingStateChanged(TabContents* contents) { - chromeos::WebUIMenuControl* control = GetMenuControl(); - if (control && !contents->is_loading()) { - loaded_ = true; - control->OnLoad(); - HandleModelUpdated(NULL); - } -} - -} // namespace - -namespace chromeos { - -//////////////////////////////////////////////////////////////////////////////// -// -// MenuHandlerBase -// -//////////////////////////////////////////////////////////////////////////////// - -chromeos::WebUIMenuControl* MenuHandlerBase::GetMenuControl() { - WebUIMenuWidget* widget = - chromeos::WebUIMenuWidget::FindWebUIMenuWidget( - web_ui_->tab_contents()->GetNativeView()); - if (widget) - return widget->webui_menu(); // NativeMenuWebUI implements WebUIMenuControl - else - return NULL; -} - -ui::MenuModel* MenuHandlerBase::GetMenuModel() { - WebUIMenuControl* control = GetMenuControl(); - if (control) - return control->GetMenuModel(); - else - return NULL; -} - -//////////////////////////////////////////////////////////////////////////////// -// -// MenuUI -// -//////////////////////////////////////////////////////////////////////////////// - -MenuUI::MenuUI(TabContents* contents) : WebUI(contents) { - MenuHandler* handler = new MenuHandler(); - AddMessageHandler((handler)->Attach(this)); - - contents->profile()->GetChromeURLDataManager()->AddDataSource( - CreateDataSource()); -} - -MenuUI::MenuUI(TabContents* contents, ChromeURLDataManager::DataSource* source) - : WebUI(contents) { - MenuHandler* handler = new MenuHandler(); - AddMessageHandler((handler)->Attach(this)); - - contents->profile()->GetChromeURLDataManager()->AddDataSource(source); -} - -void MenuUI::ModelUpdated(const ui::MenuModel* model) { - DictionaryValue json_model; - ListValue* items = new ListValue(); - json_model.Set("items", items); - int max_icon_width = 0; - bool has_accelerator = false; - for (int index = 0; index < model->GetItemCount(); ++index) { - ui::MenuModel::ItemType type = model->GetTypeAt(index); - DictionaryValue* item; - switch (type) { - case ui::MenuModel::TYPE_SEPARATOR: - item = CreateMenuItem(model, index, "separator", - &max_icon_width, &has_accelerator); - break; - case ui::MenuModel::TYPE_RADIO: - max_icon_width = std::max(max_icon_width, 12); - item = CreateMenuItem(model, index, "radio", - &max_icon_width, &has_accelerator); - break; - case ui::MenuModel::TYPE_SUBMENU: - item = CreateMenuItem(model, index, "submenu", - &max_icon_width, &has_accelerator); - break; - case ui::MenuModel::TYPE_COMMAND: - item = CreateMenuItem(model, index, "command", - &max_icon_width, &has_accelerator); - break; - case ui::MenuModel::TYPE_CHECK: - // Add space even when unchecked. - max_icon_width = std::max(max_icon_width, 12); - item = CreateMenuItem(model, index, "check", - &max_icon_width, &has_accelerator); - break; - default: - // TODO(oshima): We don't support BUTTOM_ITEM for now. - NOTREACHED(); - continue; - } - items->Set(index, item); - } - WebUIMenuWidget* widget = - chromeos::WebUIMenuWidget::FindWebUIMenuWidget( - tab_contents()->GetNativeView()); - DCHECK(widget); - json_model.SetInteger("maxIconWidth", max_icon_width); - json_model.SetBoolean("isRoot", widget->is_root()); - json_model.SetBoolean("hasAccelerator", has_accelerator); - CallJavascriptFunction("updateModel", json_model); -} - -DictionaryValue* MenuUI::CreateMenuItem(const ui::MenuModel* model, - int index, - const char* type, - int* max_icon_width, - bool* has_accel) const { - // Note: Web UI uses '&' as mnemonic. - string16 label16 = model->GetLabelAt(index); - DictionaryValue* item = new DictionaryValue(); - - item->SetString("type", type); - item->SetString("label", label16); - item->SetBoolean("enabled", model->IsEnabledAt(index)); - item->SetBoolean("visible", model->IsVisibleAt(index)); - item->SetBoolean("checked", model->IsItemCheckedAt(index)); - item->SetInteger("command_id", model->GetCommandIdAt(index)); - item->SetString( - "font", GetFontShorthand(model->GetLabelFontAt(index))); - SkBitmap icon; - if (model->GetIconAt(index, &icon) && !icon.isNull() && !icon.empty()) { - item->SetString("icon", web_ui_util::GetImageDataUrl(icon)); - *max_icon_width = std::max(*max_icon_width, icon.width()); - } - views::Accelerator menu_accelerator; - if (model->GetAcceleratorAt(index, &menu_accelerator)) { - item->SetString("accel", menu_accelerator.GetShortcutText()); - *has_accel = true; - } - return item; -} - -// static -ChromeURLDataManager::DataSource* MenuUI::CreateMenuUIHTMLSource( - const MenuSourceDelegate* delegate, - const std::string& source_name, - const std::string& menu_class, - int menu_source_id, - int menu_css_id) { - return new MenuUIHTMLSource(delegate, - source_name, - menu_class, - menu_source_id, - menu_css_id); -} - -// static -bool MenuUI::IsEnabled() { - return CommandLine::ForCurrentProcess()->HasSwitch( - switches::kEnableWebUIMenu); -} - -ChromeURLDataManager::DataSource* MenuUI::CreateDataSource() { - return CreateMenuUIHTMLSource(NULL, - chrome::kChromeUIMenu, - "Menu" /* class name */, - kNoExtraResource, - kNoExtraResource); -} - -} // namespace chromeos diff --git a/chrome/browser/chromeos/webui/menu_ui.h b/chrome/browser/chromeos/webui/menu_ui.h deleted file mode 100644 index 3423aeb..0000000 --- a/chrome/browser/chromeos/webui/menu_ui.h +++ /dev/null @@ -1,97 +0,0 @@ -// 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. - -#ifndef CHROME_BROWSER_CHROMEOS_WEBUI_MENU_UI_H_ -#define CHROME_BROWSER_CHROMEOS_WEBUI_MENU_UI_H_ -#pragma once - -#include <string> - -#include "chrome/browser/ui/webui/chrome_url_data_manager.h" -#include "content/browser/webui/web_ui.h" - -class DictionaryValue; - -namespace ui{ -class MenuModel; -} // namespace ui - -namespace chromeos { - -class WebUIMenuControl; - -// MenuSourceDelegate class allows subclass to injects specific values -// to menu javascript code. -class MenuSourceDelegate { - public: - virtual ~MenuSourceDelegate() {} - // Subclass can add extra parameters or replaces default configuration. - virtual void AddCustomConfigValues(DictionaryValue* config) const {} - - // Subclass can add their values to |localized_strings| and those values - // are used by JS template builder and could be accessed via JS class - // LocalStrings. - virtual void AddLocalizedStrings(DictionaryValue* localized_strings) const {} -}; - -class MenuUI : public WebUI { - public: - explicit MenuUI(TabContents* contents); - - // A callback method that is invoked when a menu model associated - // with the WebUI Menu gets updated. - virtual void ModelUpdated(const ui::MenuModel* new_model); - - // Creates a menu item for the menu item at index in the model. - virtual DictionaryValue* CreateMenuItem(const ui::MenuModel* model, - int index, - const char* type, - int* max_icon_width, - bool* has_accel) const; - - // A utility function which creates a concrete html file from - // template file |menu_resource_id| and |menu_css_id| for given |menu_class|. - // The resource_name is the host part of WebUI's url. - static ChromeURLDataManager::DataSource* CreateMenuUIHTMLSource( - const MenuSourceDelegate* delegate, - const std::string& source_name, - const std::string& menu_class, - int menu_source_res_id, - int menu_css_res_id); - - // Returns true if DMOUI menu is enabled. - static bool IsEnabled(); - - protected: - // A constructor for subclass to initialize the MenuUI with - // different data source. - MenuUI(TabContents* contents, ChromeURLDataManager::DataSource* source); - - private: - // Create HTML Data source for the menu. - ChromeURLDataManager::DataSource* CreateDataSource(); - - DISALLOW_COPY_AND_ASSIGN(MenuUI); -}; - -// Base class for MenuUI's WebUIMessageHandler. -class MenuHandlerBase : public WebUIMessageHandler { - public: - MenuHandlerBase() : WebUIMessageHandler() {} - - // Returns the menu control that is associated with the - // MenuUI. This may return null when menu is being deleted. - WebUIMenuControl* GetMenuControl(); - - // Returns the menu model for this menu ui. - // This may return null when menu is being deleted. - ui::MenuModel* GetMenuModel(); - - private: - DISALLOW_COPY_AND_ASSIGN(MenuHandlerBase); -}; - -} // namespace chromeos - -#endif // CHROME_BROWSER_CHROMEOS_WEBUI_MENU_UI_H_ diff --git a/chrome/browser/chromeos/webui/network_menu_ui.cc b/chrome/browser/chromeos/webui/network_menu_ui.cc deleted file mode 100644 index e4553ab..0000000 --- a/chrome/browser/chromeos/webui/network_menu_ui.cc +++ /dev/null @@ -1,198 +0,0 @@ -// 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. - -#include "chrome/browser/chromeos/webui/network_menu_ui.h" - -#include "base/string_number_conversions.h" -#include "base/string_util.h" -#include "base/values.h" -#include "chrome/app/chrome_command_ids.h" -#include "chrome/browser/chromeos/status/network_menu.h" -#include "chrome/browser/chromeos/views/native_menu_webui.h" -#include "chrome/browser/chromeos/views/webui_menu_widget.h" -#include "chrome/browser/profiles/profile.h" -#include "chrome/browser/ui/webui/theme_source.h" -#include "chrome/common/url_constants.h" -#include "content/browser/browser_thread.h" -#include "content/browser/tab_contents/tab_contents.h" -#include "googleurl/src/gurl.h" -#include "grit/browser_resources.h" -#include "grit/generated_resources.h" -#include "ui/base/l10n/l10n_util.h" -#include "views/controls/menu/menu_2.h" - -namespace { - -class NetworkMenuSourceDelegate : public chromeos::MenuSourceDelegate { - public: - virtual void AddLocalizedStrings(DictionaryValue* localized_strings) const { - DCHECK(localized_strings); - - localized_strings->SetString("reconnect", l10n_util::GetStringUTF16( - IDS_NETWORK_RECONNECT_TITLE)); - localized_strings->SetString("auto_connect_this_network", - l10n_util::GetStringUTF16( - IDS_OPTIONS_SETTINGS_INTERNET_OPTIONS_AUTO_CONNECT)); - localized_strings->SetString("ssid_prompt", - l10n_util::GetStringUTF16(IDS_NETWORK_SSID_HINT)); - localized_strings->SetString("pass_prompt", - l10n_util::GetStringUTF16(IDS_NETWORK_PASSWORD_HINT)); - } -}; - -//////////////////////////////////////////////////////////////////////////////// -// -// MenuHandler -// -//////////////////////////////////////////////////////////////////////////////// - -// The handler for Javascript messages related to the "system" view. -class NetworkMenuHandler : public chromeos::MenuHandlerBase, - public base::SupportsWeakPtr<NetworkMenuHandler> { - public: - NetworkMenuHandler(); - virtual ~NetworkMenuHandler(); - - // WebUIMessageHandler implementation. - virtual void RegisterMessages(); - - private: - void HandleAction(const ListValue* values); - - DISALLOW_COPY_AND_ASSIGN(NetworkMenuHandler); -}; - -void NetworkMenuHandler::RegisterMessages() { - web_ui_->RegisterMessageCallback( - "action", - NewCallback(this, - &NetworkMenuHandler::HandleAction)); -} - -void NetworkMenuHandler::HandleAction(const ListValue* values) { - ui::MenuModel* model = GetMenuModel(); - if (model) { - chromeos::NetworkMenuUI* network_menu_ui = - static_cast<chromeos::NetworkMenuUI*>(web_ui_); - bool close_menu = network_menu_ui->ModelAction(model, values); - if (close_menu) { - chromeos::WebUIMenuWidget* widget - = chromeos::WebUIMenuWidget::FindWebUIMenuWidget( - web_ui_->tab_contents()->GetNativeView()); - if (widget) { - chromeos::NativeMenuWebUI* webui_menu = widget->webui_menu(); - if (webui_menu) - webui_menu->Hide(); - } - } - } -} - -NetworkMenuHandler::NetworkMenuHandler() { -} - -NetworkMenuHandler::~NetworkMenuHandler() { -} - -} // namespace - -namespace chromeos { - -//////////////////////////////////////////////////////////////////////////////// -// -// NetworkMenuUI -// -//////////////////////////////////////////////////////////////////////////////// - -NetworkMenuUI::NetworkMenuUI(TabContents* contents) - : chromeos::MenuUI( - contents, - ALLOW_THIS_IN_INITIALIZER_LIST( - CreateMenuUIHTMLSource(new NetworkMenuSourceDelegate(), - chrome::kChromeUINetworkMenu, - "NetworkMenu", - IDR_NETWORK_MENU_JS, - IDR_NETWORK_MENU_CSS))) { - NetworkMenuHandler* handler = new NetworkMenuHandler(); - AddMessageHandler((handler)->Attach(this)); - - // Set up chrome://theme/ source. - ThemeSource* theme = new ThemeSource(contents->profile()); - contents->profile()->GetChromeURLDataManager()->AddDataSource(theme); -} - -bool NetworkMenuUI::ModelAction(const ui::MenuModel* model, - const ListValue* values) { - const NetworkMenu* network_menu = static_cast<const NetworkMenu*>(model); - std::string action; - bool success = values->GetString(0, &action); - bool close_menu = true; - if (!success) { - LOG(WARNING) << "ModelAction called with no arguments from: " - << chrome::kChromeUINetworkMenu; - return close_menu; - } - int index; - std::string index_str; - success = values->GetString(1, &index_str); - success = success && base::StringToInt(index_str, &index); - if (!success) { - LOG(WARNING) << "ModelAction called with no index from: " - << chrome::kChromeUINetworkMenu; - return close_menu; - } - std::string passphrase; - values->GetString(2, &passphrase); // Optional - std::string ssid; - values->GetString(3, &ssid); // Optional - int auto_connect = -1; // -1 indicates default action (auto connect) - std::string auto_connect_str; - if (values->GetString(4, &auto_connect_str)) // Optional - base::StringToInt(auto_connect_str, &auto_connect); - - if (action == "connect" || action == "reconnect") { - close_menu = network_menu->ConnectToNetworkAt(index, passphrase, ssid, - auto_connect); - } else { - LOG(WARNING) << "Unrecognized action: " << action - << " from: " << chrome::kChromeUINetworkMenu; - } - return close_menu; -} - -DictionaryValue* NetworkMenuUI::CreateMenuItem(const ui::MenuModel* model, - int index, - const char* type, - int* max_icon_width, - bool* has_accel) const { - // Create a MenuUI menu item, then append network specific values. - DictionaryValue* item = MenuUI::CreateMenuItem(model, - index, - type, - max_icon_width, - has_accel); - // Network menu specific values. - const NetworkMenu* network_menu = static_cast<const NetworkMenu*>(model); - NetworkMenu::NetworkInfo info; - bool found = network_menu->GetNetworkAt(index, &info); - - item->SetBoolean("visible", found); - item->SetString("network_type", info.network_type); - item->SetString("status", info.status); - item->SetString("message", info.message); - item->SetString("ip_address", info.ip_address); - item->SetString("passphrase", info.passphrase); - item->SetBoolean("need_passphrase", info.need_passphrase); - item->SetBoolean("remembered", info.remembered); - return item; -} - -views::Menu2* NetworkMenuUI::CreateMenu2(ui::MenuModel* model) { - views::Menu2* menu = new views::Menu2(model); - NativeMenuWebUI::SetMenuURL( - menu, GURL(StringPrintf("chrome://%s", chrome::kChromeUINetworkMenu))); - return menu; -} - -} // namespace chromeos diff --git a/chrome/browser/chromeos/webui/network_menu_ui.h b/chrome/browser/chromeos/webui/network_menu_ui.h deleted file mode 100644 index 51bf0fa..0000000 --- a/chrome/browser/chromeos/webui/network_menu_ui.h +++ /dev/null @@ -1,49 +0,0 @@ -// 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. - -#ifndef CHROME_BROWSER_CHROMEOS_WEBUI_NETWORK_MENU_UI_H_ -#define CHROME_BROWSER_CHROMEOS_WEBUI_NETWORK_MENU_UI_H_ -#pragma once - -#include "chrome/browser/chromeos/webui/menu_ui.h" - -namespace ui { -class MenuModel; -} // namespace ui - -namespace views { -class Menu2; -} // namespace views - -namespace chromeos { - -class NetworkMenuUI : public MenuUI { - public: - explicit NetworkMenuUI(TabContents* contents); - - // A callback method that is invoked when the JavaScript wants - // to invoke an action in the model. - // By convention the first member of 'values' describes the action. - // Returns true if the menu should be closed. - bool ModelAction(const ui::MenuModel* model, - const ListValue* values); - - // MenuUI overrides - virtual DictionaryValue* CreateMenuItem(const ui::MenuModel* model, - int index, - const char* type, - int* max_icon_width, - bool* has_accel) const; - - // A convenient factory method to create Menu2 for the network menu. - static views::Menu2* CreateMenu2(ui::MenuModel* model); - - private: - - DISALLOW_COPY_AND_ASSIGN(NetworkMenuUI); -}; - -} // namespace chromeos - -#endif // CHROME_BROWSER_CHROMEOS_WEBUI_NETWORK_MENU_UI_H_ diff --git a/chrome/browser/chromeos/webui/wrench_menu_ui.cc b/chrome/browser/chromeos/webui/wrench_menu_ui.cc deleted file mode 100644 index db92700..0000000 --- a/chrome/browser/chromeos/webui/wrench_menu_ui.cc +++ /dev/null @@ -1,114 +0,0 @@ -// 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. - -#include "chrome/browser/chromeos/webui/wrench_menu_ui.h" - -#include "base/string_number_conversions.h" -#include "base/string_util.h" -#include "base/utf_string_conversions.h" -#include "base/values.h" -#include "base/weak_ptr.h" -#include "chrome/app/chrome_command_ids.h" -#include "chrome/browser/browser_list.h" -#include "chrome/browser/chromeos/views/native_menu_webui.h" -#include "chrome/browser/chromeos/views/webui_menu_widget.h" -#include "chrome/browser/ui/browser.h" -#include "chrome/common/url_constants.h" -#include "content/browser/tab_contents/tab_contents.h" -#include "content/common/notification_registrar.h" -#include "content/common/notification_source.h" -#include "googleurl/src/gurl.h" -#include "grit/browser_resources.h" -#include "grit/generated_resources.h" -#include "ui/base/l10n/l10n_util.h" -#include "views/controls/menu/menu_2.h" - -namespace { - -class WrenchMenuSourceDelegate : public chromeos::MenuSourceDelegate { - public: - virtual void AddCustomConfigValues(DictionaryValue* config) const { - // Resources that are necessary to build wrench menu. - config->SetInteger("IDC_CUT", IDC_CUT); - config->SetInteger("IDC_COPY", IDC_COPY); - config->SetInteger("IDC_PASTE", IDC_PASTE); - config->SetInteger("IDC_ZOOM_MINUS", IDC_ZOOM_MINUS); - config->SetInteger("IDC_ZOOM_PLUS", IDC_ZOOM_PLUS); - config->SetInteger("IDC_FULLSCREEN", IDC_FULLSCREEN); - - config->SetString("IDS_EDIT2", l10n_util::GetStringUTF8(IDS_EDIT2)); - config->SetString("IDS_ZOOM_MENU2", - l10n_util::GetStringUTF8(IDS_ZOOM_MENU2)); - config->SetString("IDS_CUT", l10n_util::GetStringUTF8(IDS_CUT)); - config->SetString("IDS_COPY", l10n_util::GetStringUTF8(IDS_COPY)); - config->SetString("IDS_PASTE", l10n_util::GetStringUTF8(IDS_PASTE)); - } -}; - -} // namespace - -namespace chromeos { - -//////////////////////////////////////////////////////////////////////////////// -// -// WrenchMenuUI -// -//////////////////////////////////////////////////////////////////////////////// - -WrenchMenuUI::WrenchMenuUI(TabContents* contents) - : chromeos::MenuUI( - contents, - ALLOW_THIS_IN_INITIALIZER_LIST( - CreateMenuUIHTMLSource(new WrenchMenuSourceDelegate(), - chrome::kChromeUIWrenchMenu, - "WrenchMenu" /* class name */, - IDR_WRENCH_MENU_JS, - IDR_WRENCH_MENU_CSS))) { - registrar_.Add(this, NotificationType::ZOOM_LEVEL_CHANGED, - Source<Profile>(GetProfile())); -} - -void WrenchMenuUI::ModelUpdated(const ui::MenuModel* new_model) { - MenuUI::ModelUpdated(new_model); - UpdateZoomControls(); -} - -void WrenchMenuUI::Observe(NotificationType type, - const NotificationSource& source, - const NotificationDetails& details) { - DCHECK_EQ(NotificationType::ZOOM_LEVEL_CHANGED, type.value); - UpdateZoomControls(); -} - -void WrenchMenuUI::UpdateZoomControls() { - WebUIMenuWidget* widget = WebUIMenuWidget::FindWebUIMenuWidget( - tab_contents()->GetNativeView()); - if (!widget || !widget->is_root()) - return; - Browser* browser = BrowserList::GetLastActive(); - if (!browser) - return; - TabContents* selected_tab = browser->GetSelectedTabContents(); - bool enable_increment = false; - bool enable_decrement = false; - int zoom = 100; - if (selected_tab) - zoom = selected_tab->GetZoomPercent(&enable_increment, &enable_decrement); - - DictionaryValue params; - params.SetBoolean("plus", enable_increment); - params.SetBoolean("minus", enable_decrement); - params.SetString("percent", l10n_util::GetStringFUTF16( - IDS_ZOOM_PERCENT, UTF8ToUTF16(base::IntToString(zoom)))); - CallJavascriptFunction("updateZoomControls", params); -} - -views::Menu2* WrenchMenuUI::CreateMenu2(ui::MenuModel* model) { - views::Menu2* menu = new views::Menu2(model); - NativeMenuWebUI::SetMenuURL( - menu, GURL(StringPrintf("chrome://%s", chrome::kChromeUIWrenchMenu))); - return menu; -} - -} // namespace chromeos diff --git a/chrome/browser/chromeos/webui/wrench_menu_ui.h b/chrome/browser/chromeos/webui/wrench_menu_ui.h deleted file mode 100644 index a18ba8c..0000000 --- a/chrome/browser/chromeos/webui/wrench_menu_ui.h +++ /dev/null @@ -1,54 +0,0 @@ -// 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. - -#ifndef CHROME_BROWSER_CHROMEOS_WEBUI_WRENCH_MENU_UI_H_ -#define CHROME_BROWSER_CHROMEOS_WEBUI_WRENCH_MENU_UI_H_ -#pragma once - -#include "chrome/browser/chromeos/webui/menu_ui.h" -#include "content/common/notification_observer.h" -#include "content/common/notification_registrar.h" -#include "content/common/notification_type.h" - -class NotificationSource; -class NotificationDetails; - -namespace ui { -class MenuModel; -} // namespace ui - -namespace views { -class Menu2; -} // namespace views - -namespace chromeos { - -class WrenchMenuUI : public MenuUI, - public NotificationObserver { - public: - explicit WrenchMenuUI(TabContents* contents); - - // MenuUI overrides: - virtual void ModelUpdated(const ui::MenuModel* new_model); - - // NotificationObserver: - virtual void Observe(NotificationType type, - const NotificationSource& source, - const NotificationDetails& details); - - // Updates zoom controls to reflect the current zooming state. - void UpdateZoomControls(); - - // A convenient factory method to create Menu2 for wrench menu. - static views::Menu2* CreateMenu2(ui::MenuModel* model); - - private: - NotificationRegistrar registrar_; - - DISALLOW_COPY_AND_ASSIGN(WrenchMenuUI); -}; - -} // namespace chromeos - -#endif // CHROME_BROWSER_CHROMEOS_WEBUI_WRENCH_MENU_UI_H_ diff --git a/chrome/browser/ui/views/toolbar_view.cc b/chrome/browser/ui/views/toolbar_view.cc index e588366..847a24c 100644 --- a/chrome/browser/ui/views/toolbar_view.cc +++ b/chrome/browser/ui/views/toolbar_view.cc @@ -40,7 +40,6 @@ #if defined(OS_CHROMEOS) #include "chrome/browser/chromeos/cros/cros_library.h" #include "chrome/browser/chromeos/cros/update_library.h" -#include "chrome/browser/chromeos/webui/wrench_menu_ui.h" #include "views/controls/menu/menu_2.h" #endif #include "chrome/browser/ui/views/wrench_menu.h" @@ -136,12 +135,6 @@ void ToolbarView::Init(Profile* profile) { forward_menu_model_.reset(new BackForwardMenuModel( browser_, BackForwardMenuModel::FORWARD_MENU)); wrench_menu_model_.reset(new WrenchMenuModel(this, browser_)); -#if defined(OS_CHROMEOS) - if (chromeos::MenuUI::IsEnabled()) { - wrench_menu_2_.reset( - chromeos::WrenchMenuUI::CreateMenu2(wrench_menu_model_.get())); - } -#endif back_ = new views::ButtonDropDown(this, back_menu_model_.get()); back_->set_triggerable_event_flags(ui::EF_LEFT_BUTTON_DOWN | ui::EF_MIDDLE_BUTTON_DOWN); @@ -268,24 +261,10 @@ bool ToolbarView::IsAppMenuFocused() { } void ToolbarView::AddMenuListener(views::MenuListener* listener) { -#if defined(OS_CHROMEOS) - if (chromeos::MenuUI::IsEnabled()) { - DCHECK(wrench_menu_2_.get()); - wrench_menu_2_->AddMenuListener(listener); - return; - } -#endif menu_listeners_.push_back(listener); } void ToolbarView::RemoveMenuListener(views::MenuListener* listener) { -#if defined(OS_CHROMEOS) - if (chromeos::MenuUI::IsEnabled()) { - DCHECK(wrench_menu_2_.get()); - wrench_menu_2_->RemoveMenuListener(listener); - return; - } -#endif for (std::vector<views::MenuListener*>::iterator i(menu_listeners_.begin()); i != menu_listeners_.end(); ++i) { if (*i == listener) { @@ -327,20 +306,6 @@ void ToolbarView::RunMenu(views::View* source, const gfx::Point& /* pt */) { bool destroyed_flag = false; destroyed_flag_ = &destroyed_flag; -#if defined(OS_CHROMEOS) - if (chromeos::MenuUI::IsEnabled()) { - gfx::Point screen_loc; - views::View::ConvertPointToScreen(app_menu_, &screen_loc); - gfx::Rect bounds(screen_loc, app_menu_->size()); - if (base::i18n::IsRTL()) - bounds.set_x(bounds.x() - app_menu_->size().width()); - wrench_menu_2_->RunMenuAt(gfx::Point(bounds.right(), bounds.bottom()), - views::Menu2::ALIGN_TOPRIGHT); - // TODO(oshima): nuke this once we made decision about go or no go - // for WebUI menu. - goto cleanup; - } -#endif wrench_menu_ = new WrenchMenu(browser_); wrench_menu_->Init(wrench_menu_model_.get()); @@ -349,9 +314,6 @@ void ToolbarView::RunMenu(views::View* source, const gfx::Point& /* pt */) { wrench_menu_->RunMenu(app_menu_); -#if defined(OS_CHROMEOS) - cleanup: -#endif if (destroyed_flag) return; destroyed_flag_ = NULL; diff --git a/chrome/chrome_browser.gypi b/chrome/chrome_browser.gypi index 674f306..25d733f3 100644 --- a/chrome/chrome_browser.gypi +++ b/chrome/chrome_browser.gypi @@ -663,15 +663,8 @@ 'browser/chromeos/views/copy_background.h', 'browser/chromeos/views/dropdown_button.cc', 'browser/chromeos/views/dropdown_button.h', - 'browser/chromeos/views/menu_locator.cc', - 'browser/chromeos/views/menu_locator.h', - 'browser/chromeos/views/native_menu_webui.cc', - 'browser/chromeos/views/native_menu_webui.h', - 'browser/chromeos/views/webui_menu_widget.cc', - 'browser/chromeos/views/webui_menu_widget.h', 'browser/chromeos/volume_bubble.cc', 'browser/chromeos/volume_bubble.h', - 'browser/chromeos/webui_menu_control.h', 'browser/chromeos/webui/accounts_options_handler.cc', 'browser/chromeos/webui/accounts_options_handler.h', 'browser/chromeos/webui/core_chromeos_options_handler.cc', @@ -711,12 +704,8 @@ 'browser/chromeos/webui/login/login_container_ui.h', 'browser/chromeos/webui/login/login_ui_helpers.cc', 'browser/chromeos/webui/login/login_ui_helpers.h', - 'browser/chromeos/webui/menu_ui.cc', - 'browser/chromeos/webui/menu_ui.h', 'browser/chromeos/webui/mobile_setup_ui.cc', 'browser/chromeos/webui/mobile_setup_ui.h', - 'browser/chromeos/webui/network_menu_ui.cc', - 'browser/chromeos/webui/network_menu_ui.h', 'browser/chromeos/webui/proxy_handler.cc', 'browser/chromeos/webui/proxy_handler.h', 'browser/chromeos/webui/register_page_ui.cc', @@ -731,8 +720,6 @@ 'browser/chromeos/webui/system_settings_provider.h', 'browser/chromeos/webui/user_image_source.cc', 'browser/chromeos/webui/user_image_source.h', - 'browser/chromeos/webui/wrench_menu_ui.cc', - 'browser/chromeos/webui/wrench_menu_ui.h', 'browser/chromeos/wm_ipc.cc', 'browser/chromeos/wm_ipc.h', 'browser/chromeos/wm_message_listener.cc', diff --git a/chrome/common/chrome_switches.cc b/chrome/common/chrome_switches.cc index a323cc3..6003784 100644 --- a/chrome/common/chrome_switches.cc +++ b/chrome/common/chrome_switches.cc @@ -1128,9 +1128,6 @@ const char kCompressSystemFeedback[] = "compress-sys-feedback"; // switch separates chrome code from the rest of ChromeOS. const char kForceStubLibcros[] = "force-stub-libcros"; -// Enables WebUI menu. -const char kEnableWebUIMenu[] = "enable-webui-menu"; - // Enables Media Player. const char kEnableMediaPlayer[] = "enable-media-player"; diff --git a/chrome/common/chrome_switches.h b/chrome/common/chrome_switches.h index e297a72..6f6e1af 100644 --- a/chrome/common/chrome_switches.h +++ b/chrome/common/chrome_switches.h @@ -315,7 +315,6 @@ extern const char kGuestSession[]; extern const char kStubCros[]; extern const char kScreenSaverUrl[]; extern const char kCompressSystemFeedback[]; -extern const char kEnableWebUIMenu[]; extern const char kEnableMediaPlayer[]; extern const char kEnableAdvancedFileSystem[]; #endif diff --git a/content/browser/webui/web_ui_factory.cc b/content/browser/webui/web_ui_factory.cc index f8685fa..b6193c1 100644 --- a/content/browser/webui/web_ui_factory.cc +++ b/content/browser/webui/web_ui_factory.cc @@ -40,12 +40,9 @@ #if defined(OS_CHROMEOS) #include "chrome/browser/chromeos/webui/imageburner_ui.h" #include "chrome/browser/chromeos/webui/keyboard_overlay_ui.h" -#include "chrome/browser/chromeos/webui/menu_ui.h" #include "chrome/browser/chromeos/webui/mobile_setup_ui.h" -#include "chrome/browser/chromeos/webui/network_menu_ui.h" #include "chrome/browser/chromeos/webui/register_page_ui.h" #include "chrome/browser/chromeos/webui/system_info_ui.h" -#include "chrome/browser/chromeos/webui/wrench_menu_ui.h" #include "chrome/browser/ui/webui/filebrowse_ui.h" #include "chrome/browser/ui/webui/mediaplayer_ui.h" #endif @@ -200,12 +197,6 @@ static WebUIFactoryFunction GetWebUIFactoryFunction(Profile* profile, return &NewWebUI<SlideshowUI>; if (url.host() == chrome::kChromeUISystemInfoHost) return &NewWebUI<SystemInfoUI>; - if (url.host() == chrome::kChromeUIMenu) - return &NewWebUI<chromeos::MenuUI>; - if (url.host() == chrome::kChromeUIWrenchMenu) - return &NewWebUI<chromeos::WrenchMenuUI>; - if (url.host() == chrome::kChromeUINetworkMenu) - return &NewWebUI<chromeos::NetworkMenuUI>; #else if (url.host() == chrome::kChromeUISettingsHost) return &NewWebUI<OptionsUI>; |