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 40 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
51 #include "ui/base/dragdrop/drop_target.h" | 51 #include "ui/base/dragdrop/drop_target.h" |
52 #include "ui/base/dragdrop/os_exchange_data.h" | 52 #include "ui/base/dragdrop/os_exchange_data.h" |
53 #include "ui/base/dragdrop/os_exchange_data_provider_win.h" | 53 #include "ui/base/dragdrop/os_exchange_data_provider_win.h" |
54 #include "ui/base/event.h" | 54 #include "ui/base/event.h" |
55 #include "ui/base/events.h" | 55 #include "ui/base/events.h" |
56 #include "ui/base/keycodes/keyboard_codes.h" | 56 #include "ui/base/keycodes/keyboard_codes.h" |
57 #include "ui/base/l10n/l10n_util.h" | 57 #include "ui/base/l10n/l10n_util.h" |
58 #include "ui/base/l10n/l10n_util_win.h" | 58 #include "ui/base/l10n/l10n_util_win.h" |
59 #include "ui/base/win/mouse_wheel_util.h" | 59 #include "ui/base/win/mouse_wheel_util.h" |
60 #include "ui/gfx/canvas.h" | 60 #include "ui/gfx/canvas.h" |
| 61 #include "ui/gfx/image/image.h" |
61 #include "ui/views/button_drag_utils.h" | 62 #include "ui/views/button_drag_utils.h" |
62 #include "ui/views/controls/menu/menu_item_view.h" | 63 #include "ui/views/controls/menu/menu_item_view.h" |
63 #include "ui/views/controls/menu/menu_model_adapter.h" | 64 #include "ui/views/controls/menu/menu_model_adapter.h" |
64 #include "ui/views/controls/menu/menu_runner.h" | 65 #include "ui/views/controls/menu/menu_runner.h" |
65 #include "ui/views/controls/textfield/native_textfield_win.h" | 66 #include "ui/views/controls/textfield/native_textfield_win.h" |
66 #include "ui/views/widget/widget.h" | 67 #include "ui/views/widget/widget.h" |
67 | 68 |
68 #pragma comment(lib, "oleacc.lib") // Needed for accessibility support. | 69 #pragma comment(lib, "oleacc.lib") // Needed for accessibility support. |
69 #pragma comment(lib, "riched20.lib") // Needed for the richedit control. | 70 #pragma comment(lib, "riched20.lib") // Needed for the richedit control. |
70 | 71 |
(...skipping 2411 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
2482 bool write_url; | 2483 bool write_url; |
2483 const bool is_all_selected = IsSelectAllForRange(sel); | 2484 const bool is_all_selected = IsSelectAllForRange(sel); |
2484 | 2485 |
2485 // |sel| was set by GetSelection(), which preserves selection direction, so | 2486 // |sel| was set by GetSelection(), which preserves selection direction, so |
2486 // sel.cpMin may not be the smaller value. | 2487 // sel.cpMin may not be the smaller value. |
2487 model()->AdjustTextForCopy(std::min(sel.cpMin, sel.cpMax), is_all_selected, | 2488 model()->AdjustTextForCopy(std::min(sel.cpMin, sel.cpMax), is_all_selected, |
2488 &text_to_write, &url, &write_url); | 2489 &text_to_write, &url, &write_url); |
2489 | 2490 |
2490 if (write_url) { | 2491 if (write_url) { |
2491 string16 title; | 2492 string16 title; |
2492 SkBitmap favicon; | 2493 gfx::Image favicon; |
2493 if (is_all_selected) | 2494 if (is_all_selected) |
2494 model()->GetDataForURLExport(&url, &title, &favicon); | 2495 model()->GetDataForURLExport(&url, &title, &favicon); |
2495 button_drag_utils::SetURLAndDragImage(url, title, favicon, &data, | 2496 button_drag_utils::SetURLAndDragImage(url, title, favicon.AsImageSkia(), |
2496 native_view_host_->GetWidget()); | 2497 &data, native_view_host_->GetWidget()); |
2497 supported_modes |= DROPEFFECT_LINK; | 2498 supported_modes |= DROPEFFECT_LINK; |
2498 content::RecordAction(UserMetricsAction("Omnibox_DragURL")); | 2499 content::RecordAction(UserMetricsAction("Omnibox_DragURL")); |
2499 } else { | 2500 } else { |
2500 supported_modes |= DROPEFFECT_MOVE; | 2501 supported_modes |= DROPEFFECT_MOVE; |
2501 content::RecordAction(UserMetricsAction("Omnibox_DragString")); | 2502 content::RecordAction(UserMetricsAction("Omnibox_DragString")); |
2502 } | 2503 } |
2503 | 2504 |
2504 data.SetString(text_to_write); | 2505 data.SetString(text_to_write); |
2505 | 2506 |
2506 scoped_refptr<ui::DragSource> drag_source(new ui::DragSource); | 2507 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); | 2635 return (rect.left - client_rect.left) + (client_rect.right - rect.right); |
2635 } | 2636 } |
2636 | 2637 |
2637 int OmniboxViewWin::WidthNeededToDisplay(const string16& text) const { | 2638 int OmniboxViewWin::WidthNeededToDisplay(const string16& text) const { |
2638 // Use font_.GetStringWidth() instead of | 2639 // Use font_.GetStringWidth() instead of |
2639 // PosFromChar(location_entry_->GetTextLength()) because PosFromChar() is | 2640 // PosFromChar(location_entry_->GetTextLength()) because PosFromChar() is |
2640 // apparently buggy. In both LTR UI and RTL UI with left-to-right layout, | 2641 // 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. | 2642 // PosFromChar(i) might return 0 when i is greater than 1. |
2642 return font_.GetStringWidth(text) + GetHorizontalMargin(); | 2643 return font_.GetStringWidth(text) + GetHorizontalMargin(); |
2643 } | 2644 } |
OLD | NEW |