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

Side by Side Diff: chrome/browser/ui/views/website_settings/permissions_bubble_view.cc

Issue 176053002: [WebsiteSettings] Change permission bubble API to adapt to new mocks. (Closed) Base URL: svn://svn.chromium.org/chrome/trunk/src
Patch Set: Created 6 years, 10 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 2014 The Chromium Authors. All rights reserved. 1 // Copyright 2014 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/ui/views/website_settings/permissions_bubble_view.h" 5 #include "chrome/browser/ui/views/website_settings/permissions_bubble_view.h"
6 6
7 #include "base/strings/utf_string_conversions.h" 7 #include "base/strings/utf_string_conversions.h"
8 #include "chrome/browser/ui/website_settings/permission_bubble_request.h" 8 #include "chrome/browser/ui/website_settings/permission_bubble_request.h"
9 #include "grit/generated_resources.h" 9 #include "grit/generated_resources.h"
10 #include "ui/base/l10n/l10n_util.h" 10 #include "ui/base/l10n/l10n_util.h"
(...skipping 140 matching lines...) Expand 10 before | Expand all | Expand 10 after
151 l10n_util::GetStringUTF16(IDS_PERMISSION_CUSTOMIZE)); 151 l10n_util::GetStringUTF16(IDS_PERMISSION_CUSTOMIZE));
152 customize->SetStyle(views::Button::STYLE_TEXTBUTTON); 152 customize->SetStyle(views::Button::STYLE_TEXTBUTTON);
153 customize->SetTextColor(views::Button::STATE_NORMAL, SK_ColorBLUE); 153 customize->SetTextColor(views::Button::STATE_NORMAL, SK_ColorBLUE);
154 customize->SetTextColor(views::Button::STATE_HOVERED, SK_ColorBLUE); 154 customize->SetTextColor(views::Button::STATE_HOVERED, SK_ColorBLUE);
155 customize->SetTextColor(views::Button::STATE_PRESSED, SK_ColorBLUE); 155 customize->SetTextColor(views::Button::STATE_PRESSED, SK_ColorBLUE);
156 button_layout->AddView(customize); 156 button_layout->AddView(customize);
157 } else { 157 } else {
158 button_layout->AddView(new views::View()); 158 button_layout->AddView(new views::View());
159 } 159 }
160 160
161 // Lay out the Deny/Allow buttons. Use custom text if there is only 161 // Lay out the Deny/Allow buttons.
162 // one permission request. 162 base::string16 deny_text = l10n_util::GetStringUTF16(IDS_PERMISSION_DENY);
163 base::string16 deny_text;
164 base::string16 allow_text;
165 if (requests.size() == 1) {
166 deny_text = requests[0]->GetAlternateDenyButtonText();
167 allow_text = requests[0]->GetAlternateAcceptButtonText();
168 }
169
170 if (deny_text.empty())
171 deny_text = l10n_util::GetStringUTF16(IDS_PERMISSION_DENY);
172 if (allow_text.empty())
173 allow_text = l10n_util::GetStringUTF16(IDS_PERMISSION_ALLOW);
174
175 views::LabelButton* deny_button = new views::LabelButton(this, deny_text); 163 views::LabelButton* deny_button = new views::LabelButton(this, deny_text);
176 deny_button->SetStyle(views::Button::STYLE_BUTTON); 164 deny_button->SetStyle(views::Button::STYLE_BUTTON);
177 deny_button->SetFontList(rb.GetFontList(ui::ResourceBundle::MediumFont)); 165 deny_button->SetFontList(rb.GetFontList(ui::ResourceBundle::MediumFont));
178 button_layout->AddView(deny_button); 166 button_layout->AddView(deny_button);
179 deny_ = deny_button; 167 deny_ = deny_button;
180 168
169 base::string16 allow_text = l10n_util::GetStringUTF16(IDS_PERMISSION_ALLOW);
181 views::LabelButton* allow_button = new views::LabelButton(this, allow_text); 170 views::LabelButton* allow_button = new views::LabelButton(this, allow_text);
182 allow_button->SetStyle(views::Button::STYLE_BUTTON); 171 allow_button->SetStyle(views::Button::STYLE_BUTTON);
183 allow_button->SetFontList(rb.GetFontList(ui::ResourceBundle::MediumFont)); 172 allow_button->SetFontList(rb.GetFontList(ui::ResourceBundle::MediumFont));
184 button_layout->AddView(allow_button); 173 button_layout->AddView(allow_button);
185 allow_ = allow_button; 174 allow_ = allow_button;
186 175
187 button_layout->AddPaddingRow(0, kBubbleOuterMargin); 176 button_layout->AddPaddingRow(0, kBubbleOuterMargin);
188 } 177 }
189 178
190 PermissionsBubbleDelegateView::~PermissionsBubbleDelegateView() { 179 PermissionsBubbleDelegateView::~PermissionsBubbleDelegateView() {
(...skipping 71 matching lines...) Expand 10 before | Expand all | Expand 10 after
262 PermissionsBubbleDelegateView* bubble_delegate = 251 PermissionsBubbleDelegateView* bubble_delegate =
263 new PermissionsBubbleDelegateView(anchor_view_, this, 252 new PermissionsBubbleDelegateView(anchor_view_, this,
264 requests, values, customization_mode); 253 requests, values, customization_mode);
265 bubble_delegate_ = bubble_delegate; 254 bubble_delegate_ = bubble_delegate;
266 views::BubbleDelegateView::CreateBubble(bubble_delegate_); 255 views::BubbleDelegateView::CreateBubble(bubble_delegate_);
267 256
268 bubble_delegate_->StartFade(true); 257 bubble_delegate_->StartFade(true);
269 bubble_delegate->SizeToContents(); 258 bubble_delegate->SizeToContents();
270 } 259 }
271 260
261 bool PermissionBubbleViewViews::CanAcceptRequestUpdate() {
262 // TODO(gbillock): support this.
263 // return bubble_delegate_ && bubble_delegate_->IsMouseHovered();
264 return false;
265 }
266
272 void PermissionBubbleViewViews::Hide() { 267 void PermissionBubbleViewViews::Hide() {
273 if (bubble_delegate_) { 268 if (bubble_delegate_) {
274 bubble_delegate_->Close(); 269 bubble_delegate_->Close();
275 bubble_delegate_ = NULL; 270 bubble_delegate_ = NULL;
276 } 271 }
277 } 272 }
278 273
279 void PermissionBubbleViewViews::Closing() { 274 void PermissionBubbleViewViews::Closing() {
280 if (bubble_delegate_) 275 if (bubble_delegate_)
281 bubble_delegate_ = NULL; 276 bubble_delegate_ = NULL;
(...skipping 13 matching lines...) Expand all
295 290
296 void PermissionBubbleViewViews::Deny() { 291 void PermissionBubbleViewViews::Deny() {
297 if (delegate_) 292 if (delegate_)
298 delegate_->Deny(); 293 delegate_->Deny();
299 } 294 }
300 295
301 void PermissionBubbleViewViews::SetCustomizationMode() { 296 void PermissionBubbleViewViews::SetCustomizationMode() {
302 if (delegate_) 297 if (delegate_)
303 delegate_->SetCustomizationMode(); 298 delegate_->SetCustomizationMode();
304 } 299 }
OLDNEW

Powered by Google App Engine
This is Rietveld 408576698