Skip to content

Commit

Permalink
Move the keyboard overlay view to ash.
Browse files Browse the repository at this point in the history
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

git-svn-id: svn://svn.chromium.org/chrome/trunk/src@148383 0039d316-1c4b-4281-b951-d872f2087c98
  • Loading branch information
mazda@chromium.org committed Jul 25, 2012
1 parent 73c7151 commit 3d86000
Show file tree
Hide file tree
Showing 11 changed files with 122 additions and 126 deletions.
1 change: 1 addition & 0 deletions ash/DEPS
Original file line number Diff line number Diff line change
@@ -1,5 +1,6 @@
include_rules = [
"+chromeos",
"+content/public",
"+grit/ash_strings.h",
"+grit/ui_resources.h",
"+grit/ui_strings.h",
Expand Down
4 changes: 4 additions & 0 deletions ash/ash.gyp
Original file line number Diff line number Diff line change
Expand Up @@ -110,6 +110,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',
Expand Down
4 changes: 4 additions & 0 deletions ash/ash_strings.grd
Original file line number Diff line number Diff line change
Expand Up @@ -200,6 +200,10 @@ 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
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -2,19 +2,16 @@
// 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 "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 "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"
Expand Down Expand Up @@ -61,8 +58,10 @@ void PaintMessageHandler::DidPaint(const ListValue* args) {

} // namespace

KeyboardOverlayDelegate::KeyboardOverlayDelegate(const string16& title)
KeyboardOverlayDelegate::KeyboardOverlayDelegate(const string16& title,
const GURL& url)
: title_(title),
url_(url),
view_(NULL) {
}

Expand Down Expand Up @@ -101,8 +100,7 @@ string16 KeyboardOverlayDelegate::GetDialogTitle() const {
}

GURL KeyboardOverlayDelegate::GetDialogContentURL() const {
std::string url_string(chrome::kChromeUIKeyboardOverlayURL);
return GURL(url_string);
return url_;
}

void KeyboardOverlayDelegate::GetWebUIMessageHandlers(
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -2,11 +2,12 @@
// 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_
#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 {
Expand All @@ -15,7 +16,7 @@ class WebDialogView;

class KeyboardOverlayDelegate : public ui::WebDialogDelegate {
public:
explicit KeyboardOverlayDelegate(const string16& title);
KeyboardOverlayDelegate(const string16& title, const GURL& url);

void Show(views::WebDialogView* view);

Expand All @@ -42,11 +43,14 @@ class KeyboardOverlayDelegate : public ui::WebDialogDelegate {
// 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 // CHROME_BROWSER_UI_VIEWS_KEYBOARD_OVERLAY_DELEGATE_H_
#endif // ASH_KEYBOARD_OVERLAY_KEYBOARD_OVERLAY_DELEGATE_H_
52 changes: 52 additions & 0 deletions ash/keyboard_overlay/keyboard_overlay_view.cc
Original file line number Diff line number Diff line change
@@ -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;
}
42 changes: 42 additions & 0 deletions ash/keyboard_overlay/keyboard_overlay_view.h
Original file line number Diff line number Diff line change
@@ -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_
8 changes: 6 additions & 2 deletions chrome/browser/ui/views/ash/chrome_shell_delegate.cc
Original file line number Diff line number Diff line change
Expand Up @@ -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"
Expand All @@ -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"
Expand Down Expand Up @@ -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
}

Expand Down
65 changes: 0 additions & 65 deletions chrome/browser/ui/views/keyboard_overlay_dialog_view.cc

This file was deleted.

38 changes: 0 additions & 38 deletions chrome/browser/ui/views/keyboard_overlay_dialog_view.h

This file was deleted.

10 changes: 0 additions & 10 deletions chrome/chrome_browser.gypi
Original file line number Diff line number Diff line change
Expand Up @@ -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',
Expand Down Expand Up @@ -5167,8 +5163,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',
Expand Down Expand Up @@ -5245,10 +5239,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
Expand Down

0 comments on commit 3d86000

Please sign in to comment.