diff options
author | rch@chromium.org <rch@chromium.org@0039d316-1c4b-4281-b951-d872f2087c98> | 2012-07-25 19:53:38 +0000 |
---|---|---|
committer | rch@chromium.org <rch@chromium.org@0039d316-1c4b-4281-b951-d872f2087c98> | 2012-07-25 19:53:38 +0000 |
commit | b36e66174d685a4195d7cc934d978086e033a8c4 (patch) | |
tree | 6c5292963542edb817c2a8da6c02861a69953da9 /ash | |
parent | 4d230e3b61a996347cdb802de44c3122c4e0b6de (diff) | |
download | chromium_src-b36e66174d685a4195d7cc934d978086e033a8c4.zip chromium_src-b36e66174d685a4195d7cc934d978086e033a8c4.tar.gz chromium_src-b36e66174d685a4195d7cc934d978086e033a8c4.tar.bz2 |
Revert 148383 - Move the keyboard overlay view to ash.
This change introduces an issue when Shift+Alt is pressed (http://code.google.com/p/chromium/issues/detail?id=131159).
I'll fix it shortly together with the more general issue (http://code.google.com/p/chromium/issues/detail?id=129834).
BUG=124222
TEST=None
Review URL: https://chromiumcodereview.appspot.com/10829003
TBR=mazda@chromium.org
Review URL: https://chromiumcodereview.appspot.com/10823017
git-svn-id: svn://svn.chromium.org/chrome/trunk/src@148385 0039d316-1c4b-4281-b951-d872f2087c98
Diffstat (limited to 'ash')
-rw-r--r-- | ash/DEPS | 1 | ||||
-rw-r--r-- | ash/ash.gyp | 4 | ||||
-rw-r--r-- | ash/ash_strings.grd | 4 | ||||
-rw-r--r-- | ash/keyboard_overlay/keyboard_overlay_delegate.cc | 143 | ||||
-rw-r--r-- | ash/keyboard_overlay/keyboard_overlay_delegate.h | 56 | ||||
-rw-r--r-- | ash/keyboard_overlay/keyboard_overlay_view.cc | 52 | ||||
-rw-r--r-- | ash/keyboard_overlay/keyboard_overlay_view.h | 42 |
7 files changed, 0 insertions, 302 deletions
@@ -1,6 +1,5 @@ include_rules = [ "+chromeos", - "+content/public", "+grit/ash_strings.h", "+grit/ui_resources.h", "+grit/ui_strings.h", diff --git a/ash/ash.gyp b/ash/ash.gyp index 13d7e9c..5883fb1 100644 --- a/ash/ash.gyp +++ b/ash/ash.gyp @@ -110,10 +110,6 @@ 'display/screen_position_controller.h', 'display/secondary_display_view.cc', 'display/secondary_display_view.h', - 'keyboard_overlay/keyboard_overlay_delegate.cc', - 'keyboard_overlay/keyboard_overlay_delegate.h', - 'keyboard_overlay/keyboard_overlay_view.cc', - 'keyboard_overlay/keyboard_overlay_view.h', 'root_window_controller.cc', 'root_window_controller.h', 'rotator/screen_rotation.cc', diff --git a/ash/ash_strings.grd b/ash/ash_strings.grd index 826e17e..8878155 100644 --- a/ash/ash_strings.grd +++ b/ash/ash_strings.grd @@ -200,10 +200,6 @@ This file contains the strings for ash. Pull down to minimize, left or right to tile </message> - <message name="IDS_ASH_KEYBOARD_OVERLAY_TITLE" desc="The title of the keyboard overlay."> - Keyboard Overlay - </message> - <!-- Status tray items --> <message name="IDS_ASH_STATUS_TRAY_ACCESSIBLE_NAME" desc="The accessible name of the status tray."> Status tray diff --git a/ash/keyboard_overlay/keyboard_overlay_delegate.cc b/ash/keyboard_overlay/keyboard_overlay_delegate.cc deleted file mode 100644 index e819a98..0000000 --- a/ash/keyboard_overlay/keyboard_overlay_delegate.cc +++ /dev/null @@ -1,143 +0,0 @@ -// Copyright (c) 2012 The Chromium Authors. All rights reserved. -// Use of this source code is governed by a BSD-style license that can be -// found in the LICENSE file. - -#include "ash/keyboard_overlay/keyboard_overlay_delegate.h" - -#include <algorithm> - -#include "base/bind.h" -#include "base/memory/weak_ptr.h" -#include "base/utf_string_conversions.h" -#include "base/values.h" -#include "content/public/browser/web_ui.h" -#include "content/public/browser/web_ui_message_handler.h" -#include "ui/base/l10n/l10n_util.h" -#include "ui/gfx/screen.h" -#include "ui/views/controls/webview/web_dialog_view.h" -#include "ui/views/widget/widget.h" - -using content::WebContents; -using content::WebUIMessageHandler; - -namespace { - -const int kBaseWidth = 1252; -const int kBaseHeight = 516; -const int kHorizontalMargin = 28; - -// A message handler for detecting the timing when the web contents is painted. -class PaintMessageHandler - : public WebUIMessageHandler, - public base::SupportsWeakPtr<PaintMessageHandler> { - public: - explicit PaintMessageHandler(views::Widget* widget) : widget_(widget) {} - virtual ~PaintMessageHandler() {} - - // WebUIMessageHandler implementation. - virtual void RegisterMessages() OVERRIDE; - - private: - void DidPaint(const ListValue* args); - - views::Widget* widget_; - - DISALLOW_COPY_AND_ASSIGN(PaintMessageHandler); -}; - -void PaintMessageHandler::RegisterMessages() { - web_ui()->RegisterMessageCallback( - "didPaint", - base::Bind(&PaintMessageHandler::DidPaint, base::Unretained(this))); -} - -void PaintMessageHandler::DidPaint(const ListValue* args) { - // Show the widget after the web content has been painted. - widget_->Show(); -} - -} // namespace - -KeyboardOverlayDelegate::KeyboardOverlayDelegate(const string16& title, - const GURL& url) - : title_(title), - url_(url), - view_(NULL) { -} - -KeyboardOverlayDelegate::~KeyboardOverlayDelegate() { -} - -void KeyboardOverlayDelegate::Show(views::WebDialogView* view) { - view_ = view; - - views::Widget* widget = new views::Widget; - views::Widget::InitParams params( - views::Widget::InitParams::TYPE_WINDOW_FRAMELESS); - params.delegate = view; - widget->Init(params); - - // Show the widget at the bottom of the work area. - gfx::Size size; - GetDialogSize(&size); - const gfx::Rect& rect = gfx::Screen::GetDisplayNearestWindow( - widget->GetNativeView()).work_area(); - gfx::Rect bounds((rect.width() - size.width()) / 2, - rect.height() - size.height(), - size.width(), - size.height()); - widget->SetBounds(bounds); - - // The widget will be shown when the web contents gets ready to display. -} - -ui::ModalType KeyboardOverlayDelegate::GetDialogModalType() const { - return ui::MODAL_TYPE_SYSTEM; -} - -string16 KeyboardOverlayDelegate::GetDialogTitle() const { - return title_; -} - -GURL KeyboardOverlayDelegate::GetDialogContentURL() const { - return url_; -} - -void KeyboardOverlayDelegate::GetWebUIMessageHandlers( - std::vector<WebUIMessageHandler*>* handlers) const { - handlers->push_back(new PaintMessageHandler(view_->GetWidget())); -} - -void KeyboardOverlayDelegate::GetDialogSize( - gfx::Size* size) const { - using std::min; - DCHECK(view_); - gfx::Rect rect = gfx::Screen::GetDisplayNearestWindow( - view_->GetWidget()->GetNativeView()).bounds(); - const int width = min(kBaseWidth, rect.width() - kHorizontalMargin); - const int height = width * kBaseHeight / kBaseWidth; - size->SetSize(width, height); -} - -std::string KeyboardOverlayDelegate::GetDialogArgs() const { - return "[]"; -} - -void KeyboardOverlayDelegate::OnDialogClosed( - const std::string& json_retval) { - delete this; - return; -} - -void KeyboardOverlayDelegate::OnCloseContents(WebContents* source, - bool* out_close_dialog) { -} - -bool KeyboardOverlayDelegate::ShouldShowDialogTitle() const { - return false; -} - -bool KeyboardOverlayDelegate::HandleContextMenu( - const content::ContextMenuParams& params) { - return true; -} diff --git a/ash/keyboard_overlay/keyboard_overlay_delegate.h b/ash/keyboard_overlay/keyboard_overlay_delegate.h deleted file mode 100644 index 7a63ee5..0000000 --- a/ash/keyboard_overlay/keyboard_overlay_delegate.h +++ /dev/null @@ -1,56 +0,0 @@ -// Copyright (c) 2012 The Chromium Authors. All rights reserved. -// Use of this source code is governed by a BSD-style license that can be -// found in the LICENSE file. - -#ifndef ASH_KEYBOARD_OVERLAY_KEYBOARD_OVERLAY_DELEGATE_H_ -#define ASH_KEYBOARD_OVERLAY_KEYBOARD_OVERLAY_DELEGATE_H_ - -#include "base/basictypes.h" -#include "base/compiler_specific.h" -#include "googleurl/src/gurl.h" -#include "ui/web_dialogs/web_dialog_delegate.h" - -namespace views { -class WebDialogView; -} - -class KeyboardOverlayDelegate : public ui::WebDialogDelegate { - public: - KeyboardOverlayDelegate(const string16& title, const GURL& url); - - void Show(views::WebDialogView* view); - - // Overridden from ui::WebDialogDelegate: - virtual void GetDialogSize(gfx::Size* size) const OVERRIDE; - - private: - virtual ~KeyboardOverlayDelegate(); - - // Overridden from ui::WebDialogDelegate: - virtual ui::ModalType GetDialogModalType() const OVERRIDE; - virtual string16 GetDialogTitle() const OVERRIDE; - virtual GURL GetDialogContentURL() const OVERRIDE; - virtual void GetWebUIMessageHandlers( - std::vector<content::WebUIMessageHandler*>* handlers) const OVERRIDE; - virtual std::string GetDialogArgs() const OVERRIDE; - virtual void OnDialogClosed(const std::string& json_retval) OVERRIDE; - virtual void OnCloseContents(content::WebContents* source, - bool* out_close_dialog) OVERRIDE; - virtual bool ShouldShowDialogTitle() const OVERRIDE; - virtual bool HandleContextMenu( - const content::ContextMenuParams& params) OVERRIDE; - - // The dialog title. - string16 title_; - - // The URL of the keyboard overlay. - GURL url_; - - // The view associated with this delegate. - // This class does not own the pointer. - views::WebDialogView* view_; - - DISALLOW_COPY_AND_ASSIGN(KeyboardOverlayDelegate); -}; - -#endif // ASH_KEYBOARD_OVERLAY_KEYBOARD_OVERLAY_DELEGATE_H_ diff --git a/ash/keyboard_overlay/keyboard_overlay_view.cc b/ash/keyboard_overlay/keyboard_overlay_view.cc deleted file mode 100644 index d9a7b6c..0000000 --- a/ash/keyboard_overlay/keyboard_overlay_view.cc +++ /dev/null @@ -1,52 +0,0 @@ -// Copyright (c) 2012 The Chromium Authors. All rights reserved. -// Use of this source code is governed by a BSD-style license that can be -// found in the LICENSE file. - -#include "ash/keyboard_overlay/keyboard_overlay_view.h" - -#include "ash/keyboard_overlay/keyboard_overlay_delegate.h" -#include "base/utf_string_conversions.h" -#include "content/public/browser/browser_context.h" -#include "grit/ash_strings.h" -#include "ui/base/l10n/l10n_util.h" -#include "ui/gfx/screen.h" -#include "ui/views/widget/widget.h" -#include "ui/web_dialogs/web_dialog_delegate.h" - -using ui::WebDialogDelegate; - -namespace { -// Store the pointer to the view currently shown. -KeyboardOverlayView* g_instance = NULL; -} - -KeyboardOverlayView::KeyboardOverlayView( - content::BrowserContext* context, - WebDialogDelegate* delegate, - WebContentsHandler* handler) - : views::WebDialogView(context, delegate, handler) { -} - -KeyboardOverlayView::~KeyboardOverlayView() { -} - -void KeyboardOverlayView::ShowDialog( - content::BrowserContext* context, - WebContentsHandler* handler, - const GURL& url) { - // Ignore the call if another view is already shown. - if (g_instance) - return; - - KeyboardOverlayDelegate* delegate = new KeyboardOverlayDelegate( - l10n_util::GetStringUTF16(IDS_ASH_KEYBOARD_OVERLAY_TITLE), url); - KeyboardOverlayView* view = - new KeyboardOverlayView(context, delegate, handler); - delegate->Show(view); - - g_instance = view; -} - -void KeyboardOverlayView::WindowClosing() { - g_instance = NULL; -} diff --git a/ash/keyboard_overlay/keyboard_overlay_view.h b/ash/keyboard_overlay/keyboard_overlay_view.h deleted file mode 100644 index a0b44e0..0000000 --- a/ash/keyboard_overlay/keyboard_overlay_view.h +++ /dev/null @@ -1,42 +0,0 @@ -// Copyright (c) 2012 The Chromium Authors. All rights reserved. -// Use of this source code is governed by a BSD-style license that can be -// found in the LICENSE file. - -#ifndef ASH_KEYBOARD_OVERLAY_KEYBOARD_OVERLAY_VIEW_H_ -#define ASH_KEYBOARD_OVERLAY_KEYBOARD_OVERLAY_VIEW_H_ - -#include "ash/ash_export.h" -#include "base/compiler_specific.h" -#include "ui/views/controls/webview/web_dialog_view.h" - -class GURL; - -namespace content { -class BrowserContext; -} - -namespace ui { -class WebDialogDelegate; -} - -// A customized dialog view for the keyboard overlay. -class ASH_EXPORT KeyboardOverlayView : public views::WebDialogView { - public: - KeyboardOverlayView(content::BrowserContext* context, - ui::WebDialogDelegate* delegate, - WebContentsHandler* handler); - virtual ~KeyboardOverlayView(); - - // Shows the keyboard overlay. - static void ShowDialog(content::BrowserContext* context, - WebContentsHandler* handler, - const GURL& url); - - private: - // Overridden from views::WidgetDelegate: - virtual void WindowClosing() OVERRIDE; - - DISALLOW_COPY_AND_ASSIGN(KeyboardOverlayView); -}; - -#endif // ASH_KEYBOARD_OVERLAY_KEYBOARD_OVERLAY_VIEW_H_ |