Chromium Code Reviews
chromiumcodereview-hr@appspot.gserviceaccount.com (chromiumcodereview-hr) | Please choose your nickname with Settings | Help | Chromium Project | Gerrit Changes | Sign out
(299)

Side by Side Diff: chrome/browser/ui/views/keyboard_overlay_dialog_view.cc

Issue 10271002: browser: Remove window.{cc,h} module completely. (Closed) Base URL: svn://svn.chromium.org/chrome/trunk/src
Patch Set: Created 8 years, 7 months ago
Use n/p to move between diff chunks; N/P to move between comments. Draft comments are only viewable by you.
Jump to:
View unified diff | Download patch | Annotate | Revision Log
OLDNEW
1 // Copyright (c) 2012 The Chromium Authors. All rights reserved. 1 // Copyright (c) 2012 The Chromium Authors. All rights reserved.
2 // Use of this source code is governed by a BSD-style license that can be 2 // Use of this source code is governed by a BSD-style license that can be
3 // found in the LICENSE file. 3 // found in the LICENSE file.
4 4
5 #include "chrome/browser/ui/views/keyboard_overlay_dialog_view.h" 5 #include "chrome/browser/ui/views/keyboard_overlay_dialog_view.h"
6 6
7 #include "base/utf_string_conversions.h" 7 #include "base/utf_string_conversions.h"
8 #include "chrome/browser/chromeos/input_method/input_method_manager.h" 8 #include "chrome/browser/chromeos/input_method/input_method_manager.h"
9 #include "chrome/browser/ui/browser_dialogs.h" 9 #include "chrome/browser/ui/browser_dialogs.h"
10 #include "chrome/browser/ui/views/accelerator_table.h" 10 #include "chrome/browser/ui/views/accelerator_table.h"
11 #include "chrome/browser/ui/views/frame/browser_view.h" 11 #include "chrome/browser/ui/views/frame/browser_view.h"
12 #include "chrome/browser/ui/views/keyboard_overlay_delegate.h" 12 #include "chrome/browser/ui/views/keyboard_overlay_delegate.h"
13 #include "chrome/browser/ui/views/window.h"
14 #include "content/public/browser/native_web_keyboard_event.h" 13 #include "content/public/browser/native_web_keyboard_event.h"
15 #include "grit/generated_resources.h" 14 #include "grit/generated_resources.h"
16 #include "ui/base/keycodes/keyboard_codes.h" 15 #include "ui/base/keycodes/keyboard_codes.h"
17 #include "ui/base/l10n/l10n_util.h" 16 #include "ui/base/l10n/l10n_util.h"
18 #include "ui/gfx/screen.h" 17 #include "ui/gfx/screen.h"
19 #include "ui/views/events/event.h" 18 #include "ui/views/events/event.h"
20 #include "ui/views/widget/root_view.h" 19 #include "ui/views/widget/root_view.h"
21 #include "ui/views/widget/widget.h" 20 #include "ui/views/widget/widget.h"
22 21
23 namespace { 22 namespace {
(...skipping 50 matching lines...) Expand 10 before | Expand all | Expand 10 after
74 73
75 bool KeyboardOverlayDialogView::AcceleratorPressed( 74 bool KeyboardOverlayDialogView::AcceleratorPressed(
76 const ui::Accelerator& accelerator) { 75 const ui::Accelerator& accelerator) {
77 if (!IsCloseAccelerator(accelerator)) { 76 if (!IsCloseAccelerator(accelerator)) {
78 parent_view_->AcceleratorPressed(accelerator); 77 parent_view_->AcceleratorPressed(accelerator);
79 } 78 }
80 OnDialogClosed(std::string()); 79 OnDialogClosed(std::string());
81 return true; 80 return true;
82 } 81 }
83 82
84 void KeyboardOverlayDialogView::ShowDialog( 83 void KeyboardOverlayDialogView::ShowDialog(gfx::NativeWindow owning_window,
85 gfx::NativeWindow owning_window, BrowserView* parent_view) { 84 BrowserView* parent_view) {
86 // Temporarily disable Shift+Alt. crosbug.com/17208. 85 // Temporarily disable Shift+Alt. crosbug.com/17208.
87 chromeos::input_method::InputMethodManager::GetInstance()->DisableHotkeys(); 86 chromeos::input_method::InputMethodManager::GetInstance()->DisableHotkeys();
88 87
89 KeyboardOverlayDelegate* delegate = new KeyboardOverlayDelegate( 88 KeyboardOverlayDelegate* delegate = new KeyboardOverlayDelegate(
90 l10n_util::GetStringUTF16(IDS_KEYBOARD_OVERLAY_TITLE)); 89 l10n_util::GetStringUTF16(IDS_KEYBOARD_OVERLAY_TITLE));
91 KeyboardOverlayDialogView* view = 90 KeyboardOverlayDialogView* view = new KeyboardOverlayDialogView(
92 new KeyboardOverlayDialogView(parent_view->browser()->profile(), 91 parent_view->browser()->profile(), delegate, parent_view);
93 delegate,
94 parent_view);
95 delegate->set_view(view); 92 delegate->set_view(view);
96 browser::CreateFramelessViewsWindow(owning_window, view); 93
94 views::Widget* widget = new views::Widget;
95 views::Widget::InitParams params(
96 views::Widget::InitParams::TYPE_WINDOW_FRAMELESS);
97 params.delegate = view;
98 params.parent = owning_window;
99 widget->Init(params);
100
97 // Show the widget at the bottom of the work area. 101 // Show the widget at the bottom of the work area.
98 gfx::Size size; 102 gfx::Size size;
99 delegate->GetDialogSize(&size); 103 delegate->GetDialogSize(&size);
100 gfx::Rect rect = gfx::Screen::GetMonitorNearestWindow( 104 gfx::Rect rect = gfx::Screen::GetMonitorNearestWindow(
101 view->GetWidget()->GetNativeView()).work_area(); 105 view->GetWidget()->GetNativeView()).work_area();
102 gfx::Rect bounds((rect.width() - size.width()) / 2, 106 gfx::Rect bounds((rect.width() - size.width()) / 2,
103 rect.height() - size.height(), 107 rect.height() - size.height(),
104 size.width(), 108 size.width(),
105 size.height()); 109 size.height());
106 view->GetWidget()->SetBounds(bounds); 110 view->GetWidget()->SetBounds(bounds);
107 view->GetWidget()->Show(); 111 view->GetWidget()->Show();
108 } 112 }
109 113
110 bool KeyboardOverlayDialogView::IsCloseAccelerator( 114 bool KeyboardOverlayDialogView::IsCloseAccelerator(
111 const ui::Accelerator& accelerator) { 115 const ui::Accelerator& accelerator) {
112 return close_accelerators_.find(accelerator) != close_accelerators_.end(); 116 return close_accelerators_.find(accelerator) != close_accelerators_.end();
113 } 117 }
OLDNEW
« no previous file with comments | « chrome/browser/ui/views/extensions/extension_dialog.cc ('k') | chrome/browser/ui/views/window.h » ('j') | no next file with comments »

Powered by Google App Engine
This is Rietveld 408576698