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 28 matching lines...) Expand all Loading... |
39 #include "content/public/browser/navigation_details.h" | 39 #include "content/public/browser/navigation_details.h" |
40 #include "content/public/browser/navigation_entry.h" | 40 #include "content/public/browser/navigation_entry.h" |
41 #include "content/public/browser/navigation_type.h" | 41 #include "content/public/browser/navigation_type.h" |
42 #include "content/public/browser/notification_service.h" | 42 #include "content/public/browser/notification_service.h" |
43 #include "content/public/browser/notification_source.h" | 43 #include "content/public/browser/notification_source.h" |
44 #include "content/public/browser/render_frame_host.h" | 44 #include "content/public/browser/render_frame_host.h" |
45 #include "content/public/browser/render_process_host.h" | 45 #include "content/public/browser/render_process_host.h" |
46 #include "content/public/browser/user_metrics.h" | 46 #include "content/public/browser/user_metrics.h" |
47 #include "content/public/browser/web_contents.h" | 47 #include "content/public/browser/web_contents.h" |
48 #include "content/public/common/referrer.h" | 48 #include "content/public/common/referrer.h" |
| 49 #include "google_apis/gaia/gaia_auth_util.h" |
49 #include "net/base/net_errors.h" | 50 #include "net/base/net_errors.h" |
50 #include "ui/base/l10n/l10n_util.h" | 51 #include "ui/base/l10n/l10n_util.h" |
51 #include "ui/base/page_transition_types.h" | 52 #include "ui/base/page_transition_types.h" |
52 #include "url/gurl.h" | 53 #include "url/gurl.h" |
53 | 54 |
54 DEFINE_WEB_CONTENTS_USER_DATA_KEY(SearchTabHelper); | 55 DEFINE_WEB_CONTENTS_USER_DATA_KEY(SearchTabHelper); |
55 | 56 |
56 namespace { | 57 namespace { |
57 | 58 |
58 // For reporting Cacheable NTP navigations. | 59 // For reporting Cacheable NTP navigations. |
(...skipping 497 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
556 omnibox->OnBeforePossibleChange(); | 557 omnibox->OnBeforePossibleChange(); |
557 omnibox->model()->OnPaste(); | 558 omnibox->model()->OnPaste(); |
558 omnibox->SetUserText(text_to_paste); | 559 omnibox->SetUserText(text_to_paste); |
559 omnibox->OnAfterPossibleChange(); | 560 omnibox->OnAfterPossibleChange(); |
560 #endif | 561 #endif |
561 } | 562 } |
562 | 563 |
563 void SearchTabHelper::OnChromeIdentityCheck(const base::string16& identity) { | 564 void SearchTabHelper::OnChromeIdentityCheck(const base::string16& identity) { |
564 SigninManagerBase* manager = SigninManagerFactory::GetForProfile(profile()); | 565 SigninManagerBase* manager = SigninManagerFactory::GetForProfile(profile()); |
565 if (manager) { | 566 if (manager) { |
566 const base::string16 username = | 567 ipc_router_.SendChromeIdentityCheckResult( |
567 base::UTF8ToUTF16(manager->GetAuthenticatedUsername()); | 568 identity, gaia::AreEmailsSame(base::UTF16ToUTF8(identity), |
568 ipc_router_.SendChromeIdentityCheckResult(identity, identity == username); | 569 manager->GetAuthenticatedUsername())); |
569 } else { | 570 } else { |
570 ipc_router_.SendChromeIdentityCheckResult(identity, false); | 571 ipc_router_.SendChromeIdentityCheckResult(identity, false); |
571 } | 572 } |
572 } | 573 } |
573 | 574 |
574 void SearchTabHelper::OnHistorySyncCheck() { | 575 void SearchTabHelper::OnHistorySyncCheck() { |
575 ipc_router_.SendHistorySyncCheckResult(IsHistorySyncEnabled(profile())); | 576 ipc_router_.SendHistorySyncCheckResult(IsHistorySyncEnabled(profile())); |
576 } | 577 } |
577 | 578 |
578 void SearchTabHelper::UpdateMode(bool update_origin, bool is_preloaded_ntp) { | 579 void SearchTabHelper::UpdateMode(bool update_origin, bool is_preloaded_ntp) { |
(...skipping 52 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
631 | 632 |
632 bool SearchTabHelper::IsInputInProgress() const { | 633 bool SearchTabHelper::IsInputInProgress() const { |
633 OmniboxView* omnibox = GetOmniboxView(); | 634 OmniboxView* omnibox = GetOmniboxView(); |
634 return !model_.mode().is_ntp() && omnibox && | 635 return !model_.mode().is_ntp() && omnibox && |
635 omnibox->model()->focus_state() == OMNIBOX_FOCUS_VISIBLE; | 636 omnibox->model()->focus_state() == OMNIBOX_FOCUS_VISIBLE; |
636 } | 637 } |
637 | 638 |
638 OmniboxView* SearchTabHelper::GetOmniboxView() const { | 639 OmniboxView* SearchTabHelper::GetOmniboxView() const { |
639 return delegate_ ? delegate_->GetOmniboxView() : NULL; | 640 return delegate_ ? delegate_->GetOmniboxView() : NULL; |
640 } | 641 } |
OLD | NEW |