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 "chrome/browser/ui/views/keyboard_overlay_delegate.h" | 5 #include "chrome/browser/ui/views/keyboard_overlay_delegate.h" |
6 | 6 |
7 #include <algorithm> | 7 #include <algorithm> |
8 | 8 |
9 #include "base/memory/scoped_ptr.h" | 9 #include "base/memory/scoped_ptr.h" |
10 #include "base/utf_string_conversions.h" | 10 #include "base/utf_string_conversions.h" |
11 #include "chrome/browser/chromeos/input_method/input_method_manager.h" | 11 #include "chrome/browser/chromeos/input_method/input_method_manager.h" |
12 #include "chrome/browser/ui/views/html_dialog_view.h" | 12 #include "chrome/browser/ui/views/html_dialog_view.h" |
13 #include "chrome/browser/ui/webui/html_dialog_ui.h" | 13 #include "chrome/browser/ui/webui/html_dialog_ui.h" |
14 #include "chrome/common/url_constants.h" | 14 #include "chrome/common/url_constants.h" |
15 #include "grit/generated_resources.h" | 15 #include "grit/generated_resources.h" |
16 #include "ui/base/l10n/l10n_util.h" | 16 #include "ui/base/l10n/l10n_util.h" |
17 #include "ui/gfx/screen.h" | 17 #include "ui/gfx/screen.h" |
| 18 #include "ui/views/widget/widget.h" |
18 | 19 |
19 using content::WebContents; | 20 using content::WebContents; |
20 using content::WebUIMessageHandler; | 21 using content::WebUIMessageHandler; |
21 | 22 |
22 namespace { | 23 namespace { |
23 | 24 |
24 const int kBaseWidth = 1252; | 25 const int kBaseWidth = 1252; |
25 const int kBaseHeight = 516; | 26 const int kBaseHeight = 516; |
26 const int kHorizontalMargin = 28; | 27 const int kHorizontalMargin = 28; |
27 | 28 |
(...skipping 22 matching lines...) Expand all Loading... |
50 | 51 |
51 void KeyboardOverlayDelegate::GetWebUIMessageHandlers( | 52 void KeyboardOverlayDelegate::GetWebUIMessageHandlers( |
52 std::vector<WebUIMessageHandler*>* handlers) const { | 53 std::vector<WebUIMessageHandler*>* handlers) const { |
53 } | 54 } |
54 | 55 |
55 void KeyboardOverlayDelegate::GetDialogSize( | 56 void KeyboardOverlayDelegate::GetDialogSize( |
56 gfx::Size* size) const { | 57 gfx::Size* size) const { |
57 using std::min; | 58 using std::min; |
58 DCHECK(view_); | 59 DCHECK(view_); |
59 gfx::Rect rect = gfx::Screen::GetMonitorAreaNearestWindow( | 60 gfx::Rect rect = gfx::Screen::GetMonitorAreaNearestWindow( |
60 view_->native_view()); | 61 view_->GetWidget()->GetNativeView()); |
61 const int width = min(kBaseWidth, rect.width() - kHorizontalMargin); | 62 const int width = min(kBaseWidth, rect.width() - kHorizontalMargin); |
62 const int height = width * kBaseHeight / kBaseWidth; | 63 const int height = width * kBaseHeight / kBaseWidth; |
63 size->SetSize(width, height); | 64 size->SetSize(width, height); |
64 } | 65 } |
65 | 66 |
66 std::string KeyboardOverlayDelegate::GetDialogArgs() const { | 67 std::string KeyboardOverlayDelegate::GetDialogArgs() const { |
67 return "[]"; | 68 return "[]"; |
68 } | 69 } |
69 | 70 |
70 void KeyboardOverlayDelegate::OnDialogClosed( | 71 void KeyboardOverlayDelegate::OnDialogClosed( |
71 const std::string& json_retval) { | 72 const std::string& json_retval) { |
72 // Re-enable Shift+Alt. crosbug.com/17208. | 73 // Re-enable Shift+Alt. crosbug.com/17208. |
73 chromeos::input_method::InputMethodManager::GetInstance()->EnableHotkeys(); | 74 chromeos::input_method::InputMethodManager::GetInstance()->EnableHotkeys(); |
74 delete this; | 75 delete this; |
75 return; | 76 return; |
76 } | 77 } |
77 | 78 |
78 void KeyboardOverlayDelegate::OnCloseContents(WebContents* source, | 79 void KeyboardOverlayDelegate::OnCloseContents(WebContents* source, |
79 bool* out_close_dialog) { | 80 bool* out_close_dialog) { |
80 } | 81 } |
81 | 82 |
82 bool KeyboardOverlayDelegate::ShouldShowDialogTitle() const { | 83 bool KeyboardOverlayDelegate::ShouldShowDialogTitle() const { |
83 return false; | 84 return false; |
84 } | 85 } |
85 | 86 |
86 bool KeyboardOverlayDelegate::HandleContextMenu( | 87 bool KeyboardOverlayDelegate::HandleContextMenu( |
87 const content::ContextMenuParams& params) { | 88 const content::ContextMenuParams& params) { |
88 return true; | 89 return true; |
89 } | 90 } |
OLD | NEW |