| OLD | NEW |
| 1 // Copyright 2012 The Chromium Authors. All rights reserved. | 1 // Copyright 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/search/instant_controller.h" | 5 #include "chrome/browser/ui/search/instant_controller.h" |
| 6 | 6 |
| 7 #include <stddef.h> | 7 #include <stddef.h> |
| 8 #include <utility> | 8 #include <utility> |
| 9 | 9 |
| 10 #include "base/location.h" | 10 #include "base/location.h" |
| 11 #include "base/strings/stringprintf.h" | 11 #include "base/strings/stringprintf.h" |
| 12 #include "base/threading/thread_task_runner_handle.h" | 12 #include "base/threading/thread_task_runner_handle.h" |
| 13 #include "chrome/browser/chrome_notification_types.h" | |
| 14 #include "chrome/browser/profiles/profile.h" | 13 #include "chrome/browser/profiles/profile.h" |
| 15 #include "chrome/browser/search/instant_service.h" | 14 #include "chrome/browser/search/instant_service.h" |
| 16 #include "chrome/browser/search/instant_service_factory.h" | 15 #include "chrome/browser/search/instant_service_factory.h" |
| 17 #include "chrome/browser/ui/browser_instant_controller.h" | 16 #include "chrome/browser/ui/browser_instant_controller.h" |
| 18 #include "content/public/browser/notification_service.h" | |
| 19 #include "content/public/browser/web_contents.h" | 17 #include "content/public/browser/web_contents.h" |
| 20 #include "url/gurl.h" | 18 #include "url/gurl.h" |
| 21 | 19 |
| 22 namespace { | 20 namespace { |
| 23 | 21 |
| 24 bool IsContentsFrom(const InstantTab* page, | 22 bool IsContentsFrom(const InstantTab* page, |
| 25 const content::WebContents* contents) { | 23 const content::WebContents* contents) { |
| 26 return page && (page->web_contents() == contents); | 24 return page && (page->web_contents() == contents); |
| 27 } | 25 } |
| 28 | 26 |
| (...skipping 44 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 73 return; | 71 return; |
| 74 | 72 |
| 75 ResetInstantTab(); | 73 ResetInstantTab(); |
| 76 } | 74 } |
| 77 | 75 |
| 78 void InstantController::InstantSupportDetermined( | 76 void InstantController::InstantSupportDetermined( |
| 79 const content::WebContents* contents, | 77 const content::WebContents* contents, |
| 80 bool supports_instant) { | 78 bool supports_instant) { |
| 81 DCHECK(IsContentsFrom(instant_tab_.get(), contents)); | 79 DCHECK(IsContentsFrom(instant_tab_.get(), contents)); |
| 82 | 80 |
| 83 if (!supports_instant) | 81 if (!supports_instant) { |
| 84 base::ThreadTaskRunnerHandle::Get()->DeleteSoon(FROM_HERE, | 82 base::ThreadTaskRunnerHandle::Get()->DeleteSoon(FROM_HERE, |
| 85 instant_tab_.release()); | 83 instant_tab_.release()); |
| 86 | 84 } |
| 87 content::NotificationService::current()->Notify( | |
| 88 chrome::NOTIFICATION_INSTANT_TAB_SUPPORT_DETERMINED, | |
| 89 content::Source<InstantController>(this), | |
| 90 content::NotificationService::NoDetails()); | |
| 91 } | 85 } |
| 92 | 86 |
| 93 void InstantController::InstantTabAboutToNavigateMainFrame( | 87 void InstantController::InstantTabAboutToNavigateMainFrame( |
| 94 const content::WebContents* contents, | 88 const content::WebContents* contents, |
| 95 const GURL& url) { | 89 const GURL& url) { |
| 96 DCHECK(IsContentsFrom(instant_tab_.get(), contents)); | 90 DCHECK(IsContentsFrom(instant_tab_.get(), contents)); |
| 97 | 91 |
| 98 // The Instant tab navigated. Send it the data it needs to display | 92 // The Instant tab navigated. Send it the data it needs to display |
| 99 // properly. | 93 // properly. |
| 100 UpdateInfoForInstantTab(); | 94 UpdateInfoForInstantTab(); |
| (...skipping 19 matching lines...) Expand all Loading... |
| 120 if (instant_service) { | 114 if (instant_service) { |
| 121 instant_service->UpdateThemeInfo(); | 115 instant_service->UpdateThemeInfo(); |
| 122 instant_service->UpdateMostVisitedItemsInfo(); | 116 instant_service->UpdateMostVisitedItemsInfo(); |
| 123 } | 117 } |
| 124 } | 118 } |
| 125 } | 119 } |
| 126 | 120 |
| 127 InstantService* InstantController::GetInstantService() const { | 121 InstantService* InstantController::GetInstantService() const { |
| 128 return InstantServiceFactory::GetForProfile(browser_->profile()); | 122 return InstantServiceFactory::GetForProfile(browser_->profile()); |
| 129 } | 123 } |
| OLD | NEW |