| 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/geolocation/geolocation_confirm_infobar_delegate.h" | 5 #include "chrome/browser/geolocation/geolocation_confirm_infobar_delegate.h" |
| 6 | 6 |
| 7 #include "chrome/browser/geolocation/geolocation_infobar_queue_controller.h" | 7 #include "chrome/browser/geolocation/geolocation_infobar_queue_controller.h" |
| 8 #include "chrome/browser/google/google_util.h" | 8 #include "chrome/browser/google/google_util.h" |
| 9 #include "chrome/browser/infobars/infobar_tab_helper.h" | 9 #include "chrome/browser/infobars/infobar_tab_helper.h" |
| 10 #include "content/public/browser/navigation_details.h" | 10 #include "content/public/browser/navigation_details.h" |
| 11 #include "content/public/browser/navigation_entry.h" | 11 #include "content/public/browser/navigation_entry.h" |
| 12 #include "grit/generated_resources.h" | 12 #include "grit/generated_resources.h" |
| 13 #include "grit/locale_settings.h" | 13 #include "grit/locale_settings.h" |
| 14 #include "grit/theme_resources.h" | 14 #include "grit/theme_resources.h" |
| 15 #include "net/base/net_util.h" | 15 #include "net/base/net_util.h" |
| 16 #include "ui/base/l10n/l10n_util.h" | 16 #include "ui/base/l10n/l10n_util.h" |
| 17 #include "ui/base/resource/resource_bundle.h" | 17 #include "ui/base/resource/resource_bundle.h" |
| 18 | 18 |
| 19 // GeolocationConfirmInfoBarDelegate ------------------------------------------ | |
| 20 | 19 |
| 21 GeolocationConfirmInfoBarDelegate::GeolocationConfirmInfoBarDelegate( | 20 GeolocationConfirmInfoBarDelegate::GeolocationConfirmInfoBarDelegate( |
| 22 InfoBarTabHelper* infobar_helper, | 21 InfoBarTabHelper* infobar_helper, |
| 23 GeolocationInfoBarQueueController* controller, | 22 GeolocationInfoBarQueueController* controller, |
| 24 int render_process_id, | 23 const content::GeolocationPermissionRequestID& id, |
| 25 int render_view_id, | |
| 26 int bridge_id, | |
| 27 const GURL& requesting_frame_url, | 24 const GURL& requesting_frame_url, |
| 28 const std::string& display_languages) | 25 const std::string& display_languages) |
| 29 : ConfirmInfoBarDelegate(infobar_helper), | 26 : ConfirmInfoBarDelegate(infobar_helper), |
| 30 controller_(controller), | 27 controller_(controller), |
| 31 render_process_id_(render_process_id), | 28 id_(id), |
| 32 render_view_id_(render_view_id), | |
| 33 bridge_id_(bridge_id), | |
| 34 requesting_frame_url_(requesting_frame_url), | 29 requesting_frame_url_(requesting_frame_url), |
| 35 display_languages_(display_languages) { | 30 display_languages_(display_languages) { |
| 36 const content::NavigationEntry* committed_entry = | 31 const content::NavigationEntry* committed_entry = |
| 37 infobar_helper->GetWebContents()->GetController().GetLastCommittedEntry(); | 32 infobar_helper->GetWebContents()->GetController().GetLastCommittedEntry(); |
| 38 set_contents_unique_id(committed_entry ? committed_entry->GetUniqueID() : 0); | 33 set_contents_unique_id(committed_entry ? committed_entry->GetUniqueID() : 0); |
| 39 } | 34 } |
| 40 | 35 |
| 41 gfx::Image* GeolocationConfirmInfoBarDelegate::GetIcon() const { | 36 gfx::Image* GeolocationConfirmInfoBarDelegate::GetIcon() const { |
| 42 return &ResourceBundle::GetSharedInstance().GetNativeImageNamed( | 37 return &ResourceBundle::GetSharedInstance().GetNativeImageNamed( |
| 43 IDR_GEOLOCATION_INFOBAR_ICON); | 38 IDR_GEOLOCATION_INFOBAR_ICON); |
| (...skipping 10 matching lines...) Expand all Loading... |
| 54 } | 49 } |
| 55 | 50 |
| 56 string16 GeolocationConfirmInfoBarDelegate::GetButtonLabel( | 51 string16 GeolocationConfirmInfoBarDelegate::GetButtonLabel( |
| 57 InfoBarButton button) const { | 52 InfoBarButton button) const { |
| 58 return l10n_util::GetStringUTF16((button == BUTTON_OK) ? | 53 return l10n_util::GetStringUTF16((button == BUTTON_OK) ? |
| 59 IDS_GEOLOCATION_ALLOW_BUTTON : IDS_GEOLOCATION_DENY_BUTTON); | 54 IDS_GEOLOCATION_ALLOW_BUTTON : IDS_GEOLOCATION_DENY_BUTTON); |
| 60 } | 55 } |
| 61 | 56 |
| 62 void GeolocationConfirmInfoBarDelegate::SetPermission( | 57 void GeolocationConfirmInfoBarDelegate::SetPermission( |
| 63 bool update_content_setting, bool allowed) { | 58 bool update_content_setting, bool allowed) { |
| 64 controller_->OnPermissionSet( | 59 controller_->OnPermissionSet(id_, requesting_frame_url_, |
| 65 render_process_id_, render_view_id_, bridge_id_, | 60 owner()->GetWebContents()->GetURL(), |
| 66 requesting_frame_url_, | 61 update_content_setting, allowed); |
| 67 owner()->GetWebContents()->GetURL(), | |
| 68 update_content_setting, | |
| 69 allowed); | |
| 70 } | 62 } |
| 71 | 63 |
| 72 bool GeolocationConfirmInfoBarDelegate::Accept() { | 64 bool GeolocationConfirmInfoBarDelegate::Accept() { |
| 73 SetPermission(true, true); | 65 SetPermission(true, true); |
| 74 return true; | 66 return true; |
| 75 } | 67 } |
| 76 | 68 |
| 77 bool GeolocationConfirmInfoBarDelegate::Cancel() { | 69 bool GeolocationConfirmInfoBarDelegate::Cancel() { |
| 78 SetPermission(true, false); | 70 SetPermission(true, false); |
| 79 return true; | 71 return true; |
| (...skipping 13 matching lines...) Expand all Loading... |
| 93 #endif | 85 #endif |
| 94 | 86 |
| 95 content::OpenURLParams params( | 87 content::OpenURLParams params( |
| 96 google_util::AppendGoogleLocaleParam(GURL(kGeolocationLearnMoreUrl)), | 88 google_util::AppendGoogleLocaleParam(GURL(kGeolocationLearnMoreUrl)), |
| 97 content::Referrer(), | 89 content::Referrer(), |
| 98 (disposition == CURRENT_TAB) ? NEW_FOREGROUND_TAB : disposition, | 90 (disposition == CURRENT_TAB) ? NEW_FOREGROUND_TAB : disposition, |
| 99 content::PAGE_TRANSITION_LINK, false); | 91 content::PAGE_TRANSITION_LINK, false); |
| 100 owner()->GetWebContents()->OpenURL(params); | 92 owner()->GetWebContents()->OpenURL(params); |
| 101 return false; // Do not dismiss the info bar. | 93 return false; // Do not dismiss the info bar. |
| 102 } | 94 } |
| OLD | NEW |