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/tab_contents/core_tab_helper.h" | 5 #include "chrome/browser/ui/tab_contents/core_tab_helper.h" |
6 | 6 |
7 #include <string> | 7 #include <string> |
8 #include <vector> | 8 #include <vector> |
9 | 9 |
10 #include "base/command_line.h" | 10 #include "base/command_line.h" |
(...skipping 13 matching lines...) Expand all Loading... |
24 #include "content/public/browser/render_process_host.h" | 24 #include "content/public/browser/render_process_host.h" |
25 #include "content/public/browser/render_view_host.h" | 25 #include "content/public/browser/render_view_host.h" |
26 #include "content/public/browser/web_contents.h" | 26 #include "content/public/browser/web_contents.h" |
27 #include "grit/generated_resources.h" | 27 #include "grit/generated_resources.h" |
28 #include "net/base/load_states.h" | 28 #include "net/base/load_states.h" |
29 #include "net/http/http_request_headers.h" | 29 #include "net/http/http_request_headers.h" |
30 #include "third_party/skia/include/core/SkBitmap.h" | 30 #include "third_party/skia/include/core/SkBitmap.h" |
31 #include "ui/base/l10n/l10n_util.h" | 31 #include "ui/base/l10n/l10n_util.h" |
32 #include "ui/gfx/codec/jpeg_codec.h" | 32 #include "ui/gfx/codec/jpeg_codec.h" |
33 | 33 |
| 34 #if defined(OS_WIN) |
| 35 #include "base/win/win_util.h" |
| 36 #endif |
| 37 |
34 using content::WebContents; | 38 using content::WebContents; |
35 | 39 |
36 DEFINE_WEB_CONTENTS_USER_DATA_KEY(CoreTabHelper); | 40 DEFINE_WEB_CONTENTS_USER_DATA_KEY(CoreTabHelper); |
37 | 41 |
38 CoreTabHelper::CoreTabHelper(WebContents* web_contents) | 42 CoreTabHelper::CoreTabHelper(WebContents* web_contents) |
39 : content::WebContentsObserver(web_contents), | 43 : content::WebContentsObserver(web_contents), |
40 delegate_(NULL), | 44 delegate_(NULL), |
41 content_restrictions_(0) { | 45 content_restrictions_(0) { |
42 } | 46 } |
43 | 47 |
(...skipping 140 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
184 before_unload_end_time_ = proceed_time; | 188 before_unload_end_time_ = proceed_time; |
185 } | 189 } |
186 | 190 |
187 void CoreTabHelper::BeforeUnloadDialogCancelled() { | 191 void CoreTabHelper::BeforeUnloadDialogCancelled() { |
188 OnCloseCanceled(); | 192 OnCloseCanceled(); |
189 } | 193 } |
190 | 194 |
191 bool CoreTabHelper::OnMessageReceived(const IPC::Message& message) { | 195 bool CoreTabHelper::OnMessageReceived(const IPC::Message& message) { |
192 bool handled = true; | 196 bool handled = true; |
193 IPC_BEGIN_MESSAGE_MAP(CoreTabHelper, message) | 197 IPC_BEGIN_MESSAGE_MAP(CoreTabHelper, message) |
| 198 IPC_MESSAGE_HANDLER(ChromeViewHostMsg_FocusedNodeTouched, |
| 199 OnFocusedNodeTouched) |
194 IPC_MESSAGE_HANDLER(ChromeViewHostMsg_RequestThumbnailForContextNode_ACK, | 200 IPC_MESSAGE_HANDLER(ChromeViewHostMsg_RequestThumbnailForContextNode_ACK, |
195 OnRequestThumbnailForContextNodeACK) | 201 OnRequestThumbnailForContextNodeACK) |
196 IPC_MESSAGE_UNHANDLED(handled = false) | 202 IPC_MESSAGE_UNHANDLED(handled = false) |
197 IPC_END_MESSAGE_MAP() | 203 IPC_END_MESSAGE_MAP() |
198 return handled; | 204 return handled; |
199 } | 205 } |
200 | 206 |
| 207 void CoreTabHelper::OnFocusedNodeTouched(bool editable) { |
| 208 #if defined(OS_WIN) && defined(USE_AURA) |
| 209 if (editable) { |
| 210 base::win::DisplayVirtualKeyboard(); |
| 211 } else { |
| 212 base::win::DismissVirtualKeyboard(); |
| 213 } |
| 214 #endif // OS_WIN && USE_AURA |
| 215 } |
| 216 |
201 // Handles the image thumbnail for the context node, composes a image search | 217 // Handles the image thumbnail for the context node, composes a image search |
202 // request based on the received thumbnail and opens the request in a new tab. | 218 // request based on the received thumbnail and opens the request in a new tab. |
203 void CoreTabHelper::OnRequestThumbnailForContextNodeACK( | 219 void CoreTabHelper::OnRequestThumbnailForContextNodeACK( |
204 const SkBitmap& bitmap, | 220 const SkBitmap& bitmap, |
205 const gfx::Size& original_size) { | 221 const gfx::Size& original_size) { |
206 if (bitmap.isNull()) | 222 if (bitmap.isNull()) |
207 return; | 223 return; |
208 Profile* profile = | 224 Profile* profile = |
209 Profile::FromBrowserContext(web_contents()->GetBrowserContext()); | 225 Profile::FromBrowserContext(web_contents()->GetBrowserContext()); |
210 | 226 |
(...skipping 37 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
248 DCHECK(!content_type.empty()); | 264 DCHECK(!content_type.empty()); |
249 open_url_params.uses_post = true; | 265 open_url_params.uses_post = true; |
250 open_url_params.browser_initiated_post_data = | 266 open_url_params.browser_initiated_post_data = |
251 base::RefCountedString::TakeString(post_data); | 267 base::RefCountedString::TakeString(post_data); |
252 open_url_params.extra_headers += base::StringPrintf( | 268 open_url_params.extra_headers += base::StringPrintf( |
253 "%s: %s\r\n", net::HttpRequestHeaders::kContentType, | 269 "%s: %s\r\n", net::HttpRequestHeaders::kContentType, |
254 content_type.c_str()); | 270 content_type.c_str()); |
255 } | 271 } |
256 web_contents()->OpenURL(open_url_params); | 272 web_contents()->OpenURL(open_url_params); |
257 } | 273 } |
OLD | NEW |