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 "ash/keyboard_overlay/keyboard_overlay_delegate.h" |
6 | 6 |
7 #include <algorithm> | 7 #include <algorithm> |
8 | 8 |
9 #include "base/bind.h" | 9 #include "base/bind.h" |
10 #include "base/memory/weak_ptr.h" | 10 #include "base/memory/weak_ptr.h" |
11 #include "base/utf_string_conversions.h" | 11 #include "base/utf_string_conversions.h" |
12 #include "base/values.h" | 12 #include "base/values.h" |
13 #include "chrome/common/url_constants.h" | |
14 #include "content/public/browser/web_ui.h" | 13 #include "content/public/browser/web_ui.h" |
15 #include "content/public/browser/web_ui_message_handler.h" | 14 #include "content/public/browser/web_ui_message_handler.h" |
16 #include "googleurl/src/gurl.h" | |
17 #include "grit/generated_resources.h" | |
18 #include "ui/base/l10n/l10n_util.h" | 15 #include "ui/base/l10n/l10n_util.h" |
19 #include "ui/gfx/screen.h" | 16 #include "ui/gfx/screen.h" |
20 #include "ui/views/controls/webview/web_dialog_view.h" | 17 #include "ui/views/controls/webview/web_dialog_view.h" |
21 #include "ui/views/widget/widget.h" | 18 #include "ui/views/widget/widget.h" |
22 | 19 |
23 using content::WebContents; | 20 using content::WebContents; |
24 using content::WebUIMessageHandler; | 21 using content::WebUIMessageHandler; |
25 | 22 |
26 namespace { | 23 namespace { |
27 | 24 |
(...skipping 26 matching lines...) Expand all Loading... |
54 base::Bind(&PaintMessageHandler::DidPaint, base::Unretained(this))); | 51 base::Bind(&PaintMessageHandler::DidPaint, base::Unretained(this))); |
55 } | 52 } |
56 | 53 |
57 void PaintMessageHandler::DidPaint(const ListValue* args) { | 54 void PaintMessageHandler::DidPaint(const ListValue* args) { |
58 // Show the widget after the web content has been painted. | 55 // Show the widget after the web content has been painted. |
59 widget_->Show(); | 56 widget_->Show(); |
60 } | 57 } |
61 | 58 |
62 } // namespace | 59 } // namespace |
63 | 60 |
64 KeyboardOverlayDelegate::KeyboardOverlayDelegate(const string16& title) | 61 KeyboardOverlayDelegate::KeyboardOverlayDelegate(const string16& title, |
| 62 const GURL& url) |
65 : title_(title), | 63 : title_(title), |
| 64 url_(url), |
66 view_(NULL) { | 65 view_(NULL) { |
67 } | 66 } |
68 | 67 |
69 KeyboardOverlayDelegate::~KeyboardOverlayDelegate() { | 68 KeyboardOverlayDelegate::~KeyboardOverlayDelegate() { |
70 } | 69 } |
71 | 70 |
72 void KeyboardOverlayDelegate::Show(views::WebDialogView* view) { | 71 void KeyboardOverlayDelegate::Show(views::WebDialogView* view) { |
73 view_ = view; | 72 view_ = view; |
74 | 73 |
75 views::Widget* widget = new views::Widget; | 74 views::Widget* widget = new views::Widget; |
(...skipping 18 matching lines...) Expand all Loading... |
94 | 93 |
95 ui::ModalType KeyboardOverlayDelegate::GetDialogModalType() const { | 94 ui::ModalType KeyboardOverlayDelegate::GetDialogModalType() const { |
96 return ui::MODAL_TYPE_SYSTEM; | 95 return ui::MODAL_TYPE_SYSTEM; |
97 } | 96 } |
98 | 97 |
99 string16 KeyboardOverlayDelegate::GetDialogTitle() const { | 98 string16 KeyboardOverlayDelegate::GetDialogTitle() const { |
100 return title_; | 99 return title_; |
101 } | 100 } |
102 | 101 |
103 GURL KeyboardOverlayDelegate::GetDialogContentURL() const { | 102 GURL KeyboardOverlayDelegate::GetDialogContentURL() const { |
104 std::string url_string(chrome::kChromeUIKeyboardOverlayURL); | 103 return url_; |
105 return GURL(url_string); | |
106 } | 104 } |
107 | 105 |
108 void KeyboardOverlayDelegate::GetWebUIMessageHandlers( | 106 void KeyboardOverlayDelegate::GetWebUIMessageHandlers( |
109 std::vector<WebUIMessageHandler*>* handlers) const { | 107 std::vector<WebUIMessageHandler*>* handlers) const { |
110 handlers->push_back(new PaintMessageHandler(view_->GetWidget())); | 108 handlers->push_back(new PaintMessageHandler(view_->GetWidget())); |
111 } | 109 } |
112 | 110 |
113 void KeyboardOverlayDelegate::GetDialogSize( | 111 void KeyboardOverlayDelegate::GetDialogSize( |
114 gfx::Size* size) const { | 112 gfx::Size* size) const { |
115 using std::min; | 113 using std::min; |
(...skipping 20 matching lines...) Expand all Loading... |
136 } | 134 } |
137 | 135 |
138 bool KeyboardOverlayDelegate::ShouldShowDialogTitle() const { | 136 bool KeyboardOverlayDelegate::ShouldShowDialogTitle() const { |
139 return false; | 137 return false; |
140 } | 138 } |
141 | 139 |
142 bool KeyboardOverlayDelegate::HandleContextMenu( | 140 bool KeyboardOverlayDelegate::HandleContextMenu( |
143 const content::ContextMenuParams& params) { | 141 const content::ContextMenuParams& params) { |
144 return true; | 142 return true; |
145 } | 143 } |
OLD | NEW |