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

Side by Side Diff: chrome/browser/geolocation/geolocation_confirm_infobar_delegate.cc

Issue 11748012: Minor cleanup to how infobars handle expiry: (Closed) Base URL: svn://chrome-svn/chrome/trunk/src/
Patch Set: Created 7 years, 11 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/geolocation/geolocation_confirm_infobar_delegate.h" 5 #include "chrome/browser/geolocation/geolocation_confirm_infobar_delegate.h"
6 6
7 #include "chrome/browser/api/infobars/infobar_service.h" 7 #include "chrome/browser/api/infobars/infobar_service.h"
8 #include "chrome/browser/geolocation/geolocation_infobar_queue_controller.h" 8 #include "chrome/browser/geolocation/geolocation_infobar_queue_controller.h"
9 #include "chrome/browser/google/google_util.h" 9 #include "chrome/browser/google/google_util.h"
10 #include "content/public/browser/navigation_details.h" 10 #include "content/public/browser/navigation_details.h"
(...skipping 13 matching lines...) Expand all
24 const GeolocationPermissionRequestID& id, 24 const GeolocationPermissionRequestID& id,
25 const GURL& requesting_frame, 25 const GURL& requesting_frame,
26 const std::string& display_languages) 26 const std::string& display_languages)
27 : ConfirmInfoBarDelegate(infobar_service), 27 : ConfirmInfoBarDelegate(infobar_service),
28 controller_(controller), 28 controller_(controller),
29 id_(id), 29 id_(id),
30 requesting_frame_(requesting_frame), 30 requesting_frame_(requesting_frame),
31 display_languages_(display_languages) { 31 display_languages_(display_languages) {
32 const content::NavigationEntry* committed_entry = infobar_service-> 32 const content::NavigationEntry* committed_entry = infobar_service->
33 GetWebContents()->GetController().GetLastCommittedEntry(); 33 GetWebContents()->GetController().GetLastCommittedEntry();
34 set_contents_unique_id(committed_entry ? committed_entry->GetUniqueID() : 0); 34 contents_unique_id_ = committed_entry ? committed_entry->GetUniqueID() : 0;
35 } 35 }
36 36
37 gfx::Image* GeolocationConfirmInfoBarDelegate::GetIcon() const { 37 gfx::Image* GeolocationConfirmInfoBarDelegate::GetIcon() const {
38 return &ResourceBundle::GetSharedInstance().GetNativeImageNamed( 38 return &ResourceBundle::GetSharedInstance().GetNativeImageNamed(
39 IDR_GEOLOCATION_INFOBAR_ICON); 39 IDR_GEOLOCATION_INFOBAR_ICON);
40 } 40 }
41 41
42 InfoBarDelegate::Type 42 InfoBarDelegate::Type
43 GeolocationConfirmInfoBarDelegate::GetInfoBarType() const { 43 GeolocationConfirmInfoBarDelegate::GetInfoBarType() const {
44 return PAGE_ACTION_TYPE; 44 return PAGE_ACTION_TYPE;
45 } 45 }
46 46
47 bool GeolocationConfirmInfoBarDelegate::ShouldExpireInternal(
48 const content::LoadCommittedDetails& details) const {
49 // This implementation matches InfoBarDelegate::ShouldExpireInternal(), but
50 // uses the unique ID we set in the constructor instead of that stored in the
51 // base class.
52 return (contents_unique_id_ != details.entry->GetUniqueID()) ||
53 (content::PageTransitionStripQualifier(
54 details.entry->GetTransitionType()) ==
55 content::PAGE_TRANSITION_RELOAD);
56 }
57
47 string16 GeolocationConfirmInfoBarDelegate::GetMessageText() const { 58 string16 GeolocationConfirmInfoBarDelegate::GetMessageText() const {
48 return l10n_util::GetStringFUTF16(IDS_GEOLOCATION_INFOBAR_QUESTION, 59 return l10n_util::GetStringFUTF16(IDS_GEOLOCATION_INFOBAR_QUESTION,
49 net::FormatUrl(requesting_frame_.GetOrigin(), display_languages_)); 60 net::FormatUrl(requesting_frame_.GetOrigin(), display_languages_));
50 } 61 }
51 62
52 string16 GeolocationConfirmInfoBarDelegate::GetButtonLabel( 63 string16 GeolocationConfirmInfoBarDelegate::GetButtonLabel(
53 InfoBarButton button) const { 64 InfoBarButton button) const {
54 return l10n_util::GetStringUTF16((button == BUTTON_OK) ? 65 return l10n_util::GetStringUTF16((button == BUTTON_OK) ?
55 IDS_GEOLOCATION_ALLOW_BUTTON : IDS_GEOLOCATION_DENY_BUTTON); 66 IDS_GEOLOCATION_ALLOW_BUTTON : IDS_GEOLOCATION_DENY_BUTTON);
56 } 67 }
(...skipping 29 matching lines...) Expand all
86 #endif 97 #endif
87 98
88 content::OpenURLParams params( 99 content::OpenURLParams params(
89 google_util::AppendGoogleLocaleParam(GURL(kGeolocationLearnMoreUrl)), 100 google_util::AppendGoogleLocaleParam(GURL(kGeolocationLearnMoreUrl)),
90 content::Referrer(), 101 content::Referrer(),
91 (disposition == CURRENT_TAB) ? NEW_FOREGROUND_TAB : disposition, 102 (disposition == CURRENT_TAB) ? NEW_FOREGROUND_TAB : disposition,
92 content::PAGE_TRANSITION_LINK, false); 103 content::PAGE_TRANSITION_LINK, false);
93 owner()->GetWebContents()->OpenURL(params); 104 owner()->GetWebContents()->OpenURL(params);
94 return false; // Do not dismiss the info bar. 105 return false; // Do not dismiss the info bar.
95 } 106 }
OLDNEW

Powered by Google App Engine
This is Rietveld 408576698