| OLD | NEW |
| 1 // Copyright (c) 2006-2008 The Chromium Authors. All rights reserved. | 1 // Copyright (c) 2006-2008 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/views/tab_contents/tab_contents_view_win.h" | 5 #include "chrome/browser/views/tab_contents/tab_contents_view_win.h" |
| 6 | 6 |
| 7 #include <windows.h> | 7 #include <windows.h> |
| 8 | 8 |
| 9 #include "app/gfx/canvas_paint.h" | 9 #include "app/gfx/canvas_paint.h" |
| 10 #include "app/os_exchange_data.h" | 10 #include "app/os_exchange_data.h" |
| (...skipping 135 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 146 // We set the file contents before the URL because the URL also sets file | 146 // We set the file contents before the URL because the URL also sets file |
| 147 // contents (to a .URL shortcut). We want to prefer file content data over a | 147 // contents (to a .URL shortcut). We want to prefer file content data over a |
| 148 // shortcut so we add it first. | 148 // shortcut so we add it first. |
| 149 if (!drop_data.file_contents.empty()) { | 149 if (!drop_data.file_contents.empty()) { |
| 150 // Images without ALT text will only have a file extension so we need to | 150 // Images without ALT text will only have a file extension so we need to |
| 151 // synthesize one from the provided extension and URL. | 151 // synthesize one from the provided extension and URL. |
| 152 FilePath file_name(drop_data.file_description_filename); | 152 FilePath file_name(drop_data.file_description_filename); |
| 153 file_name = file_name.BaseName().RemoveExtension(); | 153 file_name = file_name.BaseName().RemoveExtension(); |
| 154 if (file_name.value().empty()) { | 154 if (file_name.value().empty()) { |
| 155 // Retrieve the name from the URL. | 155 // Retrieve the name from the URL. |
| 156 file_name = FilePath::FromWStringHack( | 156 std::wstring fn = net::GetSuggestedFilename(drop_data.url, "", "", L""); |
| 157 net::GetSuggestedFilename(drop_data.url, "", "", L"")); | 157 if ((fn.size() + drop_data.file_extension.size() + 1) > MAX_PATH) |
| 158 fn = fn.substr(0, MAX_PATH - drop_data.file_extension.size() - 2); |
| 159 file_name = FilePath::FromWStringHack(fn); |
| 158 } | 160 } |
| 159 file_name = file_name.ReplaceExtension(drop_data.file_extension); | 161 file_name = file_name.ReplaceExtension(drop_data.file_extension); |
| 160 data.SetFileContents(file_name.value(), drop_data.file_contents); | 162 data.SetFileContents(file_name.value(), drop_data.file_contents); |
| 161 } | 163 } |
| 162 if (!drop_data.text_html.empty()) | 164 if (!drop_data.text_html.empty()) |
| 163 data.SetHtml(drop_data.text_html, drop_data.html_base_url); | 165 data.SetHtml(drop_data.text_html, drop_data.html_base_url); |
| 164 if (drop_data.url.is_valid()) { | 166 if (drop_data.url.is_valid()) { |
| 165 if (drop_data.url.SchemeIs(chrome::kJavaScriptScheme)) { | 167 if (drop_data.url.SchemeIs(chrome::kJavaScriptScheme)) { |
| 166 // We don't want to allow javascript URLs to be dragged to the desktop, | 168 // We don't want to allow javascript URLs to be dragged to the desktop, |
| 167 // but we do want to allow them to be added to the bookmarks bar | 169 // but we do want to allow them to be added to the bookmarks bar |
| (...skipping 513 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 681 } | 683 } |
| 682 return false; | 684 return false; |
| 683 } | 685 } |
| 684 | 686 |
| 685 void TabContentsViewWin::WheelZoom(int distance) { | 687 void TabContentsViewWin::WheelZoom(int distance) { |
| 686 if (tab_contents()->delegate()) { | 688 if (tab_contents()->delegate()) { |
| 687 bool zoom_in = distance > 0; | 689 bool zoom_in = distance > 0; |
| 688 tab_contents()->delegate()->ContentsZoomChange(zoom_in); | 690 tab_contents()->delegate()->ContentsZoomChange(zoom_in); |
| 689 } | 691 } |
| 690 } | 692 } |
| OLD | NEW |