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/renderer/searchbox/searchbox.h" | 5 #include "chrome/renderer/searchbox/searchbox.h" |
6 | 6 |
7 #include "base/string_number_conversions.h" | 7 #include "base/string_number_conversions.h" |
8 #include "base/utf_string_conversions.h" | 8 #include "base/utf_string_conversions.h" |
9 #include "chrome/common/chrome_switches.h" | 9 #include "chrome/common/chrome_switches.h" |
10 #include "chrome/common/omnibox_focus_state.h" | 10 #include "chrome/common/omnibox_focus_state.h" |
(...skipping 314 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... | |
325 extensions_v8::SearchBoxExtension::DispatchKeyCaptureChange( | 325 extensions_v8::SearchBoxExtension::DispatchKeyCaptureChange( |
326 render_view()->GetWebView()->mainFrame()); | 326 render_view()->GetWebView()->mainFrame()); |
327 } | 327 } |
328 } | 328 } |
329 | 329 |
330 void SearchBox::OnSetDisplayInstantResults(bool display_instant_results) { | 330 void SearchBox::OnSetDisplayInstantResults(bool display_instant_results) { |
331 display_instant_results_ = display_instant_results; | 331 display_instant_results_ = display_instant_results; |
332 } | 332 } |
333 | 333 |
334 void SearchBox::OnThemeChanged(const ThemeBackgroundInfo& theme_info) { | 334 void SearchBox::OnThemeChanged(const ThemeBackgroundInfo& theme_info) { |
335 if (theme_info == theme_info_) { | |
samarth
2013/05/03 21:24:42
nit: no braces for 1-line conditionals in Chrome.
| |
336 return; | |
337 } | |
335 theme_info_ = theme_info; | 338 theme_info_ = theme_info; |
336 if (render_view()->GetWebView() && render_view()->GetWebView()->mainFrame()) { | 339 if (render_view()->GetWebView() && render_view()->GetWebView()->mainFrame()) { |
337 extensions_v8::SearchBoxExtension::DispatchThemeChange( | 340 extensions_v8::SearchBoxExtension::DispatchThemeChange( |
338 render_view()->GetWebView()->mainFrame()); | 341 render_view()->GetWebView()->mainFrame()); |
339 } | 342 } |
340 } | 343 } |
341 | 344 |
342 void SearchBox::OnFontInformationReceived(const string16& omnibox_font, | 345 void SearchBox::OnFontInformationReceived(const string16& omnibox_font, |
343 size_t omnibox_font_size) { | 346 size_t omnibox_font_size) { |
344 omnibox_font_ = omnibox_font; | 347 omnibox_font_ = omnibox_font; |
(...skipping 21 matching lines...) Expand all Loading... | |
366 theme_info_ = ThemeBackgroundInfo(); | 369 theme_info_ = ThemeBackgroundInfo(); |
367 // Don't reset display_instant_results_ to prevent clearing it on committed | 370 // Don't reset display_instant_results_ to prevent clearing it on committed |
368 // results pages in extended mode. Otherwise resetting it is a no-op because | 371 // results pages in extended mode. Otherwise resetting it is a no-op because |
369 // a new loader is created when it changes; see crbug.com/164662. | 372 // a new loader is created when it changes; see crbug.com/164662. |
370 // Also don't reset omnibox_font_ or omnibox_font_size_ since it never | 373 // Also don't reset omnibox_font_ or omnibox_font_size_ since it never |
371 // changes. | 374 // changes. |
372 } | 375 } |
373 | 376 |
374 void SearchBox::OnMostVisitedChanged( | 377 void SearchBox::OnMostVisitedChanged( |
375 const std::vector<InstantMostVisitedItemIDPair>& items) { | 378 const std::vector<InstantMostVisitedItemIDPair>& items) { |
379 std::vector<InstantMostVisitedItemIDPair> oldItems; | |
380 most_visited_items_cache_.GetCurrentItems(&oldItems); | |
381 | |
382 bool most_visited_changed = oldItems.size() != items.size(); | |
samarth
2013/05/03 21:24:42
if (oldsize != newsize)
return;
| |
383 if (!most_visited_changed) { | |
384 for (size_t i = 0; i < items.size(); i++) { | |
385 InstantMostVisitedItem oldItem = oldItems[i].second; | |
386 InstantMostVisitedItem newItem = items[i].second; | |
387 if (newItem.url != oldItem.url || newItem.title != oldItem.title) { | |
388 most_visited_changed = true; | |
samarth
2013/05/03 21:24:42
Just return here.
| |
389 break; | |
390 } | |
391 } | |
392 } | |
393 | |
394 if (!most_visited_changed) { | |
395 return; | |
396 } | |
397 | |
376 most_visited_items_cache_.AddItemsWithRestrictedID(items); | 398 most_visited_items_cache_.AddItemsWithRestrictedID(items); |
377 | 399 |
378 if (render_view()->GetWebView() && render_view()->GetWebView()->mainFrame()) { | 400 if (render_view()->GetWebView() && render_view()->GetWebView()->mainFrame()) { |
379 extensions_v8::SearchBoxExtension::DispatchMostVisitedChanged( | 401 extensions_v8::SearchBoxExtension::DispatchMostVisitedChanged( |
380 render_view()->GetWebView()->mainFrame()); | 402 render_view()->GetWebView()->mainFrame()); |
381 } | 403 } |
382 } | 404 } |
383 | 405 |
384 void SearchBox::GetMostVisitedItems( | 406 void SearchBox::GetMostVisitedItems( |
385 std::vector<InstantMostVisitedItemIDPair>* items) const { | 407 std::vector<InstantMostVisitedItemIDPair>* items) const { |
386 return most_visited_items_cache_.GetCurrentItems(items); | 408 return most_visited_items_cache_.GetCurrentItems(items); |
387 } | 409 } |
388 | 410 |
389 bool SearchBox::GetMostVisitedItemWithID( | 411 bool SearchBox::GetMostVisitedItemWithID( |
390 InstantRestrictedID most_visited_item_id, | 412 InstantRestrictedID most_visited_item_id, |
391 InstantMostVisitedItem* item) const { | 413 InstantMostVisitedItem* item) const { |
392 return most_visited_items_cache_.GetItemWithRestrictedID(most_visited_item_id, | 414 return most_visited_items_cache_.GetItemWithRestrictedID(most_visited_item_id, |
393 item); | 415 item); |
394 } | 416 } |
OLD | NEW |