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

Side by Side Diff: chrome/browser/ui/views/content_setting_bubble_contents.cc

Issue 2339783003: Make 'Load full site' a button instead of link. (Closed)
Patch Set: adressed comments Created 4 years, 3 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
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/ui/views/content_setting_bubble_contents.h" 5 #include "chrome/browser/ui/views/content_setting_bubble_contents.h"
6 6
7 #include <algorithm> 7 #include <algorithm>
8 #include <set> 8 #include <set>
9 #include <string> 9 #include <string>
10 #include <vector> 10 #include <vector>
(...skipping 11 matching lines...) Expand all
22 #include "components/content_settings/core/browser/host_content_settings_map.h" 22 #include "components/content_settings/core/browser/host_content_settings_map.h"
23 #include "components/strings/grit/components_strings.h" 23 #include "components/strings/grit/components_strings.h"
24 #include "content/public/browser/plugin_service.h" 24 #include "content/public/browser/plugin_service.h"
25 #include "content/public/browser/web_contents.h" 25 #include "content/public/browser/web_contents.h"
26 #include "ui/base/cursor/cursor.h" 26 #include "ui/base/cursor/cursor.h"
27 #include "ui/base/l10n/l10n_util.h" 27 #include "ui/base/l10n/l10n_util.h"
28 #include "ui/base/models/simple_menu_model.h" 28 #include "ui/base/models/simple_menu_model.h"
29 #include "ui/base/resource/resource_bundle.h" 29 #include "ui/base/resource/resource_bundle.h"
30 #include "ui/gfx/font_list.h" 30 #include "ui/gfx/font_list.h"
31 #include "ui/gfx/text_utils.h" 31 #include "ui/gfx/text_utils.h"
32 #include "ui/views/controls/button/md_text_button.h"
32 #include "ui/views/controls/button/menu_button.h" 33 #include "ui/views/controls/button/menu_button.h"
33 #include "ui/views/controls/button/radio_button.h" 34 #include "ui/views/controls/button/radio_button.h"
34 #include "ui/views/controls/combobox/combobox.h" 35 #include "ui/views/controls/combobox/combobox.h"
35 #include "ui/views/controls/image_view.h" 36 #include "ui/views/controls/image_view.h"
36 #include "ui/views/controls/label.h" 37 #include "ui/views/controls/label.h"
37 #include "ui/views/controls/link.h" 38 #include "ui/views/controls/link.h"
38 #include "ui/views/controls/menu/menu_config.h" 39 #include "ui/views/controls/menu/menu_config.h"
39 #include "ui/views/controls/menu/menu_runner.h" 40 #include "ui/views/controls/menu/menu_runner.h"
40 #include "ui/views/controls/separator.h" 41 #include "ui/views/controls/separator.h"
41 #include "ui/views/layout/grid_layout.h" 42 #include "ui/views/layout/grid_layout.h"
(...skipping 110 matching lines...) Expand 10 before | Expand all | Expand 10 after
152 // ContentSettingBubbleContents ----------------------------------------------- 153 // ContentSettingBubbleContents -----------------------------------------------
153 154
154 ContentSettingBubbleContents::ContentSettingBubbleContents( 155 ContentSettingBubbleContents::ContentSettingBubbleContents(
155 ContentSettingBubbleModel* content_setting_bubble_model, 156 ContentSettingBubbleModel* content_setting_bubble_model,
156 content::WebContents* web_contents, 157 content::WebContents* web_contents,
157 views::View* anchor_view, 158 views::View* anchor_view,
158 views::BubbleBorder::Arrow arrow) 159 views::BubbleBorder::Arrow arrow)
159 : content::WebContentsObserver(web_contents), 160 : content::WebContentsObserver(web_contents),
160 BubbleDialogDelegateView(anchor_view, arrow), 161 BubbleDialogDelegateView(anchor_view, arrow),
161 content_setting_bubble_model_(content_setting_bubble_model), 162 content_setting_bubble_model_(content_setting_bubble_model),
162 custom_link_(NULL), 163 custom_link_(nullptr),
163 manage_link_(NULL), 164 manage_link_(nullptr),
164 learn_more_link_(NULL) { 165 manage_button_(nullptr),
166 learn_more_link_(nullptr) {
165 // Compensate for built-in vertical padding in the anchor view's image. 167 // Compensate for built-in vertical padding in the anchor view's image.
166 set_anchor_view_insets(gfx::Insets( 168 set_anchor_view_insets(gfx::Insets(
167 GetLayoutConstant(LOCATION_BAR_BUBBLE_ANCHOR_VERTICAL_INSET), 0)); 169 GetLayoutConstant(LOCATION_BAR_BUBBLE_ANCHOR_VERTICAL_INSET), 0));
168 } 170 }
169 171
170 ContentSettingBubbleContents::~ContentSettingBubbleContents() { 172 ContentSettingBubbleContents::~ContentSettingBubbleContents() {
171 // Must remove the children here so the comboboxes get destroyed before 173 // Must remove the children here so the comboboxes get destroyed before
172 // their associated models. 174 // their associated models.
173 RemoveAllChildViews(true); 175 RemoveAllChildViews(true);
174 } 176 }
(...skipping 199 matching lines...) Expand 10 before | Expand all | Expand 10 after
374 if (!bubble_content_empty) { 376 if (!bubble_content_empty) {
375 layout->AddPaddingRow(0, views::kRelatedControlVerticalSpacing); 377 layout->AddPaddingRow(0, views::kRelatedControlVerticalSpacing);
376 layout->StartRow(0, kSingleColumnSetId); 378 layout->StartRow(0, kSingleColumnSetId);
377 layout->AddView(new views::Separator(views::Separator::HORIZONTAL), 1, 1, 379 layout->AddView(new views::Separator(views::Separator::HORIZONTAL), 1, 1,
378 GridLayout::FILL, GridLayout::FILL); 380 GridLayout::FILL, GridLayout::FILL);
379 layout->AddPaddingRow(0, views::kRelatedControlVerticalSpacing); 381 layout->AddPaddingRow(0, views::kRelatedControlVerticalSpacing);
380 } 382 }
381 } 383 }
382 384
383 views::View* ContentSettingBubbleContents::CreateExtraView() { 385 views::View* ContentSettingBubbleContents::CreateExtraView() {
384 manage_link_ = new views::Link(base::UTF8ToUTF16( 386 if (content_setting_bubble_model_->bubble_content().manage_text_as_button) {
385 content_setting_bubble_model_->bubble_content().manage_link)); 387 manage_button_ = views::MdTextButton::CreateSecondaryUiButton(
msw 2016/09/14 19:50:24 nit: remove extra space after '='; use "git cl for
melandory 2016/09/14 20:27:57 Done.
386 manage_link_->set_listener(this); 388 this, base::UTF8ToUTF16(
387 return manage_link_; 389 content_setting_bubble_model_->bubble_content().manage_text));
390 return manage_button_;
391 } else {
392 manage_link_ = new views::Link(base::UTF8ToUTF16(
393 content_setting_bubble_model_->bubble_content().manage_text));
394 manage_link_->set_listener(this);
395 return manage_link_;
396 }
388 } 397 }
389 398
390 bool ContentSettingBubbleContents::Accept() { 399 bool ContentSettingBubbleContents::Accept() {
391 content_setting_bubble_model_->OnDoneClicked(); 400 content_setting_bubble_model_->OnDoneClicked();
392 return true; 401 return true;
393 } 402 }
394 403
395 bool ContentSettingBubbleContents::Close() { 404 bool ContentSettingBubbleContents::Close() {
396 return true; 405 return true;
397 } 406 }
(...skipping 10 matching lines...) Expand all
408 void ContentSettingBubbleContents::DidNavigateMainFrame( 417 void ContentSettingBubbleContents::DidNavigateMainFrame(
409 const content::LoadCommittedDetails& details, 418 const content::LoadCommittedDetails& details,
410 const content::FrameNavigateParams& params) { 419 const content::FrameNavigateParams& params) {
411 // Content settings are based on the main frame, so if it switches then 420 // Content settings are based on the main frame, so if it switches then
412 // close up shop. 421 // close up shop.
413 GetWidget()->Close(); 422 GetWidget()->Close();
414 } 423 }
415 424
416 void ContentSettingBubbleContents::ButtonPressed(views::Button* sender, 425 void ContentSettingBubbleContents::ButtonPressed(views::Button* sender,
417 const ui::Event& event) { 426 const ui::Event& event) {
418 RadioGroup::const_iterator i( 427 if (manage_button_ == sender) {
419 std::find(radio_group_.begin(), radio_group_.end(), sender)); 428 GetWidget()->Close();
420 DCHECK(i != radio_group_.end()); 429 content_setting_bubble_model_->OnManageLinkClicked();
421 content_setting_bubble_model_->OnRadioClicked(i - radio_group_.begin()); 430 } else {
431 RadioGroup::const_iterator i(
432 std::find(radio_group_.begin(), radio_group_.end(), sender));
433 DCHECK(i != radio_group_.end());
434 content_setting_bubble_model_->OnRadioClicked(i - radio_group_.begin());
435 }
422 } 436 }
423 437
424 void ContentSettingBubbleContents::LinkClicked(views::Link* source, 438 void ContentSettingBubbleContents::LinkClicked(views::Link* source,
425 int event_flags) { 439 int event_flags) {
426 if (source == learn_more_link_) { 440 if (source == learn_more_link_) {
427 content_setting_bubble_model_->OnLearnMoreLinkClicked(); 441 content_setting_bubble_model_->OnLearnMoreLinkClicked();
428 GetWidget()->Close(); 442 GetWidget()->Close();
429 return; 443 return;
430 } 444 }
431 if (source == custom_link_) { 445 if (source == custom_link_) {
(...skipping 13 matching lines...) Expand all
445 DCHECK(i != list_item_links_.end()); 459 DCHECK(i != list_item_links_.end());
446 content_setting_bubble_model_->OnListItemClicked(i->second); 460 content_setting_bubble_model_->OnListItemClicked(i->second);
447 } 461 }
448 462
449 void ContentSettingBubbleContents::OnPerformAction(views::Combobox* combobox) { 463 void ContentSettingBubbleContents::OnPerformAction(views::Combobox* combobox) {
450 MediaComboboxModel* model = 464 MediaComboboxModel* model =
451 static_cast<MediaComboboxModel*>(combobox->model()); 465 static_cast<MediaComboboxModel*>(combobox->model());
452 content_setting_bubble_model_->OnMediaMenuClicked( 466 content_setting_bubble_model_->OnMediaMenuClicked(
453 model->type(), model->GetDevices()[combobox->selected_index()].id); 467 model->type(), model->GetDevices()[combobox->selected_index()].id);
454 } 468 }
OLDNEW

Powered by Google App Engine
This is Rietveld 408576698