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 | |
38 using content::WebContents; | 34 using content::WebContents; |
39 | 35 |
40 DEFINE_WEB_CONTENTS_USER_DATA_KEY(CoreTabHelper); | 36 DEFINE_WEB_CONTENTS_USER_DATA_KEY(CoreTabHelper); |
41 | 37 |
42 CoreTabHelper::CoreTabHelper(WebContents* web_contents) | 38 CoreTabHelper::CoreTabHelper(WebContents* web_contents) |
43 : content::WebContentsObserver(web_contents), | 39 : content::WebContentsObserver(web_contents), |
44 delegate_(NULL), | 40 delegate_(NULL), |
45 content_restrictions_(0) { | 41 content_restrictions_(0) { |
46 } | 42 } |
47 | 43 |
(...skipping 140 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
188 before_unload_end_time_ = proceed_time; | 184 before_unload_end_time_ = proceed_time; |
189 } | 185 } |
190 | 186 |
191 void CoreTabHelper::BeforeUnloadDialogCancelled() { | 187 void CoreTabHelper::BeforeUnloadDialogCancelled() { |
192 OnCloseCanceled(); | 188 OnCloseCanceled(); |
193 } | 189 } |
194 | 190 |
195 bool CoreTabHelper::OnMessageReceived(const IPC::Message& message) { | 191 bool CoreTabHelper::OnMessageReceived(const IPC::Message& message) { |
196 bool handled = true; | 192 bool handled = true; |
197 IPC_BEGIN_MESSAGE_MAP(CoreTabHelper, message) | 193 IPC_BEGIN_MESSAGE_MAP(CoreTabHelper, message) |
198 IPC_MESSAGE_HANDLER(ChromeViewHostMsg_FocusedNodeTouched, | |
199 OnFocusedNodeTouched) | |
200 IPC_MESSAGE_HANDLER(ChromeViewHostMsg_RequestThumbnailForContextNode_ACK, | 194 IPC_MESSAGE_HANDLER(ChromeViewHostMsg_RequestThumbnailForContextNode_ACK, |
201 OnRequestThumbnailForContextNodeACK) | 195 OnRequestThumbnailForContextNodeACK) |
202 IPC_MESSAGE_UNHANDLED(handled = false) | 196 IPC_MESSAGE_UNHANDLED(handled = false) |
203 IPC_END_MESSAGE_MAP() | 197 IPC_END_MESSAGE_MAP() |
204 return handled; | 198 return handled; |
205 } | 199 } |
206 | 200 |
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 | |
217 // Handles the image thumbnail for the context node, composes a image search | 201 // Handles the image thumbnail for the context node, composes a image search |
218 // request based on the received thumbnail and opens the request in a new tab. | 202 // request based on the received thumbnail and opens the request in a new tab. |
219 void CoreTabHelper::OnRequestThumbnailForContextNodeACK( | 203 void CoreTabHelper::OnRequestThumbnailForContextNodeACK( |
220 const SkBitmap& bitmap, | 204 const SkBitmap& bitmap, |
221 const gfx::Size& original_size) { | 205 const gfx::Size& original_size) { |
222 if (bitmap.isNull()) | 206 if (bitmap.isNull()) |
223 return; | 207 return; |
224 Profile* profile = | 208 Profile* profile = |
225 Profile::FromBrowserContext(web_contents()->GetBrowserContext()); | 209 Profile::FromBrowserContext(web_contents()->GetBrowserContext()); |
226 | 210 |
(...skipping 37 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
264 DCHECK(!content_type.empty()); | 248 DCHECK(!content_type.empty()); |
265 open_url_params.uses_post = true; | 249 open_url_params.uses_post = true; |
266 open_url_params.browser_initiated_post_data = | 250 open_url_params.browser_initiated_post_data = |
267 base::RefCountedString::TakeString(post_data); | 251 base::RefCountedString::TakeString(post_data); |
268 open_url_params.extra_headers += base::StringPrintf( | 252 open_url_params.extra_headers += base::StringPrintf( |
269 "%s: %s\r\n", net::HttpRequestHeaders::kContentType, | 253 "%s: %s\r\n", net::HttpRequestHeaders::kContentType, |
270 content_type.c_str()); | 254 content_type.c_str()); |
271 } | 255 } |
272 web_contents()->OpenURL(open_url_params); | 256 web_contents()->OpenURL(open_url_params); |
273 } | 257 } |
OLD | NEW |