OLD | NEW |
1 // Copyright (c) 2010 The Chromium Authors. All rights reserved. | 1 // Copyright (c) 2010 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/instant/instant_loader.h" | 5 #include "chrome/browser/instant/instant_loader.h" |
6 | 6 |
7 #include <algorithm> | 7 #include <algorithm> |
8 #include <string> | 8 #include <string> |
9 #include <utility> | 9 #include <utility> |
10 #include <vector> | 10 #include <vector> |
(...skipping 78 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
89 switch (type.value) { | 89 switch (type.value) { |
90 case NotificationType::LOAD_COMPLETED_MAIN_FRAME: { | 90 case NotificationType::LOAD_COMPLETED_MAIN_FRAME: { |
91 int page_id = *(Details<int>(details).ptr()); | 91 int page_id = *(Details<int>(details).ptr()); |
92 NavigationEntry* active_entry = | 92 NavigationEntry* active_entry = |
93 tab_contents_->controller().GetActiveEntry(); | 93 tab_contents_->controller().GetActiveEntry(); |
94 if (!active_entry || active_entry->page_id() != page_id || | 94 if (!active_entry || active_entry->page_id() != page_id || |
95 active_entry->unique_id() != unique_id_) { | 95 active_entry->unique_id() != unique_id_) { |
96 return; | 96 return; |
97 } | 97 } |
98 loader_->SendBoundsToPage(true); | 98 loader_->SendBoundsToPage(true); |
| 99 // TODO: support real cursor position. |
| 100 int text_length = static_cast<int>(text_.size()); |
99 tab_contents_->render_view_host()->DetermineIfPageSupportsInstant( | 101 tab_contents_->render_view_host()->DetermineIfPageSupportsInstant( |
100 text_, verbatim_); | 102 text_, verbatim_, text_length, text_length); |
101 break; | 103 break; |
102 } | 104 } |
103 default: | 105 default: |
104 NOTREACHED(); | 106 NOTREACHED(); |
105 break; | 107 break; |
106 } | 108 } |
107 } | 109 } |
108 | 110 |
109 private: | 111 private: |
110 InstantLoader* loader_; | 112 InstantLoader* loader_; |
(...skipping 360 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
471 if (template_url) { | 473 if (template_url) { |
472 DCHECK(template_url_id_ == template_url->id()); | 474 DCHECK(template_url_id_ == template_url->id()); |
473 if (!created_preview_contents) { | 475 if (!created_preview_contents) { |
474 if (is_waiting_for_load()) { | 476 if (is_waiting_for_load()) { |
475 // The page hasn't loaded yet. We'll send the script down when it does. | 477 // The page hasn't loaded yet. We'll send the script down when it does. |
476 frame_load_observer_->set_text(user_text_); | 478 frame_load_observer_->set_text(user_text_); |
477 frame_load_observer_->set_verbatim(verbatim); | 479 frame_load_observer_->set_verbatim(verbatim); |
478 preview_tab_contents_delegate_->set_user_typed_before_load(); | 480 preview_tab_contents_delegate_->set_user_typed_before_load(); |
479 return; | 481 return; |
480 } | 482 } |
| 483 // TODO: support real cursor position. |
| 484 int text_length = static_cast<int>(user_text_.size()); |
481 preview_contents_->render_view_host()->SearchBoxChange( | 485 preview_contents_->render_view_host()->SearchBoxChange( |
482 user_text_, verbatim, 0, 0); | 486 user_text_, verbatim, text_length, text_length); |
483 | 487 |
484 string16 complete_suggested_text_lower = l10n_util::ToLower( | 488 string16 complete_suggested_text_lower = l10n_util::ToLower( |
485 complete_suggested_text_); | 489 complete_suggested_text_); |
486 string16 user_text_lower = l10n_util::ToLower(user_text_); | 490 string16 user_text_lower = l10n_util::ToLower(user_text_); |
487 if (!verbatim && | 491 if (!verbatim && |
488 complete_suggested_text_lower.size() > user_text_lower.size() && | 492 complete_suggested_text_lower.size() > user_text_lower.size() && |
489 !complete_suggested_text_lower.compare(0, user_text_lower.size(), | 493 !complete_suggested_text_lower.compare(0, user_text_lower.size(), |
490 user_text_lower)) { | 494 user_text_lower)) { |
491 *suggested_text = last_suggestion_ = | 495 *suggested_text = last_suggestion_ = |
492 complete_suggested_text_.substr(user_text_.size()); | 496 complete_suggested_text_.substr(user_text_.size()); |
(...skipping 273 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
766 Source<NavigationController>(&preview_contents_->controller())); | 770 Source<NavigationController>(&preview_contents_->controller())); |
767 #endif | 771 #endif |
768 | 772 |
769 registrar_.Add( | 773 registrar_.Add( |
770 this, | 774 this, |
771 NotificationType::NAV_ENTRY_COMMITTED, | 775 NotificationType::NAV_ENTRY_COMMITTED, |
772 Source<NavigationController>(&preview_contents_->controller())); | 776 Source<NavigationController>(&preview_contents_->controller())); |
773 | 777 |
774 preview_contents_->tab_contents()->ShowContents(); | 778 preview_contents_->tab_contents()->ShowContents(); |
775 } | 779 } |
OLD | NEW |