From 729b4851c4a3dc59e40f80b8798fa9253ee074a0 Mon Sep 17 00:00:00 2001 From: "mazda@chromium.org" Date: Wed, 25 Jul 2012 21:55:02 +0000 Subject: Revert "Revert 148383 - Move the keyboard overlay view to ash." The original CL broke win_aura, which is fixed in this CL. This reverts commit b36e66174d685a4195d7cc934d978086e033a8c4. TBR=ben@chromium.org BUG=124222 TEST=None Review URL: https://chromiumcodereview.appspot.com/10824023 git-svn-id: svn://svn.chromium.org/chrome/trunk/src@148428 0039d316-1c4b-4281-b951-d872f2087c98 --- ash/DEPS | 1 + ash/ash.gyp | 5 + ash/ash_strings.grd | 4 + ash/keyboard_overlay/keyboard_overlay_delegate.cc | 143 ++++++++++++++++++++ ash/keyboard_overlay/keyboard_overlay_delegate.h | 56 ++++++++ ash/keyboard_overlay/keyboard_overlay_view.cc | 52 ++++++++ ash/keyboard_overlay/keyboard_overlay_view.h | 42 ++++++ .../browser/ui/views/ash/chrome_shell_delegate.cc | 8 +- .../browser/ui/views/keyboard_overlay_delegate.cc | 145 --------------------- .../browser/ui/views/keyboard_overlay_delegate.h | 52 -------- .../ui/views/keyboard_overlay_dialog_view.cc | 65 --------- .../ui/views/keyboard_overlay_dialog_view.h | 38 ------ chrome/chrome_browser.gypi | 10 -- 13 files changed, 309 insertions(+), 312 deletions(-) create mode 100644 ash/keyboard_overlay/keyboard_overlay_delegate.cc create mode 100644 ash/keyboard_overlay/keyboard_overlay_delegate.h create mode 100644 ash/keyboard_overlay/keyboard_overlay_view.cc create mode 100644 ash/keyboard_overlay/keyboard_overlay_view.h delete mode 100644 chrome/browser/ui/views/keyboard_overlay_delegate.cc delete mode 100644 chrome/browser/ui/views/keyboard_overlay_delegate.h delete mode 100644 chrome/browser/ui/views/keyboard_overlay_dialog_view.cc delete mode 100644 chrome/browser/ui/views/keyboard_overlay_dialog_view.h diff --git a/ash/DEPS b/ash/DEPS index 5681eb3..1d2a2b1 100644 --- a/ash/DEPS +++ b/ash/DEPS @@ -1,5 +1,6 @@ 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 5883fb1..eb180ba 100644 --- a/ash/ash.gyp +++ b/ash/ash.gyp @@ -33,6 +33,7 @@ '../ui/ui.gyp:ui', '../ui/ui.gyp:ui_resources', '../ui/views/views.gyp:views', + '../ui/web_dialogs/web_dialogs.gyp:web_dialogs', ], 'defines': [ 'ASH_IMPLEMENTATION', @@ -110,6 +111,10 @@ '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 8878155..826e17e 100644 --- a/ash/ash_strings.grd +++ b/ash/ash_strings.grd @@ -200,6 +200,10 @@ This file contains the strings for ash. Pull down to minimize, left or right to tile + + Keyboard Overlay + + Status tray diff --git a/ash/keyboard_overlay/keyboard_overlay_delegate.cc b/ash/keyboard_overlay/keyboard_overlay_delegate.cc new file mode 100644 index 0000000..e819a98 --- /dev/null +++ b/ash/keyboard_overlay/keyboard_overlay_delegate.cc @@ -0,0 +1,143 @@ +// 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 + +#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 { + 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* 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 new file mode 100644 index 0000000..7a63ee5 --- /dev/null +++ b/ash/keyboard_overlay/keyboard_overlay_delegate.h @@ -0,0 +1,56 @@ +// 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* 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 new file mode 100644 index 0000000..d9a7b6c --- /dev/null +++ b/ash/keyboard_overlay/keyboard_overlay_view.cc @@ -0,0 +1,52 @@ +// 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 new file mode 100644 index 0000000..a0b44e0 --- /dev/null +++ b/ash/keyboard_overlay/keyboard_overlay_view.h @@ -0,0 +1,42 @@ +// 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_ diff --git a/chrome/browser/ui/views/ash/chrome_shell_delegate.cc b/chrome/browser/ui/views/ash/chrome_shell_delegate.cc index 9f5ff2b..1e8ad69 100644 --- a/chrome/browser/ui/views/ash/chrome_shell_delegate.cc +++ b/chrome/browser/ui/views/ash/chrome_shell_delegate.cc @@ -34,6 +34,7 @@ #include "ui/aura/window.h" #if defined(OS_CHROMEOS) +#include "ash/keyboard_overlay/keyboard_overlay_view.h" #include "base/chromeos/chromeos_version.h" #include "chrome/browser/chromeos/accessibility/accessibility_util.h" #include "chrome/browser/chromeos/background/ash_user_wallpaper_delegate.h" @@ -42,7 +43,6 @@ #include "chrome/browser/chromeos/login/user_manager.h" #include "chrome/browser/chromeos/login/webui_login_display_host.h" #include "chrome/browser/chromeos/system/ash_system_tray_delegate.h" -#include "chrome/browser/ui/views/keyboard_overlay_dialog_view.h" #include "chrome/browser/ui/webui/chromeos/login/oobe_ui.h" #include "chrome/browser/ui/webui/chromeos/mobile_setup_dialog.h" #include "chromeos/dbus/dbus_thread_manager.h" @@ -262,8 +262,12 @@ bool ChromeShellDelegate::RotatePaneFocus(ash::Shell::Direction direction) { void ChromeShellDelegate::ShowKeyboardOverlay() { #if defined(OS_CHROMEOS) + // TODO(mazda): Move the show logic to ash (http://crbug.com/124222). Profile* profile = ProfileManager::GetDefaultProfileOrOffTheRecord(); - KeyboardOverlayDialogView::ShowDialog(profile, new ChromeWebContentsHandler); + std::string url(chrome::kChromeUIKeyboardOverlayURL); + KeyboardOverlayView::ShowDialog(profile, + new ChromeWebContentsHandler, + GURL(url)); #endif } diff --git a/chrome/browser/ui/views/keyboard_overlay_delegate.cc b/chrome/browser/ui/views/keyboard_overlay_delegate.cc deleted file mode 100644 index 051979e9..0000000 --- a/chrome/browser/ui/views/keyboard_overlay_delegate.cc +++ /dev/null @@ -1,145 +0,0 @@ -// Copyright (c) 2012 The Chromium Authors. All rights reserved. -// Use of this source code is governed by a BSD-style license that can be -// found in the LICENSE file. - -#include "chrome/browser/ui/views/keyboard_overlay_delegate.h" - -#include - -#include "base/bind.h" -#include "base/memory/weak_ptr.h" -#include "base/utf_string_conversions.h" -#include "base/values.h" -#include "chrome/common/url_constants.h" -#include "content/public/browser/web_ui.h" -#include "content/public/browser/web_ui_message_handler.h" -#include "googleurl/src/gurl.h" -#include "grit/generated_resources.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 { - 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) - : title_(title), - 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 { - std::string url_string(chrome::kChromeUIKeyboardOverlayURL); - return GURL(url_string); -} - -void KeyboardOverlayDelegate::GetWebUIMessageHandlers( - std::vector* 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/chrome/browser/ui/views/keyboard_overlay_delegate.h b/chrome/browser/ui/views/keyboard_overlay_delegate.h deleted file mode 100644 index 50b8a92..0000000 --- a/chrome/browser/ui/views/keyboard_overlay_delegate.h +++ /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. - -#ifndef CHROME_BROWSER_UI_VIEWS_KEYBOARD_OVERLAY_DELEGATE_H_ -#define CHROME_BROWSER_UI_VIEWS_KEYBOARD_OVERLAY_DELEGATE_H_ - -#include "base/basictypes.h" -#include "base/compiler_specific.h" -#include "ui/web_dialogs/web_dialog_delegate.h" - -namespace views { -class WebDialogView; -} - -class KeyboardOverlayDelegate : public ui::WebDialogDelegate { - public: - explicit KeyboardOverlayDelegate(const string16& title); - - 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* 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 view associated with this delegate. - // This class does not own the pointer. - views::WebDialogView* view_; - - DISALLOW_COPY_AND_ASSIGN(KeyboardOverlayDelegate); -}; - -#endif // CHROME_BROWSER_UI_VIEWS_KEYBOARD_OVERLAY_DELEGATE_H_ diff --git a/chrome/browser/ui/views/keyboard_overlay_dialog_view.cc b/chrome/browser/ui/views/keyboard_overlay_dialog_view.cc deleted file mode 100644 index 1ca47ea..0000000 --- a/chrome/browser/ui/views/keyboard_overlay_dialog_view.cc +++ /dev/null @@ -1,65 +0,0 @@ -// Copyright (c) 2012 The Chromium Authors. All rights reserved. -// Use of this source code is governed by a BSD-style license that can be -// found in the LICENSE file. - -#include "chrome/browser/ui/views/keyboard_overlay_dialog_view.h" - -#include "base/utf_string_conversions.h" -#include "chrome/browser/ui/views/keyboard_overlay_delegate.h" -#include "content/public/browser/browser_context.h" -#include "grit/generated_resources.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" - -#if defined(OS_CHROMEOS) -#include "chrome/browser/chromeos/input_method/input_method_manager.h" -#endif - -using ui::WebDialogDelegate; - -namespace { -// Store the pointer to the view currently shown. -KeyboardOverlayDialogView* g_instance = NULL; -} - -KeyboardOverlayDialogView::KeyboardOverlayDialogView( - content::BrowserContext* context, - WebDialogDelegate* delegate, - WebContentsHandler* handler) - : views::WebDialogView(context, delegate, handler) { -} - -KeyboardOverlayDialogView::~KeyboardOverlayDialogView() { -} - -void KeyboardOverlayDialogView::ShowDialog( - content::BrowserContext* context, - WebContentsHandler* handler) { - // Ignore the call if another view is already shown. - if (g_instance) - return; - -#if defined(OS_CHROMEOS) - // Temporarily disable all accelerators for IME switching including Shift+Alt - // since the user might press Shift+Alt to remember an accelerator that starts - // with Shift+Alt (e.g. Shift+Alt+Tab for moving focus backwards). - chromeos::input_method::InputMethodManager::GetInstance()->DisableHotkeys(); -#endif - KeyboardOverlayDelegate* delegate = new KeyboardOverlayDelegate( - l10n_util::GetStringUTF16(IDS_KEYBOARD_OVERLAY_TITLE)); - KeyboardOverlayDialogView* view = - new KeyboardOverlayDialogView(context, delegate, handler); - delegate->Show(view); - - g_instance = view; -} - -void KeyboardOverlayDialogView::WindowClosing() { -#if defined(OS_CHROMEOS) - // Re-enable the IME accelerators. See the comment in ShowDialog() above. - chromeos::input_method::InputMethodManager::GetInstance()->EnableHotkeys(); -#endif - g_instance = NULL; -} diff --git a/chrome/browser/ui/views/keyboard_overlay_dialog_view.h b/chrome/browser/ui/views/keyboard_overlay_dialog_view.h deleted file mode 100644 index 2eecf3ef..0000000 --- a/chrome/browser/ui/views/keyboard_overlay_dialog_view.h +++ /dev/null @@ -1,38 +0,0 @@ -// Copyright (c) 2012 The Chromium Authors. All rights reserved. -// Use of this source code is governed by a BSD-style license that can be -// found in the LICENSE file. - -#ifndef CHROME_BROWSER_UI_VIEWS_KEYBOARD_OVERLAY_DIALOG_VIEW_H_ -#define CHROME_BROWSER_UI_VIEWS_KEYBOARD_OVERLAY_DIALOG_VIEW_H_ - -#include "base/compiler_specific.h" -#include "ui/views/controls/webview/web_dialog_view.h" - -namespace content { -class BrowserContext; -} - -namespace ui { -class WebDialogDelegate; -} - -// A customized dialog view for the keyboard overlay. -class KeyboardOverlayDialogView : public views::WebDialogView { - public: - KeyboardOverlayDialogView(content::BrowserContext* context, - ui::WebDialogDelegate* delegate, - WebContentsHandler* handler); - virtual ~KeyboardOverlayDialogView(); - - // Shows the keyboard overlay. - static void ShowDialog(content::BrowserContext* context, - WebContentsHandler* handler); - - private: - // Overridden from views::WidgetDelegate: - virtual void WindowClosing() OVERRIDE; - - DISALLOW_COPY_AND_ASSIGN(KeyboardOverlayDialogView); -}; - -#endif // CHROME_BROWSER_UI_VIEWS_KEYBOARD_OVERLAY_DIALOG_VIEW_H_ diff --git a/chrome/chrome_browser.gypi b/chrome/chrome_browser.gypi index de2dde1..da21bbd 100644 --- a/chrome/chrome_browser.gypi +++ b/chrome/chrome_browser.gypi @@ -3712,10 +3712,6 @@ 'browser/ui/views/infobars/translate_message_infobar.h', 'browser/ui/views/javascript_app_modal_dialog_views.cc', 'browser/ui/views/javascript_app_modal_dialog_views.h', - 'browser/ui/views/keyboard_overlay_delegate.cc', - 'browser/ui/views/keyboard_overlay_delegate.h', - 'browser/ui/views/keyboard_overlay_dialog_view.cc', - 'browser/ui/views/keyboard_overlay_dialog_view.h', 'browser/ui/views/location_bar/action_box_button_view.cc', 'browser/ui/views/location_bar/action_box_button_view.h', 'browser/ui/views/location_bar/chrome_to_mobile_view.cc', @@ -5169,8 +5165,6 @@ 'browser/ui/crypto_module_password_dialog.cc', 'browser/ui/crypto_module_password_dialog_nss.cc', 'browser/ui/startup/autolaunch_prompt.cc', - 'browser/ui/views/keyboard_overlay_delegate.cc', - 'browser/ui/views/keyboard_overlay_dialog_view.cc', 'browser/ui/views/simple_message_box_views.cc', 'browser/ui/webui/help/version_updater_basic.cc', 'browser/ui/webui/help/version_updater_basic.h', @@ -5247,10 +5241,6 @@ 'sources/': [ ['exclude', '^browser/chromeos/extensions/file_browser_handler_api'], ['exclude', '^browser/chromeos/extensions/file_browser_private_api'], - ['exclude', '^browser/ui/views/keyboard_overlay_delegate.cc'], - ['exclude', '^browser/ui/views/keyboard_overlay_delegate.h'], - ['exclude', '^browser/ui/views/keyboard_overlay_dialog_view.cc'], - ['exclude', '^browser/ui/views/keyboard_overlay_dialog_view.h'], ], }], # GTK build only -- cgit v1.1