| 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 |
| 11 #include <richedit.h> | 11 #include <richedit.h> |
| 12 #include <textserv.h> | 12 #include <textserv.h> |
| 13 | 13 |
| 14 #include "base/auto_reset.h" | 14 #include "base/auto_reset.h" |
| 15 #include "base/basictypes.h" | 15 #include "base/basictypes.h" |
| 16 #include "base/i18n/rtl.h" | 16 #include "base/i18n/rtl.h" |
| 17 #include "base/lazy_instance.h" | 17 #include "base/lazy_instance.h" |
| 18 #include "base/memory/ref_counted.h" | 18 #include "base/memory/ref_counted.h" |
| 19 #include "base/string_util.h" | 19 #include "base/string_util.h" |
| 20 #include "base/utf_string_conversions.h" | 20 #include "base/utf_string_conversions.h" |
| 21 #include "base/win/iat_patch_function.h" | 21 #include "base/win/iat_patch_function.h" |
| 22 #include "base/win/metro.h" | 22 #include "base/win/metro.h" |
| 23 #include "base/win/scoped_hdc.h" | 23 #include "base/win/scoped_hdc.h" |
| 24 #include "base/win/scoped_select_object.h" | 24 #include "base/win/scoped_select_object.h" |
| 25 #include "base/win/windows_version.h" | 25 #include "base/win/windows_version.h" |
| 26 #include "chrome/app/chrome_command_ids.h" | 26 #include "chrome/app/chrome_command_ids.h" |
| 27 #include "chrome/browser/autocomplete/autocomplete_input.h" | 27 #include "chrome/browser/autocomplete/autocomplete_input.h" |
| 28 #include "chrome/browser/autocomplete/autocomplete_match.h" | 28 #include "chrome/browser/autocomplete/autocomplete_match.h" |
| 29 #include "chrome/browser/autocomplete/keyword_provider.h" | 29 #include "chrome/browser/autocomplete/keyword_provider.h" |
| 30 #include "chrome/browser/browser_process.h" | |
| 31 #include "chrome/browser/command_updater.h" | 30 #include "chrome/browser/command_updater.h" |
| 32 #include "chrome/browser/net/url_fixer_upper.h" | 31 #include "chrome/browser/net/url_fixer_upper.h" |
| 33 #include "chrome/browser/profiles/profile.h" | 32 #include "chrome/browser/profiles/profile.h" |
| 34 #include "chrome/browser/ui/browser.h" | 33 #include "chrome/browser/ui/browser.h" |
| 35 #include "chrome/browser/ui/omnibox/omnibox_edit_controller.h" | 34 #include "chrome/browser/ui/omnibox/omnibox_edit_controller.h" |
| 36 #include "chrome/browser/ui/omnibox/omnibox_popup_model.h" | 35 #include "chrome/browser/ui/omnibox/omnibox_popup_model.h" |
| 37 #include "chrome/browser/ui/views/location_bar/location_bar_view.h" | 36 #include "chrome/browser/ui/views/location_bar/location_bar_view.h" |
| 38 #include "chrome/browser/ui/views/omnibox/omnibox_view_views.h" | 37 #include "chrome/browser/ui/views/omnibox/omnibox_view_views.h" |
| 39 #include "chrome/common/chrome_notification_types.h" | 38 #include "chrome/common/chrome_notification_types.h" |
| 40 #include "content/public/browser/user_metrics.h" | 39 #include "content/public/browser/user_metrics.h" |
| (...skipping 1285 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 1326 if (text.empty()) | 1325 if (text.empty()) |
| 1327 return; | 1326 return; |
| 1328 | 1327 |
| 1329 CHARRANGE sel; | 1328 CHARRANGE sel; |
| 1330 GURL url; | 1329 GURL url; |
| 1331 bool write_url = false; | 1330 bool write_url = false; |
| 1332 GetSel(sel); | 1331 GetSel(sel); |
| 1333 // GetSel() doesn't preserve selection direction, so sel.cpMin will always be | 1332 // GetSel() doesn't preserve selection direction, so sel.cpMin will always be |
| 1334 // the smaller value. | 1333 // the smaller value. |
| 1335 model()->AdjustTextForCopy(sel.cpMin, IsSelectAll(), &text, &url, &write_url); | 1334 model()->AdjustTextForCopy(sel.cpMin, IsSelectAll(), &text, &url, &write_url); |
| 1336 ui::ScopedClipboardWriter scw(g_browser_process->clipboard(), | 1335 ui::ScopedClipboardWriter scw(ui::Clipboard::GetForCurrentThread(), |
| 1337 ui::Clipboard::BUFFER_STANDARD); | 1336 ui::Clipboard::BUFFER_STANDARD); |
| 1338 scw.WriteText(text); | 1337 scw.WriteText(text); |
| 1339 if (write_url) | 1338 if (write_url) |
| 1340 scw.WriteBookmark(text, url.spec()); | 1339 scw.WriteBookmark(text, url.spec()); |
| 1341 } | 1340 } |
| 1342 | 1341 |
| 1343 LRESULT OmniboxViewWin::OnCreate(const CREATESTRUCTW* /*create_struct*/) { | 1342 LRESULT OmniboxViewWin::OnCreate(const CREATESTRUCTW* /*create_struct*/) { |
| 1344 if (base::win::IsTsfAwareRequired()) { | 1343 if (base::win::IsTsfAwareRequired()) { |
| 1345 // Enable TSF support of RichEdit. | 1344 // Enable TSF support of RichEdit. |
| 1346 SetEditStyle(SES_USECTF, SES_USECTF); | 1345 SetEditStyle(SES_USECTF, SES_USECTF); |
| (...skipping 1294 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 2641 return (rect.left - client_rect.left) + (client_rect.right - rect.right); | 2640 return (rect.left - client_rect.left) + (client_rect.right - rect.right); |
| 2642 } | 2641 } |
| 2643 | 2642 |
| 2644 int OmniboxViewWin::WidthNeededToDisplay(const string16& text) const { | 2643 int OmniboxViewWin::WidthNeededToDisplay(const string16& text) const { |
| 2645 // Use font_.GetStringWidth() instead of | 2644 // Use font_.GetStringWidth() instead of |
| 2646 // PosFromChar(location_entry_->GetTextLength()) because PosFromChar() is | 2645 // PosFromChar(location_entry_->GetTextLength()) because PosFromChar() is |
| 2647 // apparently buggy. In both LTR UI and RTL UI with left-to-right layout, | 2646 // apparently buggy. In both LTR UI and RTL UI with left-to-right layout, |
| 2648 // PosFromChar(i) might return 0 when i is greater than 1. | 2647 // PosFromChar(i) might return 0 when i is greater than 1. |
| 2649 return font_.GetStringWidth(text) + GetHorizontalMargin(); | 2648 return font_.GetStringWidth(text) + GetHorizontalMargin(); |
| 2650 } | 2649 } |
| OLD | NEW |