OLD | NEW |
---|---|
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 "ash/keyboard_overlay/keyboard_overlay_delegate.h" | 5 #include "ash/keyboard_overlay/keyboard_overlay_delegate.h" |
6 | 6 |
7 #include <algorithm> | 7 #include <algorithm> |
8 | 8 |
9 #include "ash/shell.h" | |
9 #include "base/bind.h" | 10 #include "base/bind.h" |
10 #include "base/memory/weak_ptr.h" | 11 #include "base/memory/weak_ptr.h" |
11 #include "base/utf_string_conversions.h" | 12 #include "base/utf_string_conversions.h" |
12 #include "base/values.h" | 13 #include "base/values.h" |
13 #include "content/public/browser/web_ui.h" | 14 #include "content/public/browser/web_ui.h" |
14 #include "content/public/browser/web_ui_message_handler.h" | 15 #include "content/public/browser/web_ui_message_handler.h" |
15 #include "ui/base/l10n/l10n_util.h" | 16 #include "ui/base/l10n/l10n_util.h" |
16 #include "ui/gfx/screen.h" | 17 #include "ui/gfx/screen.h" |
17 #include "ui/views/controls/webview/web_dialog_view.h" | 18 #include "ui/views/controls/webview/web_dialog_view.h" |
18 #include "ui/views/widget/widget.h" | 19 #include "ui/views/widget/widget.h" |
(...skipping 54 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... | |
73 | 74 |
74 views::Widget* widget = new views::Widget; | 75 views::Widget* widget = new views::Widget; |
75 views::Widget::InitParams params( | 76 views::Widget::InitParams params( |
76 views::Widget::InitParams::TYPE_WINDOW_FRAMELESS); | 77 views::Widget::InitParams::TYPE_WINDOW_FRAMELESS); |
77 params.delegate = view; | 78 params.delegate = view; |
78 widget->Init(params); | 79 widget->Init(params); |
79 | 80 |
80 // Show the widget at the bottom of the work area. | 81 // Show the widget at the bottom of the work area. |
81 gfx::Size size; | 82 gfx::Size size; |
82 GetDialogSize(&size); | 83 GetDialogSize(&size); |
83 const gfx::Rect& rect = gfx::Screen::GetDisplayNearestWindow( | 84 const gfx::Rect& rect = ash::Shell::GetAshScreen()->GetDisplayNearestWindow( |
oshima
2012/10/10 17:58:23
this class should be in ash namespace. (confirmed
scottmg
2012/10/10 19:04:47
Done.
| |
84 widget->GetNativeView()).work_area(); | 85 widget->GetNativeView()).work_area(); |
85 gfx::Rect bounds((rect.width() - size.width()) / 2, | 86 gfx::Rect bounds((rect.width() - size.width()) / 2, |
86 rect.height() - size.height(), | 87 rect.height() - size.height(), |
87 size.width(), | 88 size.width(), |
88 size.height()); | 89 size.height()); |
89 widget->SetBounds(bounds); | 90 widget->SetBounds(bounds); |
90 | 91 |
91 // The widget will be shown when the web contents gets ready to display. | 92 // The widget will be shown when the web contents gets ready to display. |
92 } | 93 } |
93 | 94 |
(...skipping 11 matching lines...) Expand all Loading... | |
105 | 106 |
106 void KeyboardOverlayDelegate::GetWebUIMessageHandlers( | 107 void KeyboardOverlayDelegate::GetWebUIMessageHandlers( |
107 std::vector<WebUIMessageHandler*>* handlers) const { | 108 std::vector<WebUIMessageHandler*>* handlers) const { |
108 handlers->push_back(new PaintMessageHandler(view_->GetWidget())); | 109 handlers->push_back(new PaintMessageHandler(view_->GetWidget())); |
109 } | 110 } |
110 | 111 |
111 void KeyboardOverlayDelegate::GetDialogSize( | 112 void KeyboardOverlayDelegate::GetDialogSize( |
112 gfx::Size* size) const { | 113 gfx::Size* size) const { |
113 using std::min; | 114 using std::min; |
114 DCHECK(view_); | 115 DCHECK(view_); |
115 gfx::Rect rect = gfx::Screen::GetDisplayNearestWindow( | 116 gfx::Rect rect = ash::Shell::GetAshScreen()->GetDisplayNearestWindow( |
116 view_->GetWidget()->GetNativeView()).bounds(); | 117 view_->GetWidget()->GetNativeView()).bounds(); |
117 const int width = min(kBaseWidth, rect.width() - kHorizontalMargin); | 118 const int width = min(kBaseWidth, rect.width() - kHorizontalMargin); |
118 const int height = width * kBaseHeight / kBaseWidth; | 119 const int height = width * kBaseHeight / kBaseWidth; |
119 size->SetSize(width, height); | 120 size->SetSize(width, height); |
120 } | 121 } |
121 | 122 |
122 std::string KeyboardOverlayDelegate::GetDialogArgs() const { | 123 std::string KeyboardOverlayDelegate::GetDialogArgs() const { |
123 return "[]"; | 124 return "[]"; |
124 } | 125 } |
125 | 126 |
126 void KeyboardOverlayDelegate::OnDialogClosed( | 127 void KeyboardOverlayDelegate::OnDialogClosed( |
127 const std::string& json_retval) { | 128 const std::string& json_retval) { |
128 delete this; | 129 delete this; |
129 return; | 130 return; |
130 } | 131 } |
131 | 132 |
132 void KeyboardOverlayDelegate::OnCloseContents(WebContents* source, | 133 void KeyboardOverlayDelegate::OnCloseContents(WebContents* source, |
133 bool* out_close_dialog) { | 134 bool* out_close_dialog) { |
134 } | 135 } |
135 | 136 |
136 bool KeyboardOverlayDelegate::ShouldShowDialogTitle() const { | 137 bool KeyboardOverlayDelegate::ShouldShowDialogTitle() const { |
137 return false; | 138 return false; |
138 } | 139 } |
139 | 140 |
140 bool KeyboardOverlayDelegate::HandleContextMenu( | 141 bool KeyboardOverlayDelegate::HandleContextMenu( |
141 const content::ContextMenuParams& params) { | 142 const content::ContextMenuParams& params) { |
142 return true; | 143 return true; |
143 } | 144 } |
OLD | NEW |