| 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/instant/instant_controller.h" | 5 #include "chrome/browser/instant/instant_controller.h" |
| 6 | 6 |
| 7 #include "base/bind.h" | 7 #include "base/bind.h" |
| 8 #include "base/command_line.h" | 8 #include "base/command_line.h" |
| 9 #include "base/message_loop.h" | 9 #include "base/message_loop.h" |
| 10 #include "base/metrics/histogram.h" | 10 #include "base/metrics/histogram.h" |
| 11 #include "base/rand_util.h" | 11 #include "base/rand_util.h" |
| 12 #include "build/build_config.h" | 12 #include "build/build_config.h" |
| 13 #include "chrome/browser/autocomplete/autocomplete_match.h" | 13 #include "chrome/browser/autocomplete/autocomplete_match.h" |
| 14 #include "chrome/browser/instant/instant_delegate.h" | 14 #include "chrome/browser/instant/instant_delegate.h" |
| 15 #include "chrome/browser/instant/instant_field_trial.h" | 15 #include "chrome/browser/instant/instant_field_trial.h" |
| 16 #include "chrome/browser/instant/instant_loader.h" | 16 #include "chrome/browser/instant/instant_loader.h" |
| 17 #include "chrome/browser/instant/promo_counter.h" | 17 #include "chrome/browser/instant/promo_counter.h" |
| 18 #include "chrome/browser/platform_util.h" | 18 #include "chrome/browser/platform_util.h" |
| 19 #include "chrome/browser/prefs/pref_service.h" | 19 #include "chrome/browser/prefs/pref_service.h" |
| 20 #include "chrome/browser/profiles/profile.h" | 20 #include "chrome/browser/profiles/profile.h" |
| 21 #include "chrome/browser/search_engines/template_url.h" | 21 #include "chrome/browser/search_engines/template_url.h" |
| 22 #include "chrome/browser/search_engines/template_url_service.h" | 22 #include "chrome/browser/search_engines/template_url_service.h" |
| 23 #include "chrome/browser/search_engines/template_url_service_factory.h" | 23 #include "chrome/browser/search_engines/template_url_service_factory.h" |
| 24 #include "chrome/browser/ui/blocked_content/blocked_content_tab_helper.h" | 24 #include "chrome/browser/ui/blocked_content/blocked_content_tab_helper.h" |
| 25 #include "chrome/browser/ui/tab_contents/tab_contents_wrapper.h" | 25 #include "chrome/browser/ui/tab_contents/tab_contents_wrapper.h" |
| 26 #include "chrome/common/chrome_notification_types.h" | 26 #include "chrome/common/chrome_notification_types.h" |
| 27 #include "chrome/common/chrome_switches.h" | 27 #include "chrome/common/chrome_switches.h" |
| 28 #include "chrome/common/pref_names.h" | 28 #include "chrome/common/pref_names.h" |
| 29 #include "content/browser/renderer_host/render_widget_host_view.h" | |
| 30 #include "content/public/browser/notification_service.h" | 29 #include "content/public/browser/notification_service.h" |
| 30 #include "content/public/browser/render_widget_host_view.h" |
| 31 #include "content/public/browser/web_contents.h" | 31 #include "content/public/browser/web_contents.h" |
| 32 | 32 |
| 33 #if defined(TOOLKIT_VIEWS) | 33 #if defined(TOOLKIT_VIEWS) |
| 34 #include "ui/views/focus/focus_manager.h" | 34 #include "ui/views/focus/focus_manager.h" |
| 35 #include "ui/views/view.h" | 35 #include "ui/views/view.h" |
| 36 #include "ui/views/widget/widget.h" | 36 #include "ui/views/widget/widget.h" |
| 37 #endif | 37 #endif |
| 38 | 38 |
| 39 InstantController::InstantController(Profile* profile, | 39 InstantController::InstantController(Profile* profile, |
| 40 InstantDelegate* delegate) | 40 InstantDelegate* delegate) |
| (...skipping 265 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 306 SetCommitOnMouseUp(); | 306 SetCommitOnMouseUp(); |
| 307 } | 307 } |
| 308 #else | 308 #else |
| 309 void InstantController::OnAutocompleteLostFocus( | 309 void InstantController::OnAutocompleteLostFocus( |
| 310 gfx::NativeView view_gaining_focus) { | 310 gfx::NativeView view_gaining_focus) { |
| 311 if (!IsCurrent()) { | 311 if (!IsCurrent()) { |
| 312 DestroyPreviewContents(); | 312 DestroyPreviewContents(); |
| 313 return; | 313 return; |
| 314 } | 314 } |
| 315 | 315 |
| 316 RenderWidgetHostView* rwhv = | 316 content::RenderWidgetHostView* rwhv = |
| 317 GetPreviewContents()->web_contents()->GetRenderWidgetHostView(); | 317 GetPreviewContents()->web_contents()->GetRenderWidgetHostView(); |
| 318 if (!view_gaining_focus || !rwhv) { | 318 if (!view_gaining_focus || !rwhv) { |
| 319 DestroyPreviewContents(); | 319 DestroyPreviewContents(); |
| 320 return; | 320 return; |
| 321 } | 321 } |
| 322 | 322 |
| 323 #if defined(TOOLKIT_VIEWS) | 323 #if defined(TOOLKIT_VIEWS) |
| 324 // For views the top level widget is always focused. If the focus change | 324 // For views the top level widget is always focused. If the focus change |
| 325 // originated in views determine the child Widget from the view that is being | 325 // originated in views determine the child Widget from the view that is being |
| 326 // focused. | 326 // focused. |
| (...skipping 240 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 567 if (!weak_factory_.HasWeakPtrs()) { | 567 if (!weak_factory_.HasWeakPtrs()) { |
| 568 MessageLoop::current()->PostTask( | 568 MessageLoop::current()->PostTask( |
| 569 FROM_HERE, base::Bind(&InstantController::DestroyLoaders, | 569 FROM_HERE, base::Bind(&InstantController::DestroyLoaders, |
| 570 weak_factory_.GetWeakPtr())); | 570 weak_factory_.GetWeakPtr())); |
| 571 } | 571 } |
| 572 } | 572 } |
| 573 | 573 |
| 574 void InstantController::DestroyLoaders() { | 574 void InstantController::DestroyLoaders() { |
| 575 loaders_to_destroy_.reset(); | 575 loaders_to_destroy_.reset(); |
| 576 } | 576 } |
| OLD | NEW |