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/search_tab_helper.h" | 5 #include "chrome/browser/ui/search/search_tab_helper.h" |
6 | 6 |
7 #include <set> | 7 #include <set> |
8 | 8 |
9 #include "base/memory/scoped_ptr.h" | 9 #include "base/memory/scoped_ptr.h" |
10 #include "base/metrics/histogram.h" | 10 #include "base/metrics/histogram.h" |
(...skipping 547 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
558 omnibox->SetUserText(text_to_paste); | 558 omnibox->SetUserText(text_to_paste); |
559 omnibox->OnAfterPossibleChange(); | 559 omnibox->OnAfterPossibleChange(); |
560 #endif | 560 #endif |
561 } | 561 } |
562 | 562 |
563 void SearchTabHelper::OnChromeIdentityCheck(const base::string16& identity) { | 563 void SearchTabHelper::OnChromeIdentityCheck(const base::string16& identity) { |
564 SigninManagerBase* manager = SigninManagerFactory::GetForProfile(profile()); | 564 SigninManagerBase* manager = SigninManagerFactory::GetForProfile(profile()); |
565 if (manager) { | 565 if (manager) { |
566 const base::string16 username = | 566 const base::string16 username = |
567 base::UTF8ToUTF16(manager->GetAuthenticatedUsername()); | 567 base::UTF8ToUTF16(manager->GetAuthenticatedUsername()); |
568 // The identity check only passes if the user is syncing their history. | 568 ipc_router_.SendChromeIdentityCheckResult(identity, identity == username); |
569 // TODO(beaudoin): Change this function name and related APIs now that it's | 569 } else { |
570 // checking both the identity and the user's sync state. | 570 ipc_router_.SendChromeIdentityCheckResult(identity, false); |
571 bool matches = IsHistorySyncEnabled(profile()) && identity == username; | |
572 ipc_router_.SendChromeIdentityCheckResult(identity, matches); | |
573 } | 571 } |
574 } | 572 } |
575 | 573 |
| 574 void SearchTabHelper::OnHistorySyncCheck() { |
| 575 ipc_router_.SendHistorySyncCheckResult(IsHistorySyncEnabled(profile())); |
| 576 } |
| 577 |
576 void SearchTabHelper::UpdateMode(bool update_origin, bool is_preloaded_ntp) { | 578 void SearchTabHelper::UpdateMode(bool update_origin, bool is_preloaded_ntp) { |
577 SearchMode::Type type = SearchMode::MODE_DEFAULT; | 579 SearchMode::Type type = SearchMode::MODE_DEFAULT; |
578 SearchMode::Origin origin = SearchMode::ORIGIN_DEFAULT; | 580 SearchMode::Origin origin = SearchMode::ORIGIN_DEFAULT; |
579 if (IsNTP(web_contents_) || is_preloaded_ntp) { | 581 if (IsNTP(web_contents_) || is_preloaded_ntp) { |
580 type = SearchMode::MODE_NTP; | 582 type = SearchMode::MODE_NTP; |
581 origin = SearchMode::ORIGIN_NTP; | 583 origin = SearchMode::ORIGIN_NTP; |
582 } else if (IsSearchResults(web_contents_)) { | 584 } else if (IsSearchResults(web_contents_)) { |
583 type = SearchMode::MODE_SEARCH_RESULTS; | 585 type = SearchMode::MODE_SEARCH_RESULTS; |
584 origin = SearchMode::ORIGIN_SEARCH; | 586 origin = SearchMode::ORIGIN_SEARCH; |
585 } | 587 } |
(...skipping 43 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
629 | 631 |
630 bool SearchTabHelper::IsInputInProgress() const { | 632 bool SearchTabHelper::IsInputInProgress() const { |
631 OmniboxView* omnibox = GetOmniboxView(); | 633 OmniboxView* omnibox = GetOmniboxView(); |
632 return !model_.mode().is_ntp() && omnibox && | 634 return !model_.mode().is_ntp() && omnibox && |
633 omnibox->model()->focus_state() == OMNIBOX_FOCUS_VISIBLE; | 635 omnibox->model()->focus_state() == OMNIBOX_FOCUS_VISIBLE; |
634 } | 636 } |
635 | 637 |
636 OmniboxView* SearchTabHelper::GetOmniboxView() const { | 638 OmniboxView* SearchTabHelper::GetOmniboxView() const { |
637 return delegate_ ? delegate_->GetOmniboxView() : NULL; | 639 return delegate_ ? delegate_->GetOmniboxView() : NULL; |
638 } | 640 } |
OLD | NEW |