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" | 13 #include "chrome/browser/chrome_notification_types.h" |
14 #include "chrome/browser/profiles/profile.h" | 14 #include "chrome/browser/profiles/profile.h" |
15 #include "chrome/browser/search/instant_service.h" | 15 #include "chrome/browser/search/instant_service.h" |
16 #include "chrome/browser/search/instant_service_factory.h" | 16 #include "chrome/browser/search/instant_service_factory.h" |
17 #include "chrome/browser/search/search.h" | 17 #include "chrome/browser/search/search.h" |
18 #include "chrome/browser/ui/browser_instant_controller.h" | 18 #include "chrome/browser/ui/browser_instant_controller.h" |
19 #include "chrome/browser/ui/search/instant_tab.h" | 19 #include "chrome/browser/ui/search/instant_page.h" |
20 #include "chrome/browser/ui/search/search_tab_helper.h" | 20 #include "chrome/browser/ui/search/search_tab_helper.h" |
21 #include "components/sessions/core/serialized_navigation_entry.h" | 21 #include "components/sessions/core/serialized_navigation_entry.h" |
22 #include "content/public/browser/navigation_controller.h" | 22 #include "content/public/browser/navigation_controller.h" |
23 #include "content/public/browser/navigation_entry.h" | 23 #include "content/public/browser/navigation_entry.h" |
24 #include "content/public/browser/notification_service.h" | 24 #include "content/public/browser/notification_service.h" |
25 #include "content/public/browser/web_contents.h" | 25 #include "content/public/browser/web_contents.h" |
26 #include "url/gurl.h" | 26 #include "url/gurl.h" |
27 | 27 |
28 // Macro used for logging debug events. |message| should be a std::string. | 28 // Macro used for logging debug events. |message| should be a std::string. |
29 #define LOG_INSTANT_DEBUG_EVENT(controller, message) \ | 29 #define LOG_INSTANT_DEBUG_EVENT(controller, message) \ |
(...skipping 81 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
111 } | 111 } |
112 | 112 |
113 void InstantController::ClearDebugEvents() { | 113 void InstantController::ClearDebugEvents() { |
114 debug_events_.clear(); | 114 debug_events_.clear(); |
115 } | 115 } |
116 | 116 |
117 Profile* InstantController::profile() const { | 117 Profile* InstantController::profile() const { |
118 return browser_->profile(); | 118 return browser_->profile(); |
119 } | 119 } |
120 | 120 |
121 InstantTab* InstantController::instant_tab() const { | 121 InstantPage* InstantController::instant_tab() const { |
122 return instant_tab_.get(); | 122 return instant_tab_.get(); |
123 } | 123 } |
124 | 124 |
125 void InstantController::InstantSupportChanged( | 125 void InstantController::InstantSupportChanged( |
126 InstantSupportState instant_support) { | 126 InstantSupportState instant_support) { |
127 // Handle INSTANT_SUPPORT_YES here because InstantPage is not hooked up to the | 127 // Handle INSTANT_SUPPORT_YES here because InstantPage is not hooked up to the |
128 // active tab. Search model changed listener in InstantPage will handle other | 128 // active tab. Search model changed listener in InstantPage will handle other |
129 // cases. | 129 // cases. |
130 if (instant_support != INSTANT_SUPPORT_YES) | 130 if (instant_support != INSTANT_SUPPORT_YES) |
131 return; | 131 return; |
(...skipping 23 matching lines...) Expand all Loading... |
155 | 155 |
156 // The Instant tab navigated. Send it the data it needs to display | 156 // The Instant tab navigated. Send it the data it needs to display |
157 // properly. | 157 // properly. |
158 UpdateInfoForInstantTab(); | 158 UpdateInfoForInstantTab(); |
159 } | 159 } |
160 | 160 |
161 void InstantController::ResetInstantTab() { | 161 void InstantController::ResetInstantTab() { |
162 if (!search_mode_.is_origin_default()) { | 162 if (!search_mode_.is_origin_default()) { |
163 content::WebContents* active_tab = browser_->GetActiveWebContents(); | 163 content::WebContents* active_tab = browser_->GetActiveWebContents(); |
164 if (!instant_tab_ || active_tab != instant_tab_->web_contents()) { | 164 if (!instant_tab_ || active_tab != instant_tab_->web_contents()) { |
165 instant_tab_.reset(new InstantTab(this)); | 165 instant_tab_.reset(new InstantPage(this)); |
166 instant_tab_->Init(active_tab); | 166 instant_tab_->Init(active_tab); |
167 UpdateInfoForInstantTab(); | 167 UpdateInfoForInstantTab(); |
168 } | 168 } |
169 } else { | 169 } else { |
170 instant_tab_.reset(); | 170 instant_tab_.reset(); |
171 } | 171 } |
172 } | 172 } |
173 | 173 |
174 void InstantController::UpdateInfoForInstantTab() { | 174 void InstantController::UpdateInfoForInstantTab() { |
175 if (instant_tab_) { | 175 if (instant_tab_) { |
176 // Update theme details. | 176 // Update theme details. |
177 InstantService* instant_service = GetInstantService(); | 177 InstantService* instant_service = GetInstantService(); |
178 if (instant_service) { | 178 if (instant_service) { |
179 instant_service->UpdateThemeInfo(); | 179 instant_service->UpdateThemeInfo(); |
180 instant_service->UpdateMostVisitedItemsInfo(); | 180 instant_service->UpdateMostVisitedItemsInfo(); |
181 } | 181 } |
182 } | 182 } |
183 } | 183 } |
184 | 184 |
185 InstantService* InstantController::GetInstantService() const { | 185 InstantService* InstantController::GetInstantService() const { |
186 return InstantServiceFactory::GetForProfile(profile()); | 186 return InstantServiceFactory::GetForProfile(profile()); |
187 } | 187 } |
OLD | NEW |