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.h" | 9 #include "chrome/browser/infobars/infobar.h" |
10 #include "chrome/browser/infobars/infobar_service.h" | 10 #include "chrome/browser/infobars/infobar_service.h" |
(...skipping 40 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
51 GURL new_search_url; | 51 GURL new_search_url; |
52 if (redo_search) { | 52 if (redo_search) { |
53 // Re-do the user's search on the new domain. | 53 // Re-do the user's search on the new domain. |
54 DCHECK(search_url_.is_valid()); | 54 DCHECK(search_url_.is_valid()); |
55 url_canon::Replacements<char> replacements; | 55 url_canon::Replacements<char> replacements; |
56 const std::string& host(google_url_tracker_->fetched_google_url().host()); | 56 const std::string& host(google_url_tracker_->fetched_google_url().host()); |
57 replacements.SetHost(host.data(), url_parse::Component(0, host.length())); | 57 replacements.SetHost(host.data(), url_parse::Component(0, host.length())); |
58 new_search_url = search_url_.ReplaceComponents(replacements); | 58 new_search_url = search_url_.ReplaceComponents(replacements); |
59 } | 59 } |
60 | 60 |
61 content::WebContents* contents = web_contents(); | 61 content::WebContents* contents = |
| 62 InfoBarService::WebContentsFromInfoBar(infobar()); |
62 infobar()->RemoveSelf(); | 63 infobar()->RemoveSelf(); |
63 // WARNING: |this| may be deleted at this point! Do not access any members! | 64 // WARNING: |this| may be deleted at this point! Do not access any members! |
64 | 65 |
65 if (new_search_url.is_valid()) { | 66 if (new_search_url.is_valid()) { |
66 contents->OpenURL(content::OpenURLParams( | 67 contents->OpenURL(content::OpenURLParams( |
67 new_search_url, content::Referrer(), CURRENT_TAB, | 68 new_search_url, content::Referrer(), CURRENT_TAB, |
68 content::PAGE_TRANSITION_GENERATED, false)); | 69 content::PAGE_TRANSITION_GENERATED, false)); |
69 } | 70 } |
70 } | 71 } |
71 | 72 |
(...skipping 27 matching lines...) Expand all Loading... |
99 IDS_GOOGLE_URL_TRACKER_INFOBAR_DONT_SWITCH, | 100 IDS_GOOGLE_URL_TRACKER_INFOBAR_DONT_SWITCH, |
100 net::StripWWWFromHost(google_url_tracker_->google_url())); | 101 net::StripWWWFromHost(google_url_tracker_->google_url())); |
101 } | 102 } |
102 | 103 |
103 base::string16 GoogleURLTrackerInfoBarDelegate::GetLinkText() const { | 104 base::string16 GoogleURLTrackerInfoBarDelegate::GetLinkText() const { |
104 return l10n_util::GetStringUTF16(IDS_LEARN_MORE); | 105 return l10n_util::GetStringUTF16(IDS_LEARN_MORE); |
105 } | 106 } |
106 | 107 |
107 bool GoogleURLTrackerInfoBarDelegate::LinkClicked( | 108 bool GoogleURLTrackerInfoBarDelegate::LinkClicked( |
108 WindowOpenDisposition disposition) { | 109 WindowOpenDisposition disposition) { |
109 web_contents()->OpenURL(content::OpenURLParams( | 110 InfoBarService::WebContentsFromInfoBar(infobar())->OpenURL( |
110 google_util::AppendGoogleLocaleParam(GURL( | 111 content::OpenURLParams( |
111 "https://www.google.com/support/chrome/bin/answer.py?" | 112 google_util::AppendGoogleLocaleParam(GURL( |
112 "answer=1618699")), | 113 "https://www.google.com/support/chrome/bin/answer.py?" |
113 content::Referrer(), | 114 "answer=1618699")), |
114 (disposition == CURRENT_TAB) ? NEW_FOREGROUND_TAB : disposition, | 115 content::Referrer(), |
115 content::PAGE_TRANSITION_LINK, false)); | 116 (disposition == CURRENT_TAB) ? NEW_FOREGROUND_TAB : disposition, |
| 117 content::PAGE_TRANSITION_LINK, false)); |
116 return false; | 118 return false; |
117 } | 119 } |
118 | 120 |
119 bool GoogleURLTrackerInfoBarDelegate::ShouldExpireInternal( | 121 bool GoogleURLTrackerInfoBarDelegate::ShouldExpireInternal( |
120 const NavigationDetails& details) const { | 122 const NavigationDetails& details) const { |
121 return (details.entry_id != contents_unique_id()) && | 123 return (details.entry_id != contents_unique_id()) && |
122 (details.entry_id != pending_id_); | 124 (details.entry_id != pending_id_); |
123 } | 125 } |
OLD | NEW |