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

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

Issue 11183018: Refactor ChromeGeolocationPermissionContext (Closed) Base URL: svn://svn.chromium.org/chrome/trunk/src
Patch Set: Fixing unit tests Created 8 years, 2 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
(Empty)
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
3 // found in the LICENSE file.
4
5 #include "chrome/browser/geolocation/geolocation_confirm_infobar_delegate.h"
6
7 #include "chrome/browser/geolocation/geolocation_infobar_queue_controller.h"
8 #include "chrome/browser/google/google_util.h"
9 #include "chrome/browser/infobars/infobar_tab_helper.h"
10 #include "content/public/browser/navigation_details.h"
11 #include "content/public/browser/navigation_entry.h"
12 #include "grit/generated_resources.h"
13 #include "grit/locale_settings.h"
14 #include "grit/theme_resources.h"
15 #include "net/base/net_util.h"
16 #include "ui/base/l10n/l10n_util.h"
17 #include "ui/base/resource/resource_bundle.h"
18
19 // GeolocationConfirmInfoBarDelegate ------------------------------------------
20
21 GeolocationConfirmInfoBarDelegate::GeolocationConfirmInfoBarDelegate(
22 InfoBarTabHelper* infobar_helper,
23 GeolocationInfoBarQueueController* controller,
24 int render_process_id,
25 int render_view_id,
26 int bridge_id,
27 const GURL& requesting_frame_url,
28 const std::string& display_languages)
29 : ConfirmInfoBarDelegate(infobar_helper),
30 controller_(controller),
31 render_process_id_(render_process_id),
32 render_view_id_(render_view_id),
33 bridge_id_(bridge_id),
34 requesting_frame_url_(requesting_frame_url),
35 display_languages_(display_languages) {
36 const content::NavigationEntry* committed_entry =
37 infobar_helper->GetWebContents()->GetController().GetLastCommittedEntry();
38 set_contents_unique_id(committed_entry ? committed_entry->GetUniqueID() : 0);
39 }
40
41 gfx::Image* GeolocationConfirmInfoBarDelegate::GetIcon() const {
42 return &ResourceBundle::GetSharedInstance().GetNativeImageNamed(
43 IDR_GEOLOCATION_INFOBAR_ICON);
44 }
45
46 InfoBarDelegate::Type
47 GeolocationConfirmInfoBarDelegate::GetInfoBarType() const {
48 return PAGE_ACTION_TYPE;
49 }
50
51 string16 GeolocationConfirmInfoBarDelegate::GetMessageText() const {
52 return l10n_util::GetStringFUTF16(IDS_GEOLOCATION_INFOBAR_QUESTION,
53 net::FormatUrl(requesting_frame_url_.GetOrigin(), display_languages_));
54 }
55
56 string16 GeolocationConfirmInfoBarDelegate::GetButtonLabel(
57 InfoBarButton button) const {
58 return l10n_util::GetStringUTF16((button == BUTTON_OK) ?
59 IDS_GEOLOCATION_ALLOW_BUTTON : IDS_GEOLOCATION_DENY_BUTTON);
60 }
61
62 void GeolocationConfirmInfoBarDelegate::SetPermission(
63 bool update_content_setting, bool allowed) {
64 controller_->OnPermissionSet(
65 render_process_id_, render_view_id_, bridge_id_,
66 requesting_frame_url_,
67 owner()->GetWebContents()->GetURL(),
68 update_content_setting,
69 allowed);
70 }
71
72 bool GeolocationConfirmInfoBarDelegate::Accept() {
73 SetPermission(true, true);
74 return true;
75 }
76
77 bool GeolocationConfirmInfoBarDelegate::Cancel() {
78 SetPermission(true, false);
79 return true;
80 }
81
82 string16 GeolocationConfirmInfoBarDelegate::GetLinkText() const {
83 return l10n_util::GetStringUTF16(IDS_LEARN_MORE);
84 }
85
86 bool GeolocationConfirmInfoBarDelegate::LinkClicked(
87 WindowOpenDisposition disposition) {
88 const char kGeolocationLearnMoreUrl[] =
89 #if defined(OS_CHROMEOS)
90 "https://www.google.com/support/chromeos/bin/answer.py?answer=142065";
91 #else
92 "https://www.google.com/support/chrome/bin/answer.py?answer=142065";
93 #endif
94
95 content::OpenURLParams params(
96 google_util::AppendGoogleLocaleParam(GURL(kGeolocationLearnMoreUrl)),
97 content::Referrer(),
98 (disposition == CURRENT_TAB) ? NEW_FOREGROUND_TAB : disposition,
99 content::PAGE_TRANSITION_LINK, false);
100 owner()->GetWebContents()->OpenURL(params);
101 return false; // Do not dismiss the info bar.
102 }
OLDNEW

Powered by Google App Engine
This is Rietveld 408576698