Chromium Code Reviews
chromiumcodereview-hr@appspot.gserviceaccount.com (chromiumcodereview-hr) | Please choose your nickname with Settings | Help | Chromium Project | Gerrit Changes | Sign out
(561)

Side by Side Diff: chrome/browser/views/tab_contents/tab_contents_view_win.cc

Issue 271056: Do some cleanup of file path name handling. (Closed) Base URL: svn://chrome-svn/chrome/trunk/src/
Patch Set: '' Created 11 years, 2 months ago
Use n/p to move between diff chunks; N/P to move between comments. Draft comments are only viewable by you.
Jump to:
View unified diff | Download patch | Annotate | Revision Log
« no previous file with comments | « chrome/browser/views/new_profile_dialog.cc ('k') | net/base/net_util.h » ('j') | no next file with comments »
Toggle Intra-line Diffs ('i') | Expand Comments ('e') | Collapse Comments ('c') | Show Comments Hide Comments ('s')
OLDNEW
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 120 matching lines...) Expand 10 before | Expand all | Expand 10 after
131 // We set the file contents before the URL because the URL also sets file 131 // We set the file contents before the URL because the URL also sets file
132 // contents (to a .URL shortcut). We want to prefer file content data over a 132 // contents (to a .URL shortcut). We want to prefer file content data over a
133 // shortcut so we add it first. 133 // shortcut so we add it first.
134 if (!drop_data.file_contents.empty()) { 134 if (!drop_data.file_contents.empty()) {
135 // Images without ALT text will only have a file extension so we need to 135 // Images without ALT text will only have a file extension so we need to
136 // synthesize one from the provided extension and URL. 136 // synthesize one from the provided extension and URL.
137 FilePath file_name(drop_data.file_description_filename); 137 FilePath file_name(drop_data.file_description_filename);
138 file_name = file_name.BaseName().RemoveExtension(); 138 file_name = file_name.BaseName().RemoveExtension();
139 if (file_name.value().empty()) { 139 if (file_name.value().empty()) {
140 // Retrieve the name from the URL. 140 // Retrieve the name from the URL.
141 std::wstring fn = net::GetSuggestedFilename(drop_data.url, "", "", L""); 141 file_name = net::GetSuggestedFilename(drop_data.url, "", "", "");
142 if ((fn.size() + drop_data.file_extension.size() + 1) > MAX_PATH) 142 if (file_name.value().size() + drop_data.file_extension.size() + 1 >
143 fn = fn.substr(0, MAX_PATH - drop_data.file_extension.size() - 2); 143 MAX_PATH) {
144 file_name = FilePath::FromWStringHack(fn); 144 file_name = FilePath(file_name.value().substr(
145 0, MAX_PATH - drop_data.file_extension.size() - 2));
146 }
145 } 147 }
146 file_name = file_name.ReplaceExtension(drop_data.file_extension); 148 file_name = file_name.ReplaceExtension(drop_data.file_extension);
147 data.SetFileContents(file_name.value(), drop_data.file_contents); 149 data.SetFileContents(file_name.value(), drop_data.file_contents);
148 } 150 }
149 if (!drop_data.text_html.empty()) 151 if (!drop_data.text_html.empty())
150 data.SetHtml(drop_data.text_html, drop_data.html_base_url); 152 data.SetHtml(drop_data.text_html, drop_data.html_base_url);
151 if (drop_data.url.is_valid()) { 153 if (drop_data.url.is_valid()) {
152 if (drop_data.url.SchemeIs(chrome::kJavaScriptScheme)) { 154 if (drop_data.url.SchemeIs(chrome::kJavaScriptScheme)) {
153 // We don't want to allow javascript URLs to be dragged to the desktop, 155 // We don't want to allow javascript URLs to be dragged to the desktop,
154 // but we do want to allow them to be added to the bookmarks bar 156 // but we do want to allow them to be added to the bookmarks bar
(...skipping 491 matching lines...) Expand 10 before | Expand all | Expand 10 after
646 } 648 }
647 return false; 649 return false;
648 } 650 }
649 651
650 void TabContentsViewWin::WheelZoom(int distance) { 652 void TabContentsViewWin::WheelZoom(int distance) {
651 if (tab_contents()->delegate()) { 653 if (tab_contents()->delegate()) {
652 bool zoom_in = distance > 0; 654 bool zoom_in = distance > 0;
653 tab_contents()->delegate()->ContentsZoomChange(zoom_in); 655 tab_contents()->delegate()->ContentsZoomChange(zoom_in);
654 } 656 }
655 } 657 }
OLDNEW
« no previous file with comments | « chrome/browser/views/new_profile_dialog.cc ('k') | net/base/net_util.h » ('j') | no next file with comments »

Powered by Google App Engine
This is Rietveld 408576698