OLD | NEW |
1 // Copyright (c) 2012 The Chromium Authors. All rights reserved. | 1 // Copyright (c) 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/google/google_url_tracker_infobar_delegate.h" | 5 #include "chrome/browser/google/google_url_tracker_infobar_delegate.h" |
6 | 6 |
7 #include "chrome/browser/google/google_url_tracker.h" | 7 #include "chrome/browser/google/google_url_tracker.h" |
8 #include "chrome/browser/google/google_util.h" | 8 #include "chrome/browser/google/google_util.h" |
9 #include "chrome/browser/infobars/infobar_service.h" | 9 #include "chrome/browser/infobars/infobar_service.h" |
10 #include "content/public/browser/navigation_details.h" | 10 #include "content/public/browser/navigation_details.h" |
(...skipping 30 matching lines...) Expand all Loading... |
41 return l10n_util::GetStringUTF16(IDS_LEARN_MORE); | 41 return l10n_util::GetStringUTF16(IDS_LEARN_MORE); |
42 } | 42 } |
43 | 43 |
44 bool GoogleURLTrackerInfoBarDelegate::LinkClicked( | 44 bool GoogleURLTrackerInfoBarDelegate::LinkClicked( |
45 WindowOpenDisposition disposition) { | 45 WindowOpenDisposition disposition) { |
46 content::OpenURLParams params(google_util::AppendGoogleLocaleParam(GURL( | 46 content::OpenURLParams params(google_util::AppendGoogleLocaleParam(GURL( |
47 "https://www.google.com/support/chrome/bin/answer.py?answer=1618699")), | 47 "https://www.google.com/support/chrome/bin/answer.py?answer=1618699")), |
48 content::Referrer(), | 48 content::Referrer(), |
49 (disposition == CURRENT_TAB) ? NEW_FOREGROUND_TAB : disposition, | 49 (disposition == CURRENT_TAB) ? NEW_FOREGROUND_TAB : disposition, |
50 content::PAGE_TRANSITION_LINK, false); | 50 content::PAGE_TRANSITION_LINK, false); |
51 owner()->GetWebContents()->OpenURL(params); | 51 owner()->web_contents()->OpenURL(params); |
52 return false; | 52 return false; |
53 } | 53 } |
54 | 54 |
55 bool GoogleURLTrackerInfoBarDelegate::ShouldExpireInternal( | 55 bool GoogleURLTrackerInfoBarDelegate::ShouldExpireInternal( |
56 const content::LoadCommittedDetails& details) const { | 56 const content::LoadCommittedDetails& details) const { |
57 int unique_id = details.entry->GetUniqueID(); | 57 int unique_id = details.entry->GetUniqueID(); |
58 return (unique_id != contents_unique_id()) && (unique_id != pending_id_); | 58 return (unique_id != contents_unique_id()) && (unique_id != pending_id_); |
59 } | 59 } |
60 | 60 |
61 void GoogleURLTrackerInfoBarDelegate::Update(const GURL& search_url) { | 61 void GoogleURLTrackerInfoBarDelegate::Update(const GURL& search_url) { |
62 StoreActiveEntryUniqueID(); | 62 StoreActiveEntryUniqueID(); |
63 search_url_ = search_url; | 63 search_url_ = search_url; |
64 pending_id_ = 0; | 64 pending_id_ = 0; |
65 } | 65 } |
66 | 66 |
67 void GoogleURLTrackerInfoBarDelegate::Close(bool redo_search) { | 67 void GoogleURLTrackerInfoBarDelegate::Close(bool redo_search) { |
68 if (redo_search) { | 68 if (redo_search) { |
69 // Re-do the user's search on the new domain. | 69 // Re-do the user's search on the new domain. |
70 DCHECK(search_url_.is_valid()); | 70 DCHECK(search_url_.is_valid()); |
71 url_canon::Replacements<char> replacements; | 71 url_canon::Replacements<char> replacements; |
72 const std::string& host(google_url_tracker_->fetched_google_url().host()); | 72 const std::string& host(google_url_tracker_->fetched_google_url().host()); |
73 replacements.SetHost(host.data(), url_parse::Component(0, host.length())); | 73 replacements.SetHost(host.data(), url_parse::Component(0, host.length())); |
74 GURL new_search_url(search_url_.ReplaceComponents(replacements)); | 74 GURL new_search_url(search_url_.ReplaceComponents(replacements)); |
75 if (new_search_url.is_valid()) { | 75 if (new_search_url.is_valid()) { |
76 owner()->GetWebContents()->OpenURL(content::OpenURLParams( | 76 owner()->web_contents()->OpenURL(content::OpenURLParams( |
77 new_search_url, content::Referrer(), CURRENT_TAB, | 77 new_search_url, content::Referrer(), CURRENT_TAB, |
78 content::PAGE_TRANSITION_GENERATED, false)); | 78 content::PAGE_TRANSITION_GENERATED, false)); |
79 } | 79 } |
80 } | 80 } |
81 | 81 |
82 owner()->RemoveInfoBar(this); | 82 owner()->RemoveInfoBar(this); |
83 } | 83 } |
84 | 84 |
85 GoogleURLTrackerInfoBarDelegate::GoogleURLTrackerInfoBarDelegate( | 85 GoogleURLTrackerInfoBarDelegate::GoogleURLTrackerInfoBarDelegate( |
86 InfoBarService* infobar_service, | 86 InfoBarService* infobar_service, |
(...skipping 19 matching lines...) Expand all Loading... |
106 InfoBarButton button) const { | 106 InfoBarButton button) const { |
107 if (button == BUTTON_OK) { | 107 if (button == BUTTON_OK) { |
108 return l10n_util::GetStringFUTF16( | 108 return l10n_util::GetStringFUTF16( |
109 IDS_GOOGLE_URL_TRACKER_INFOBAR_SWITCH, | 109 IDS_GOOGLE_URL_TRACKER_INFOBAR_SWITCH, |
110 net::StripWWWFromHost(google_url_tracker_->fetched_google_url())); | 110 net::StripWWWFromHost(google_url_tracker_->fetched_google_url())); |
111 } | 111 } |
112 return l10n_util::GetStringFUTF16( | 112 return l10n_util::GetStringFUTF16( |
113 IDS_GOOGLE_URL_TRACKER_INFOBAR_DONT_SWITCH, | 113 IDS_GOOGLE_URL_TRACKER_INFOBAR_DONT_SWITCH, |
114 net::StripWWWFromHost(google_url_tracker_->google_url())); | 114 net::StripWWWFromHost(google_url_tracker_->google_url())); |
115 } | 115 } |
OLD | NEW |