Chromium Code Reviews
chromiumcodereview-hr@appspot.gserviceaccount.com (chromiumcodereview-hr) | Please choose your nickname with Settings | Help | Chromium Project | Gerrit Changes | Sign out
(514)

Side by Side Diff: chrome/browser/google/google_url_tracker_infobar_delegate.cc

Issue 230453004: Remove InfoBarDelegate::web_contents() (Closed) Base URL: svn://svn.chromium.org/chrome/trunk/src
Patch Set: fix android Created 6 years, 8 months ago
Use n/p to move between diff chunks; N/P to move between comments. Draft comments are only viewable by you.
Jump to:
View unified diff | Download patch | Annotate | Revision Log
OLDNEW
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
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
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 content::WebContents* web_contents =
111 InfoBarService::WebContentsFromInfoBar(infobar());
112 web_contents->OpenURL(content::OpenURLParams(
110 google_util::AppendGoogleLocaleParam(GURL( 113 google_util::AppendGoogleLocaleParam(GURL(
111 "https://www.google.com/support/chrome/bin/answer.py?" 114 "https://www.google.com/support/chrome/bin/answer.py?"
112 "answer=1618699")), 115 "answer=1618699")),
113 content::Referrer(), 116 content::Referrer(),
114 (disposition == CURRENT_TAB) ? NEW_FOREGROUND_TAB : disposition, 117 (disposition == CURRENT_TAB) ? NEW_FOREGROUND_TAB : disposition,
115 content::PAGE_TRANSITION_LINK, false)); 118 content::PAGE_TRANSITION_LINK, false));
116 return false; 119 return false;
117 } 120 }
118 121
119 bool GoogleURLTrackerInfoBarDelegate::ShouldExpireInternal( 122 bool GoogleURLTrackerInfoBarDelegate::ShouldExpireInternal(
120 const NavigationDetails& details) const { 123 const NavigationDetails& details) const {
121 return (details.entry_id != contents_unique_id()) && 124 return (details.entry_id != contents_unique_id()) &&
122 (details.entry_id != pending_id_); 125 (details.entry_id != pending_id_);
123 } 126 }
OLDNEW

Powered by Google App Engine
This is Rietveld 408576698