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/instant/instant_controller.h" | 5 #include "chrome/browser/instant/instant_controller.h" |
6 | 6 |
7 #include "base/command_line.h" | 7 #include "base/command_line.h" |
8 #include "base/message_loop.h" | 8 #include "base/message_loop.h" |
9 #include "base/metrics/histogram.h" | 9 #include "base/metrics/histogram.h" |
10 #include "build/build_config.h" | 10 #include "build/build_config.h" |
11 #include "chrome/browser/autocomplete/autocomplete_match.h" | 11 #include "chrome/browser/autocomplete/autocomplete_match.h" |
12 #include "chrome/browser/instant/instant_delegate.h" | 12 #include "chrome/browser/instant/instant_delegate.h" |
13 #include "chrome/browser/instant/instant_loader.h" | 13 #include "chrome/browser/instant/instant_loader.h" |
14 #include "chrome/browser/instant/instant_loader_manager.h" | 14 #include "chrome/browser/instant/instant_loader_manager.h" |
15 #include "chrome/browser/instant/promo_counter.h" | 15 #include "chrome/browser/instant/promo_counter.h" |
16 #include "chrome/browser/platform_util.h" | 16 #include "chrome/browser/platform_util.h" |
17 #include "chrome/browser/prefs/pref_service.h" | 17 #include "chrome/browser/prefs/pref_service.h" |
18 #include "chrome/browser/prerender/prerender_manager.h" | 18 #include "chrome/browser/prerender/prerender_manager.h" |
19 #include "chrome/browser/profiles/profile.h" | 19 #include "chrome/browser/profiles/profile.h" |
20 #include "chrome/browser/search_engines/template_url.h" | 20 #include "chrome/browser/search_engines/template_url.h" |
21 #include "chrome/browser/search_engines/template_url_service.h" | 21 #include "chrome/browser/search_engines/template_url_service.h" |
22 #include "chrome/browser/search_engines/template_url_service_factory.h" | 22 #include "chrome/browser/search_engines/template_url_service_factory.h" |
23 #include "chrome/browser/ui/blocked_content/blocked_content_tab_helper.h" | 23 #include "chrome/browser/ui/blocked_content/blocked_content_tab_helper.h" |
24 #include "chrome/browser/ui/tab_contents/tab_contents_wrapper.h" | 24 #include "chrome/browser/ui/tab_contents/tab_contents_wrapper.h" |
| 25 #include "chrome/common/chrome_notification_types.h" |
25 #include "chrome/common/chrome_switches.h" | 26 #include "chrome/common/chrome_switches.h" |
26 #include "chrome/common/pref_names.h" | 27 #include "chrome/common/pref_names.h" |
27 #include "chrome/common/url_constants.h" | 28 #include "chrome/common/url_constants.h" |
28 #include "content/browser/renderer_host/render_widget_host_view.h" | 29 #include "content/browser/renderer_host/render_widget_host_view.h" |
29 #include "content/browser/tab_contents/tab_contents.h" | 30 #include "content/browser/tab_contents/tab_contents.h" |
30 #include "content/common/notification_service.h" | 31 #include "content/common/notification_service.h" |
31 | 32 |
32 // Number of ms to delay between loading urls. | 33 // Number of ms to delay between loading urls. |
33 static const int kUpdateDelayMS = 200; | 34 static const int kUpdateDelayMS = 200; |
34 | 35 |
(...skipping 165 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
200 bool real_verbatim = template_url_id ? verbatim : false; | 201 bool real_verbatim = template_url_id ? verbatim : false; |
201 | 202 |
202 if (ShouldUpdateNow(template_url_id, match.destination_url)) { | 203 if (ShouldUpdateNow(template_url_id, match.destination_url)) { |
203 UpdateLoader(template_url, match.destination_url, match.transition, | 204 UpdateLoader(template_url, match.destination_url, match.transition, |
204 user_text, real_verbatim, suggested_text); | 205 user_text, real_verbatim, suggested_text); |
205 } else { | 206 } else { |
206 ScheduleUpdate(match.destination_url); | 207 ScheduleUpdate(match.destination_url); |
207 } | 208 } |
208 | 209 |
209 NotificationService::current()->Notify( | 210 NotificationService::current()->Notify( |
210 NotificationType::INSTANT_CONTROLLER_UPDATED, | 211 chrome::NOTIFICATION_INSTANT_CONTROLLER_UPDATED, |
211 Source<InstantController>(this), | 212 Source<InstantController>(this), |
212 NotificationService::NoDetails()); | 213 NotificationService::NoDetails()); |
213 } | 214 } |
214 | 215 |
215 void InstantController::SetOmniboxBounds(const gfx::Rect& bounds) { | 216 void InstantController::SetOmniboxBounds(const gfx::Rect& bounds) { |
216 if (omnibox_bounds_ == bounds) | 217 if (omnibox_bounds_ == bounds) |
217 return; | 218 return; |
218 | 219 |
219 // Always track the omnibox bounds. That way if Update is later invoked the | 220 // Always track the omnibox bounds. That way if Update is later invoked the |
220 // bounds are in sync. | 221 // bounds are in sync. |
(...skipping 341 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
562 if (loader == displayable_loader_) | 563 if (loader == displayable_loader_) |
563 return; | 564 return; |
564 | 565 |
565 displayable_loader_ = loader; | 566 displayable_loader_ = loader; |
566 | 567 |
567 if (!displayable_loader_) { | 568 if (!displayable_loader_) { |
568 delegate_->HideInstant(); | 569 delegate_->HideInstant(); |
569 } else { | 570 } else { |
570 delegate_->ShowInstant(displayable_loader_->preview_contents()); | 571 delegate_->ShowInstant(displayable_loader_->preview_contents()); |
571 NotificationService::current()->Notify( | 572 NotificationService::current()->Notify( |
572 NotificationType::INSTANT_CONTROLLER_SHOWN, | 573 chrome::NOTIFICATION_INSTANT_CONTROLLER_SHOWN, |
573 Source<InstantController>(this), | 574 Source<InstantController>(this), |
574 NotificationService::NoDetails()); | 575 NotificationService::NoDetails()); |
575 } | 576 } |
576 } | 577 } |
577 | 578 |
578 TabContentsWrapper* InstantController::GetPendingPreviewContents() { | 579 TabContentsWrapper* InstantController::GetPendingPreviewContents() { |
579 return loader_manager_.get() && loader_manager_->pending_loader() ? | 580 return loader_manager_.get() && loader_manager_->pending_loader() ? |
580 loader_manager_->pending_loader()->preview_contents() : NULL; | 581 loader_manager_->pending_loader()->preview_contents() : NULL; |
581 } | 582 } |
582 | 583 |
(...skipping 148 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
731 if (destroy_factory_.empty()) { | 732 if (destroy_factory_.empty()) { |
732 MessageLoop::current()->PostTask( | 733 MessageLoop::current()->PostTask( |
733 FROM_HERE, destroy_factory_.NewRunnableMethod( | 734 FROM_HERE, destroy_factory_.NewRunnableMethod( |
734 &InstantController::DestroyLoaders)); | 735 &InstantController::DestroyLoaders)); |
735 } | 736 } |
736 } | 737 } |
737 | 738 |
738 void InstantController::DestroyLoaders() { | 739 void InstantController::DestroyLoaders() { |
739 loaders_to_destroy_.reset(); | 740 loaders_to_destroy_.reset(); |
740 } | 741 } |
OLD | NEW |