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/omnibox/omnibox_view_win.h" | 5 #include "chrome/browser/ui/views/omnibox/omnibox_view_win.h" |
6 | 6 |
7 #include <algorithm> | 7 #include <algorithm> |
8 #include <locale> | 8 #include <locale> |
9 #include <string> | 9 #include <string> |
10 | 10 |
(...skipping 2471 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
2482 bool write_url; | 2482 bool write_url; |
2483 const bool is_all_selected = IsSelectAllForRange(sel); | 2483 const bool is_all_selected = IsSelectAllForRange(sel); |
2484 | 2484 |
2485 // |sel| was set by GetSelection(), which preserves selection direction, so | 2485 // |sel| was set by GetSelection(), which preserves selection direction, so |
2486 // sel.cpMin may not be the smaller value. | 2486 // sel.cpMin may not be the smaller value. |
2487 model()->AdjustTextForCopy(std::min(sel.cpMin, sel.cpMax), is_all_selected, | 2487 model()->AdjustTextForCopy(std::min(sel.cpMin, sel.cpMax), is_all_selected, |
2488 &text_to_write, &url, &write_url); | 2488 &text_to_write, &url, &write_url); |
2489 | 2489 |
2490 if (write_url) { | 2490 if (write_url) { |
2491 string16 title; | 2491 string16 title; |
2492 SkBitmap favicon; | 2492 gfx::Image favicon; |
2493 if (is_all_selected) | 2493 if (is_all_selected) |
2494 model()->GetDataForURLExport(&url, &title, &favicon); | 2494 model()->GetDataForURLExport(&url, &title, &favicon); |
2495 button_drag_utils::SetURLAndDragImage(url, title, favicon, &data, | 2495 button_drag_utils::SetURLAndDragImage(url, title, favicon.AsImageSkia(), |
2496 native_view_host_->GetWidget()); | 2496 &data, native_view_host_->GetWidget()); |
2497 supported_modes |= DROPEFFECT_LINK; | 2497 supported_modes |= DROPEFFECT_LINK; |
2498 content::RecordAction(UserMetricsAction("Omnibox_DragURL")); | 2498 content::RecordAction(UserMetricsAction("Omnibox_DragURL")); |
2499 } else { | 2499 } else { |
2500 supported_modes |= DROPEFFECT_MOVE; | 2500 supported_modes |= DROPEFFECT_MOVE; |
2501 content::RecordAction(UserMetricsAction("Omnibox_DragString")); | 2501 content::RecordAction(UserMetricsAction("Omnibox_DragString")); |
2502 } | 2502 } |
2503 | 2503 |
2504 data.SetString(text_to_write); | 2504 data.SetString(text_to_write); |
2505 | 2505 |
2506 scoped_refptr<ui::DragSource> drag_source(new ui::DragSource); | 2506 scoped_refptr<ui::DragSource> drag_source(new ui::DragSource); |
(...skipping 127 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
2634 return (rect.left - client_rect.left) + (client_rect.right - rect.right); | 2634 return (rect.left - client_rect.left) + (client_rect.right - rect.right); |
2635 } | 2635 } |
2636 | 2636 |
2637 int OmniboxViewWin::WidthNeededToDisplay(const string16& text) const { | 2637 int OmniboxViewWin::WidthNeededToDisplay(const string16& text) const { |
2638 // Use font_.GetStringWidth() instead of | 2638 // Use font_.GetStringWidth() instead of |
2639 // PosFromChar(location_entry_->GetTextLength()) because PosFromChar() is | 2639 // PosFromChar(location_entry_->GetTextLength()) because PosFromChar() is |
2640 // apparently buggy. In both LTR UI and RTL UI with left-to-right layout, | 2640 // apparently buggy. In both LTR UI and RTL UI with left-to-right layout, |
2641 // PosFromChar(i) might return 0 when i is greater than 1. | 2641 // PosFromChar(i) might return 0 when i is greater than 1. |
2642 return font_.GetStringWidth(text) + GetHorizontalMargin(); | 2642 return font_.GetStringWidth(text) + GetHorizontalMargin(); |
2643 } | 2643 } |
OLD | NEW |