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

Side by Side Diff: chrome/browser/ui/views/omnibox/omnibox_view_win.cc

Issue 10911074: Change how ui::Clipboard is accessed so there's only one per thread. (Closed) Base URL: svn://svn.chromium.org/chrome/trunk/src
Patch Set: views_delegate.h deletion Created 8 years, 3 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
OLDNEW
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" 30 #include "chrome/browser/browser_process.h"
kaiwang 2012/09/06 22:11:47 remove?
31 #include "chrome/browser/command_updater.h" 31 #include "chrome/browser/command_updater.h"
32 #include "chrome/browser/net/url_fixer_upper.h" 32 #include "chrome/browser/net/url_fixer_upper.h"
33 #include "chrome/browser/profiles/profile.h" 33 #include "chrome/browser/profiles/profile.h"
34 #include "chrome/browser/ui/browser.h" 34 #include "chrome/browser/ui/browser.h"
35 #include "chrome/browser/ui/omnibox/omnibox_edit_controller.h" 35 #include "chrome/browser/ui/omnibox/omnibox_edit_controller.h"
36 #include "chrome/browser/ui/omnibox/omnibox_popup_model.h" 36 #include "chrome/browser/ui/omnibox/omnibox_popup_model.h"
37 #include "chrome/browser/ui/views/location_bar/location_bar_view.h" 37 #include "chrome/browser/ui/views/location_bar/location_bar_view.h"
38 #include "chrome/browser/ui/views/omnibox/omnibox_view_views.h" 38 #include "chrome/browser/ui/views/omnibox/omnibox_view_views.h"
39 #include "chrome/common/chrome_notification_types.h" 39 #include "chrome/common/chrome_notification_types.h"
40 #include "content/public/browser/user_metrics.h" 40 #include "content/public/browser/user_metrics.h"
(...skipping 1285 matching lines...) Expand 10 before | Expand all | Expand 10 after
1326 if (text.empty()) 1326 if (text.empty())
1327 return; 1327 return;
1328 1328
1329 CHARRANGE sel; 1329 CHARRANGE sel;
1330 GURL url; 1330 GURL url;
1331 bool write_url = false; 1331 bool write_url = false;
1332 GetSel(sel); 1332 GetSel(sel);
1333 // GetSel() doesn't preserve selection direction, so sel.cpMin will always be 1333 // GetSel() doesn't preserve selection direction, so sel.cpMin will always be
1334 // the smaller value. 1334 // the smaller value.
1335 model()->AdjustTextForCopy(sel.cpMin, IsSelectAll(), &text, &url, &write_url); 1335 model()->AdjustTextForCopy(sel.cpMin, IsSelectAll(), &text, &url, &write_url);
1336 ui::ScopedClipboardWriter scw(g_browser_process->clipboard(), 1336 ui::ScopedClipboardWriter scw(ui::Clipboard::GetForCurrentThread(),
1337 ui::Clipboard::BUFFER_STANDARD); 1337 ui::Clipboard::BUFFER_STANDARD);
1338 scw.WriteText(text); 1338 scw.WriteText(text);
1339 if (write_url) 1339 if (write_url)
1340 scw.WriteBookmark(text, url.spec()); 1340 scw.WriteBookmark(text, url.spec());
1341 } 1341 }
1342 1342
1343 LRESULT OmniboxViewWin::OnCreate(const CREATESTRUCTW* /*create_struct*/) { 1343 LRESULT OmniboxViewWin::OnCreate(const CREATESTRUCTW* /*create_struct*/) {
1344 if (base::win::IsTsfAwareRequired()) { 1344 if (base::win::IsTsfAwareRequired()) {
1345 // Enable TSF support of RichEdit. 1345 // Enable TSF support of RichEdit.
1346 SetEditStyle(SES_USECTF, SES_USECTF); 1346 SetEditStyle(SES_USECTF, SES_USECTF);
(...skipping 1294 matching lines...) Expand 10 before | Expand all | Expand 10 after
2641 return (rect.left - client_rect.left) + (client_rect.right - rect.right); 2641 return (rect.left - client_rect.left) + (client_rect.right - rect.right);
2642 } 2642 }
2643 2643
2644 int OmniboxViewWin::WidthNeededToDisplay(const string16& text) const { 2644 int OmniboxViewWin::WidthNeededToDisplay(const string16& text) const {
2645 // Use font_.GetStringWidth() instead of 2645 // Use font_.GetStringWidth() instead of
2646 // PosFromChar(location_entry_->GetTextLength()) because PosFromChar() is 2646 // PosFromChar(location_entry_->GetTextLength()) because PosFromChar() is
2647 // apparently buggy. In both LTR UI and RTL UI with left-to-right layout, 2647 // 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. 2648 // PosFromChar(i) might return 0 when i is greater than 1.
2649 return font_.GetStringWidth(text) + GetHorizontalMargin(); 2649 return font_.GetStringWidth(text) + GetHorizontalMargin();
2650 } 2650 }
OLDNEW

Powered by Google App Engine
This is Rietveld 408576698