| OLD | NEW |
| 1 // Copyright 2013 The Chromium Authors. All rights reserved. | 1 // Copyright 2013 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_page.h" | 5 #include "chrome/browser/ui/search/instant_page.h" |
| 6 | 6 |
| 7 #include "apps/app_launcher.h" | 7 #include "apps/app_launcher.h" |
| 8 #include "base/strings/utf_string_conversions.h" | 8 #include "base/strings/utf_string_conversions.h" |
| 9 #include "chrome/browser/chrome_notification_types.h" | 9 #include "chrome/browser/chrome_notification_types.h" |
| 10 #include "chrome/browser/history/most_visited_tiles_experiment.h" | 10 #include "chrome/browser/history/most_visited_tiles_experiment.h" |
| (...skipping 104 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 115 } | 115 } |
| 116 | 116 |
| 117 bool InstantPage::ShouldProcessFocusOmnibox() { | 117 bool InstantPage::ShouldProcessFocusOmnibox() { |
| 118 return false; | 118 return false; |
| 119 } | 119 } |
| 120 | 120 |
| 121 bool InstantPage::ShouldProcessNavigateToURL() { | 121 bool InstantPage::ShouldProcessNavigateToURL() { |
| 122 return false; | 122 return false; |
| 123 } | 123 } |
| 124 | 124 |
| 125 bool InstantPage::ShouldProcessPasteIntoOmnibox() { |
| 126 return false; |
| 127 } |
| 128 |
| 125 bool InstantPage::ShouldProcessDeleteMostVisitedItem() { | 129 bool InstantPage::ShouldProcessDeleteMostVisitedItem() { |
| 126 return false; | 130 return false; |
| 127 } | 131 } |
| 128 | 132 |
| 129 bool InstantPage::ShouldProcessUndoMostVisitedDeletion() { | 133 bool InstantPage::ShouldProcessUndoMostVisitedDeletion() { |
| 130 return false; | 134 return false; |
| 131 } | 135 } |
| 132 | 136 |
| 133 bool InstantPage::ShouldProcessUndoAllMostVisitedDeletions() { | 137 bool InstantPage::ShouldProcessUndoAllMostVisitedDeletions() { |
| 134 return false; | 138 return false; |
| 135 } | 139 } |
| 136 | 140 |
| 137 bool InstantPage::OnMessageReceived(const IPC::Message& message) { | 141 bool InstantPage::OnMessageReceived(const IPC::Message& message) { |
| 138 if (is_incognito_) | 142 if (is_incognito_) |
| 139 return false; | 143 return false; |
| 140 | 144 |
| 141 bool handled = true; | 145 bool handled = true; |
| 142 IPC_BEGIN_MESSAGE_MAP(InstantPage, message) | 146 IPC_BEGIN_MESSAGE_MAP(InstantPage, message) |
| 143 IPC_MESSAGE_HANDLER(ChromeViewHostMsg_FocusOmnibox, OnFocusOmnibox) | 147 IPC_MESSAGE_HANDLER(ChromeViewHostMsg_FocusOmnibox, OnFocusOmnibox) |
| 144 IPC_MESSAGE_HANDLER(ChromeViewHostMsg_SearchBoxNavigate, | 148 IPC_MESSAGE_HANDLER(ChromeViewHostMsg_SearchBoxNavigate, |
| 145 OnSearchBoxNavigate); | 149 OnSearchBoxNavigate); |
| 150 IPC_MESSAGE_HANDLER(ChromeViewHostMsg_PasteAndOpenDropdown, |
| 151 OnSearchBoxPaste); |
| 146 IPC_MESSAGE_HANDLER(ChromeViewHostMsg_CountMouseover, OnCountMouseover); | 152 IPC_MESSAGE_HANDLER(ChromeViewHostMsg_CountMouseover, OnCountMouseover); |
| 147 IPC_MESSAGE_HANDLER(ChromeViewHostMsg_SearchBoxDeleteMostVisitedItem, | 153 IPC_MESSAGE_HANDLER(ChromeViewHostMsg_SearchBoxDeleteMostVisitedItem, |
| 148 OnDeleteMostVisitedItem); | 154 OnDeleteMostVisitedItem); |
| 149 IPC_MESSAGE_HANDLER(ChromeViewHostMsg_SearchBoxUndoMostVisitedDeletion, | 155 IPC_MESSAGE_HANDLER(ChromeViewHostMsg_SearchBoxUndoMostVisitedDeletion, |
| 150 OnUndoMostVisitedDeletion); | 156 OnUndoMostVisitedDeletion); |
| 151 IPC_MESSAGE_HANDLER(ChromeViewHostMsg_SearchBoxUndoAllMostVisitedDeletions, | 157 IPC_MESSAGE_HANDLER(ChromeViewHostMsg_SearchBoxUndoAllMostVisitedDeletions, |
| 152 OnUndoAllMostVisitedDeletions); | 158 OnUndoAllMostVisitedDeletions); |
| 153 IPC_MESSAGE_UNHANDLED(handled = false) | 159 IPC_MESSAGE_UNHANDLED(handled = false) |
| 154 IPC_END_MESSAGE_MAP() | 160 IPC_END_MESSAGE_MAP() |
| 155 return handled; | 161 return handled; |
| (...skipping 81 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 237 return; | 243 return; |
| 238 | 244 |
| 239 SearchTabHelper::FromWebContents(contents())->InstantSupportChanged(true); | 245 SearchTabHelper::FromWebContents(contents())->InstantSupportChanged(true); |
| 240 if (!ShouldProcessNavigateToURL()) | 246 if (!ShouldProcessNavigateToURL()) |
| 241 return; | 247 return; |
| 242 | 248 |
| 243 delegate_->NavigateToURL( | 249 delegate_->NavigateToURL( |
| 244 contents(), url, transition, disposition, is_search_type); | 250 contents(), url, transition, disposition, is_search_type); |
| 245 } | 251 } |
| 246 | 252 |
| 253 void InstantPage::OnSearchBoxPaste(int page_id, const string16& text) { |
| 254 if (!contents()->IsActiveEntry(page_id)) |
| 255 return; |
| 256 |
| 257 SearchTabHelper::FromWebContents(contents())->InstantSupportChanged(true); |
| 258 if (!ShouldProcessPasteIntoOmnibox()) |
| 259 return; |
| 260 |
| 261 delegate_->PasteIntoOmnibox(contents(), text); |
| 262 } |
| 263 |
| 247 void InstantPage::OnCountMouseover(int page_id) { | 264 void InstantPage::OnCountMouseover(int page_id) { |
| 248 if (!contents()->IsActiveEntry(page_id)) | 265 if (!contents()->IsActiveEntry(page_id)) |
| 249 return; | 266 return; |
| 250 | 267 |
| 251 InstantTab::CountMouseover(contents()); | 268 InstantTab::CountMouseover(contents()); |
| 252 } | 269 } |
| 253 | 270 |
| 254 void InstantPage::OnDeleteMostVisitedItem(int page_id, const GURL& url) { | 271 void InstantPage::OnDeleteMostVisitedItem(int page_id, const GURL& url) { |
| 255 if (!contents()->IsActiveEntry(page_id)) | 272 if (!contents()->IsActiveEntry(page_id)) |
| 256 return; | 273 return; |
| (...skipping 55 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 312 return; | 329 return; |
| 313 } | 330 } |
| 314 | 331 |
| 315 std::set<std::string> open_urls; | 332 std::set<std::string> open_urls; |
| 316 chrome::GetOpenUrls(*tab_strip_model, *top_sites, &open_urls); | 333 chrome::GetOpenUrls(*tab_strip_model, *top_sites, &open_urls); |
| 317 history::MostVisitedTilesExperiment::RemoveItemsMatchingOpenTabs( | 334 history::MostVisitedTilesExperiment::RemoveItemsMatchingOpenTabs( |
| 318 open_urls, items); | 335 open_urls, items); |
| 319 | 336 |
| 320 #endif | 337 #endif |
| 321 } | 338 } |
| OLD | NEW |