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