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

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

Issue 8775004: Geolocation InfoBar sometimes doesn't expire when navigating back. (Closed) Base URL: svn://svn.chromium.org/chrome/trunk/src
Patch Set: Created 9 years 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
« no previous file with comments | « no previous file | chrome/browser/geolocation/chrome_geolocation_permission_context_unittest.cc » ('j') | no next file with comments »
Toggle Intra-line Diffs ('i') | Expand Comments ('e') | Collapse Comments ('c') | Show Comments Hide Comments ('s')
OLDNEW
1 // Copyright (c) 2011 The Chromium Authors. All rights reserved. 1 // Copyright (c) 2011 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/chrome_geolocation_permission_context.h" 5 #include "chrome/browser/geolocation/chrome_geolocation_permission_context.h"
6 6
7 #include <functional> 7 #include <functional>
8 #include <string> 8 #include <string>
9 #include <vector> 9 #include <vector>
10 10
11 #include "base/bind.h" 11 #include "base/bind.h"
12 #include "base/utf_string_conversions.h" 12 #include "base/utf_string_conversions.h"
13 #include "chrome/browser/content_settings/host_content_settings_map.h" 13 #include "chrome/browser/content_settings/host_content_settings_map.h"
14 #include "chrome/browser/content_settings/tab_specific_content_settings.h" 14 #include "chrome/browser/content_settings/tab_specific_content_settings.h"
15 #include "chrome/browser/extensions/extension_service.h" 15 #include "chrome/browser/extensions/extension_service.h"
16 #include "chrome/browser/google/google_util.h" 16 #include "chrome/browser/google/google_util.h"
17 #include "chrome/browser/infobars/infobar_tab_helper.h" 17 #include "chrome/browser/infobars/infobar_tab_helper.h"
18 #include "chrome/browser/prefs/pref_service.h" 18 #include "chrome/browser/prefs/pref_service.h"
19 #include "chrome/browser/profiles/profile.h" 19 #include "chrome/browser/profiles/profile.h"
20 #include "chrome/browser/tab_contents/confirm_infobar_delegate.h" 20 #include "chrome/browser/tab_contents/confirm_infobar_delegate.h"
21 #include "chrome/browser/tab_contents/tab_util.h" 21 #include "chrome/browser/tab_contents/tab_util.h"
22 #include "chrome/browser/ui/tab_contents/tab_contents_wrapper.h" 22 #include "chrome/browser/ui/tab_contents/tab_contents_wrapper.h"
23 #include "chrome/common/extensions/extension.h" 23 #include "chrome/common/extensions/extension.h"
24 #include "chrome/common/pref_names.h" 24 #include "chrome/common/pref_names.h"
25 #include "content/browser/geolocation/geolocation_provider.h" 25 #include "content/browser/geolocation/geolocation_provider.h"
26 #include "content/browser/renderer_host/render_view_host.h" 26 #include "content/browser/renderer_host/render_view_host.h"
27 #include "content/browser/tab_contents/navigation_details.h"
27 #include "content/browser/tab_contents/tab_contents.h" 28 #include "content/browser/tab_contents/tab_contents.h"
28 #include "content/public/browser/browser_thread.h" 29 #include "content/public/browser/browser_thread.h"
29 #include "content/public/browser/notification_registrar.h" 30 #include "content/public/browser/notification_registrar.h"
30 #include "content/public/browser/notification_source.h" 31 #include "content/public/browser/notification_source.h"
31 #include "content/public/browser/notification_types.h" 32 #include "content/public/browser/notification_types.h"
32 #include "grit/generated_resources.h" 33 #include "grit/generated_resources.h"
33 #include "grit/locale_settings.h" 34 #include "grit/locale_settings.h"
34 #include "grit/theme_resources.h" 35 #include "grit/theme_resources.h"
35 #include "grit/theme_resources_standard.h" 36 #include "grit/theme_resources_standard.h"
36 #include "net/base/net_util.h" 37 #include "net/base/net_util.h"
(...skipping 87 matching lines...) Expand 10 before | Expand all | Expand 10 after
124 int render_process_id, 125 int render_process_id,
125 int render_view_id, 126 int render_view_id,
126 int bridge_id, 127 int bridge_id,
127 const GURL& requesting_frame_url, 128 const GURL& requesting_frame_url,
128 const std::string& display_languages); 129 const std::string& display_languages);
129 130
130 private: 131 private:
131 virtual ~GeolocationConfirmInfoBarDelegate(); 132 virtual ~GeolocationConfirmInfoBarDelegate();
132 133
133 // ConfirmInfoBarDelegate: 134 // ConfirmInfoBarDelegate:
135 virtual bool ShouldExpire(
136 const content::LoadCommittedDetails& details) const OVERRIDE;
134 virtual gfx::Image* GetIcon() const OVERRIDE; 137 virtual gfx::Image* GetIcon() const OVERRIDE;
135 virtual Type GetInfoBarType() const OVERRIDE; 138 virtual Type GetInfoBarType() const OVERRIDE;
136 virtual string16 GetMessageText() const OVERRIDE; 139 virtual string16 GetMessageText() const OVERRIDE;
137 virtual string16 GetButtonLabel(InfoBarButton button) const OVERRIDE; 140 virtual string16 GetButtonLabel(InfoBarButton button) const OVERRIDE;
138 virtual bool Accept() OVERRIDE; 141 virtual bool Accept() OVERRIDE;
139 virtual bool Cancel() OVERRIDE; 142 virtual bool Cancel() OVERRIDE;
140 virtual string16 GetLinkText() const OVERRIDE; 143 virtual string16 GetLinkText() const OVERRIDE;
141 virtual bool LinkClicked(WindowOpenDisposition disposition) OVERRIDE; 144 virtual bool LinkClicked(WindowOpenDisposition disposition) OVERRIDE;
142 145
143 GeolocationInfoBarQueueController* controller_; 146 GeolocationInfoBarQueueController* controller_;
144 int render_process_id_; 147 int render_process_id_;
145 int render_view_id_; 148 int render_view_id_;
146 int bridge_id_; 149 int bridge_id_;
150 // The unique id of the committed NavigationEntry of the TabContents that we
151 // were opened for. Used to help expire on navigations.
152 int committed_contents_unique_id_;
153
147 GURL requesting_frame_url_; 154 GURL requesting_frame_url_;
148 std::string display_languages_; 155 std::string display_languages_;
149 156
150 DISALLOW_IMPLICIT_CONSTRUCTORS(GeolocationConfirmInfoBarDelegate); 157 DISALLOW_IMPLICIT_CONSTRUCTORS(GeolocationConfirmInfoBarDelegate);
151 }; 158 };
152 159
153 GeolocationConfirmInfoBarDelegate::GeolocationConfirmInfoBarDelegate( 160 GeolocationConfirmInfoBarDelegate::GeolocationConfirmInfoBarDelegate(
154 InfoBarTabHelper* infobar_helper, 161 InfoBarTabHelper* infobar_helper,
155 GeolocationInfoBarQueueController* controller, 162 GeolocationInfoBarQueueController* controller,
156 int render_process_id, 163 int render_process_id,
157 int render_view_id, 164 int render_view_id,
158 int bridge_id, 165 int bridge_id,
159 const GURL& requesting_frame_url, 166 const GURL& requesting_frame_url,
160 const std::string& display_languages) 167 const std::string& display_languages)
161 : ConfirmInfoBarDelegate(infobar_helper), 168 : ConfirmInfoBarDelegate(infobar_helper),
162 controller_(controller), 169 controller_(controller),
163 render_process_id_(render_process_id), 170 render_process_id_(render_process_id),
164 render_view_id_(render_view_id), 171 render_view_id_(render_view_id),
165 bridge_id_(bridge_id), 172 bridge_id_(bridge_id),
166 requesting_frame_url_(requesting_frame_url), 173 requesting_frame_url_(requesting_frame_url),
167 display_languages_(display_languages) { 174 display_languages_(display_languages) {
175 const NavigationEntry* committed_entry =
176 infobar_helper->tab_contents()->controller().GetLastCommittedEntry();
177 committed_contents_unique_id_ = committed_entry ?
178 committed_entry->unique_id() : 0;
168 } 179 }
169 180
170 GeolocationConfirmInfoBarDelegate::~GeolocationConfirmInfoBarDelegate() { 181 GeolocationConfirmInfoBarDelegate::~GeolocationConfirmInfoBarDelegate() {
171 controller_->OnInfoBarClosed(render_process_id_, render_view_id_, 182 controller_->OnInfoBarClosed(render_process_id_, render_view_id_,
172 bridge_id_); 183 bridge_id_);
173 } 184 }
174 185
186 bool GeolocationConfirmInfoBarDelegate::ShouldExpire(
187 const content::LoadCommittedDetails& details) const {
188 if (details.did_replace_entry || !details.is_navigation_to_different_page())
189 return false;
190 return committed_contents_unique_id_ != details.entry->unique_id() ||
191 content::PageTransitionStripQualifier(details.entry->transition_type()) ==
192 content::PAGE_TRANSITION_RELOAD;
193 }
194
175 gfx::Image* GeolocationConfirmInfoBarDelegate::GetIcon() const { 195 gfx::Image* GeolocationConfirmInfoBarDelegate::GetIcon() const {
176 return &ResourceBundle::GetSharedInstance().GetNativeImageNamed( 196 return &ResourceBundle::GetSharedInstance().GetNativeImageNamed(
177 IDR_GEOLOCATION_INFOBAR_ICON); 197 IDR_GEOLOCATION_INFOBAR_ICON);
178 } 198 }
179 199
180 InfoBarDelegate::Type 200 InfoBarDelegate::Type
181 GeolocationConfirmInfoBarDelegate::GetInfoBarType() const { 201 GeolocationConfirmInfoBarDelegate::GetInfoBarType() const {
182 return PAGE_ACTION_TYPE; 202 return PAGE_ACTION_TYPE;
183 } 203 }
184 204
(...skipping 457 matching lines...) Expand 10 before | Expand all | Expand 10 after
642 BrowserThread::UI, FROM_HERE, 662 BrowserThread::UI, FROM_HERE,
643 base::Bind( 663 base::Bind(
644 &ChromeGeolocationPermissionContext::CancelPendingInfoBarRequest, 664 &ChromeGeolocationPermissionContext::CancelPendingInfoBarRequest,
645 this, render_process_id, render_view_id, bridge_id)); 665 this, render_process_id, render_view_id, bridge_id));
646 return; 666 return;
647 } 667 }
648 DCHECK(BrowserThread::CurrentlyOn(BrowserThread::UI)); 668 DCHECK(BrowserThread::CurrentlyOn(BrowserThread::UI));
649 geolocation_infobar_queue_controller_->CancelInfoBarRequest(render_process_id, 669 geolocation_infobar_queue_controller_->CancelInfoBarRequest(render_process_id,
650 render_view_id, bridge_id); 670 render_view_id, bridge_id);
651 } 671 }
OLDNEW
« no previous file with comments | « no previous file | chrome/browser/geolocation/chrome_geolocation_permission_context_unittest.cc » ('j') | no next file with comments »

Powered by Google App Engine
This is Rietveld 408576698