Chromium Code Reviews| 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 313 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... | |
| 324 DVLOG(1) << render_view() << " OnKeyCaptureChange"; | 324 DVLOG(1) << render_view() << " OnKeyCaptureChange"; |
| 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 bool SearchBox::DidThemeInfoChange(const ThemeBackgroundInfo& theme_info) { | |
|
samarth
2013/05/03 22:18:45
nit: Please move the anonymous namespace at the to
| |
| 335 return theme_info_.color_r != theme_info.color_r || | |
| 336 theme_info_.color_g != theme_info.color_g || | |
| 337 theme_info_.color_b != theme_info.color_b || | |
| 338 theme_info_.color_a != theme_info.color_a || | |
| 339 theme_info_.theme_id != theme_info.theme_id || | |
| 340 theme_info_.image_horizontal_alignment != | |
| 341 theme_info.image_horizontal_alignment || | |
| 342 theme_info_.image_vertical_alignment != | |
| 343 theme_info.image_vertical_alignment || | |
| 344 theme_info_.image_tiling != theme_info.image_tiling || | |
| 345 theme_info_.image_height != theme_info.image_height || | |
| 346 theme_info_.has_attribution != theme_info.has_attribution; | |
|
samarth
2013/05/03 22:18:45
Please also add a comment in instant_types.h to ke
| |
| 347 } | |
| 348 | |
| 334 void SearchBox::OnThemeChanged(const ThemeBackgroundInfo& theme_info) { | 349 void SearchBox::OnThemeChanged(const ThemeBackgroundInfo& theme_info) { |
| 350 if (!DidThemeInfoChange(theme_info)) | |
| 351 return; | |
| 335 theme_info_ = theme_info; | 352 theme_info_ = theme_info; |
| 336 if (render_view()->GetWebView() && render_view()->GetWebView()->mainFrame()) { | 353 if (render_view()->GetWebView() && render_view()->GetWebView()->mainFrame()) { |
| 337 extensions_v8::SearchBoxExtension::DispatchThemeChange( | 354 extensions_v8::SearchBoxExtension::DispatchThemeChange( |
| 338 render_view()->GetWebView()->mainFrame()); | 355 render_view()->GetWebView()->mainFrame()); |
| 339 } | 356 } |
| 340 } | 357 } |
| 341 | 358 |
| 342 void SearchBox::OnFontInformationReceived(const string16& omnibox_font, | 359 void SearchBox::OnFontInformationReceived(const string16& omnibox_font, |
| 343 size_t omnibox_font_size) { | 360 size_t omnibox_font_size) { |
| 344 omnibox_font_ = omnibox_font; | 361 omnibox_font_ = omnibox_font; |
| (...skipping 19 matching lines...) Expand all Loading... | |
| 364 start_margin_ = 0; | 381 start_margin_ = 0; |
| 365 is_key_capture_enabled_ = false; | 382 is_key_capture_enabled_ = false; |
| 366 theme_info_ = ThemeBackgroundInfo(); | 383 theme_info_ = ThemeBackgroundInfo(); |
| 367 // Don't reset display_instant_results_ to prevent clearing it on committed | 384 // 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 | 385 // 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. | 386 // 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 | 387 // Also don't reset omnibox_font_ or omnibox_font_size_ since it never |
| 371 // changes. | 388 // changes. |
| 372 } | 389 } |
| 373 | 390 |
| 391 bool SearchBox::DidMostVisitedItemsChange( | |
|
samarth
2013/05/03 22:18:45
Likewise (anonymous namespace please).
| |
| 392 const std::vector<InstantMostVisitedItemIDPair>& items) { | |
| 393 std::vector<InstantMostVisitedItemIDPair> oldItems; | |
| 394 most_visited_items_cache_.GetCurrentItems(&oldItems); | |
| 395 bool most_visited_changed = oldItems.size() != items.size(); | |
| 396 if (!most_visited_changed) { | |
| 397 for (size_t i = 0; i < items.size(); i++) { | |
| 398 InstantMostVisitedItem oldItem = oldItems[i].second; | |
| 399 InstantMostVisitedItem newItem = items[i].second; | |
| 400 if (newItem.url != oldItem.url || newItem.title != oldItem.title) { | |
| 401 most_visited_changed = true; | |
| 402 break; | |
| 403 } | |
| 404 } | |
| 405 } | |
| 406 return most_visited_changed; | |
| 407 } | |
| 408 | |
| 374 void SearchBox::OnMostVisitedChanged( | 409 void SearchBox::OnMostVisitedChanged( |
| 375 const std::vector<InstantMostVisitedItemIDPair>& items) { | 410 const std::vector<InstantMostVisitedItemIDPair>& items) { |
| 411 if (!DidMostVisitedItemsChange(items)) | |
| 412 return; | |
| 413 | |
| 376 most_visited_items_cache_.AddItemsWithRestrictedID(items); | 414 most_visited_items_cache_.AddItemsWithRestrictedID(items); |
| 377 | 415 |
| 378 if (render_view()->GetWebView() && render_view()->GetWebView()->mainFrame()) { | 416 if (render_view()->GetWebView() && render_view()->GetWebView()->mainFrame()) { |
| 379 extensions_v8::SearchBoxExtension::DispatchMostVisitedChanged( | 417 extensions_v8::SearchBoxExtension::DispatchMostVisitedChanged( |
| 380 render_view()->GetWebView()->mainFrame()); | 418 render_view()->GetWebView()->mainFrame()); |
| 381 } | 419 } |
| 382 } | 420 } |
| 383 | 421 |
| 384 void SearchBox::GetMostVisitedItems( | 422 void SearchBox::GetMostVisitedItems( |
| 385 std::vector<InstantMostVisitedItemIDPair>* items) const { | 423 std::vector<InstantMostVisitedItemIDPair>* items) const { |
| 386 return most_visited_items_cache_.GetCurrentItems(items); | 424 return most_visited_items_cache_.GetCurrentItems(items); |
| 387 } | 425 } |
| 388 | 426 |
| 389 bool SearchBox::GetMostVisitedItemWithID( | 427 bool SearchBox::GetMostVisitedItemWithID( |
| 390 InstantRestrictedID most_visited_item_id, | 428 InstantRestrictedID most_visited_item_id, |
| 391 InstantMostVisitedItem* item) const { | 429 InstantMostVisitedItem* item) const { |
| 392 return most_visited_items_cache_.GetItemWithRestrictedID(most_visited_item_id, | 430 return most_visited_items_cache_.GetItemWithRestrictedID(most_visited_item_id, |
| 393 item); | 431 item); |
| 394 } | 432 } |
| OLD | NEW |