| OLD | NEW |
| 1 // Copyright (c) 2011 The Chromium Authors. All rights reserved. | 1 // Copyright (c) 2011 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 11 matching lines...) Expand all Loading... |
| 22 #include "chrome/app/chrome_command_ids.h" | 22 #include "chrome/app/chrome_command_ids.h" |
| 23 #include "chrome/browser/autocomplete/autocomplete_accessibility.h" | 23 #include "chrome/browser/autocomplete/autocomplete_accessibility.h" |
| 24 #include "chrome/browser/autocomplete/autocomplete_match.h" | 24 #include "chrome/browser/autocomplete/autocomplete_match.h" |
| 25 #include "chrome/browser/autocomplete/autocomplete_popup_model.h" | 25 #include "chrome/browser/autocomplete/autocomplete_popup_model.h" |
| 26 #include "chrome/browser/autocomplete/keyword_provider.h" | 26 #include "chrome/browser/autocomplete/keyword_provider.h" |
| 27 #include "chrome/browser/browser_process.h" | 27 #include "chrome/browser/browser_process.h" |
| 28 #include "chrome/browser/command_updater.h" | 28 #include "chrome/browser/command_updater.h" |
| 29 #include "chrome/browser/net/url_fixer_upper.h" | 29 #include "chrome/browser/net/url_fixer_upper.h" |
| 30 #include "chrome/browser/profiles/profile.h" | 30 #include "chrome/browser/profiles/profile.h" |
| 31 #include "chrome/browser/ui/views/location_bar/location_bar_view.h" | 31 #include "chrome/browser/ui/views/location_bar/location_bar_view.h" |
| 32 #include "chrome/common/chrome_notification_types.h" |
| 32 #include "content/browser/tab_contents/tab_contents.h" | 33 #include "content/browser/tab_contents/tab_contents.h" |
| 33 #include "content/browser/user_metrics.h" | 34 #include "content/browser/user_metrics.h" |
| 34 #include "content/common/notification_service.h" | 35 #include "content/common/notification_service.h" |
| 35 #include "googleurl/src/url_util.h" | 36 #include "googleurl/src/url_util.h" |
| 36 #include "grit/generated_resources.h" | 37 #include "grit/generated_resources.h" |
| 37 #include "net/base/escape.h" | 38 #include "net/base/escape.h" |
| 38 #include "skia/ext/skia_utils_win.h" | 39 #include "skia/ext/skia_utils_win.h" |
| 39 #include "ui/base/clipboard/clipboard.h" | 40 #include "ui/base/clipboard/clipboard.h" |
| 40 #include "ui/base/clipboard/scoped_clipboard_writer.h" | 41 #include "ui/base/clipboard/scoped_clipboard_writer.h" |
| 41 #include "ui/base/dragdrop/drag_drop_types.h" | 42 #include "ui/base/dragdrop/drag_drop_types.h" |
| (...skipping 433 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 475 | 476 |
| 476 // Register our drop target. RichEdit appears to invoke RevokeDropTarget when | 477 // Register our drop target. RichEdit appears to invoke RevokeDropTarget when |
| 477 // done so that we don't have to explicitly. | 478 // done so that we don't have to explicitly. |
| 478 if (!popup_window_mode_) { | 479 if (!popup_window_mode_) { |
| 479 scoped_refptr<EditDropTarget> drop_target = new EditDropTarget(this); | 480 scoped_refptr<EditDropTarget> drop_target = new EditDropTarget(this); |
| 480 RegisterDragDrop(m_hWnd, drop_target.get()); | 481 RegisterDragDrop(m_hWnd, drop_target.get()); |
| 481 } | 482 } |
| 482 } | 483 } |
| 483 | 484 |
| 484 OmniboxViewWin::~OmniboxViewWin() { | 485 OmniboxViewWin::~OmniboxViewWin() { |
| 485 NotificationService::current()->Notify(NotificationType::OMNIBOX_DESTROYED, | 486 NotificationService::current()->Notify( |
| 486 Source<OmniboxViewWin>(this), | 487 chrome::NOTIFICATION_OMNIBOX_DESTROYED, Source<OmniboxViewWin>(this), |
| 487 NotificationService::NoDetails()); | 488 NotificationService::NoDetails()); |
| 488 | 489 |
| 489 // Explicitly release the text object model now that we're done with it, and | 490 // Explicitly release the text object model now that we're done with it, and |
| 490 // before we free the library. If the library gets unloaded before this | 491 // before we free the library. If the library gets unloaded before this |
| 491 // released, it becomes garbage. | 492 // released, it becomes garbage. |
| 492 text_object_model_->Release(); | 493 text_object_model_->Release(); |
| 493 | 494 |
| 494 // We balance our reference count and unpatch when the last instance has | 495 // We balance our reference count and unpatch when the last instance has |
| 495 // been destroyed. This prevents us from relying on the AtExit or static | 496 // been destroyed. This prevents us from relying on the AtExit or static |
| 496 // destructor sequence to do our unpatching, which is generally fragile. | 497 // destructor sequence to do our unpatching, which is generally fragile. |
| 497 g_paint_patcher.Pointer()->DerefPatch(); | 498 g_paint_patcher.Pointer()->DerefPatch(); |
| (...skipping 2103 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 2601 // PosFromChar(i) might return 0 when i is greater than 1. | 2602 // PosFromChar(i) might return 0 when i is greater than 1. |
| 2602 return font_.GetStringWidth(text) + GetHorizontalMargin(); | 2603 return font_.GetStringWidth(text) + GetHorizontalMargin(); |
| 2603 } | 2604 } |
| 2604 | 2605 |
| 2605 bool OmniboxViewWin::IsCaretAtEnd() const { | 2606 bool OmniboxViewWin::IsCaretAtEnd() const { |
| 2606 long length = GetTextLength(); | 2607 long length = GetTextLength(); |
| 2607 CHARRANGE sel; | 2608 CHARRANGE sel; |
| 2608 GetSelection(sel); | 2609 GetSelection(sel); |
| 2609 return sel.cpMin == sel.cpMax && sel.cpMin == length; | 2610 return sel.cpMin == sel.cpMax && sel.cpMin == length; |
| 2610 } | 2611 } |
| OLD | NEW |