| 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/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 120 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 131 ContentSettingBubbleContents::MediaMenuParts::~MediaMenuParts() {} | 131 ContentSettingBubbleContents::MediaMenuParts::~MediaMenuParts() {} |
| 132 | 132 |
| 133 // ContentSettingBubbleContents ----------------------------------------------- | 133 // ContentSettingBubbleContents ----------------------------------------------- |
| 134 | 134 |
| 135 ContentSettingBubbleContents::ContentSettingBubbleContents( | 135 ContentSettingBubbleContents::ContentSettingBubbleContents( |
| 136 ContentSettingBubbleModel* content_setting_bubble_model, | 136 ContentSettingBubbleModel* content_setting_bubble_model, |
| 137 content::WebContents* web_contents, | 137 content::WebContents* web_contents, |
| 138 views::View* anchor_view, | 138 views::View* anchor_view, |
| 139 views::BubbleBorder::Arrow arrow) | 139 views::BubbleBorder::Arrow arrow) |
| 140 : content::WebContentsObserver(web_contents), | 140 : content::WebContentsObserver(web_contents), |
| 141 BubbleDelegateView(anchor_view, arrow), | 141 BubbleDialogDelegateView(anchor_view, arrow), |
| 142 content_setting_bubble_model_(content_setting_bubble_model), | 142 content_setting_bubble_model_(content_setting_bubble_model), |
| 143 custom_link_(NULL), | 143 custom_link_(NULL), |
| 144 manage_link_(NULL), | 144 manage_link_(NULL), |
| 145 learn_more_link_(NULL), | 145 learn_more_link_(NULL), |
| 146 close_button_(NULL) { | 146 close_button_(NULL) { |
| 147 // Compensate for built-in vertical padding in the anchor view's image. | 147 // Compensate for built-in vertical padding in the anchor view's image. |
| 148 set_anchor_view_insets(gfx::Insets( | 148 set_anchor_view_insets(gfx::Insets( |
| 149 GetLayoutConstant(LOCATION_BAR_BUBBLE_ANCHOR_VERTICAL_INSET), 0)); | 149 GetLayoutConstant(LOCATION_BAR_BUBBLE_ANCHOR_VERTICAL_INSET), 0)); |
| 150 } | 150 } |
| 151 | 151 |
| (...skipping 214 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 366 new views::Link(base::UTF8ToUTF16(bubble_content.custom_link)); | 366 new views::Link(base::UTF8ToUTF16(bubble_content.custom_link)); |
| 367 custom_link_->SetEnabled(bubble_content.custom_link_enabled); | 367 custom_link_->SetEnabled(bubble_content.custom_link_enabled); |
| 368 custom_link_->set_listener(this); | 368 custom_link_->set_listener(this); |
| 369 if (!bubble_content_empty) | 369 if (!bubble_content_empty) |
| 370 layout->AddPaddingRow(0, views::kRelatedControlVerticalSpacing); | 370 layout->AddPaddingRow(0, views::kRelatedControlVerticalSpacing); |
| 371 layout->StartRow(0, kSingleColumnSetId); | 371 layout->StartRow(0, kSingleColumnSetId); |
| 372 layout->AddView(custom_link_); | 372 layout->AddView(custom_link_); |
| 373 bubble_content_empty = false; | 373 bubble_content_empty = false; |
| 374 } | 374 } |
| 375 | 375 |
| 376 const int kDoubleColumnSetId = 1; | |
| 377 views::ColumnSet* double_column_set = | |
| 378 layout->AddColumnSet(kDoubleColumnSetId); | |
| 379 if (!bubble_content_empty) { | 376 if (!bubble_content_empty) { |
| 380 layout->AddPaddingRow(0, views::kRelatedControlVerticalSpacing); | 377 layout->AddPaddingRow(0, views::kRelatedControlVerticalSpacing); |
| 381 layout->StartRow(0, kSingleColumnSetId); | 378 layout->StartRow(0, kSingleColumnSetId); |
| 382 layout->AddView(new views::Separator(views::Separator::HORIZONTAL), 1, 1, | 379 layout->AddView(new views::Separator(views::Separator::HORIZONTAL), 1, 1, |
| 383 GridLayout::FILL, GridLayout::FILL); | 380 GridLayout::FILL, GridLayout::FILL); |
| 384 layout->AddPaddingRow(0, views::kRelatedControlVerticalSpacing); | 381 layout->AddPaddingRow(0, views::kRelatedControlVerticalSpacing); |
| 385 } | 382 } |
| 383 } |
| 386 | 384 |
| 387 double_column_set->AddColumn(GridLayout::LEADING, GridLayout::CENTER, 1, | 385 views::View* ContentSettingBubbleContents::CreateExtraView() { |
| 388 GridLayout::USE_PREF, 0, 0); | 386 manage_link_ = new views::Link(base::UTF8ToUTF16( |
| 389 double_column_set->AddPaddingColumn( | 387 content_setting_bubble_model_->bubble_content().manage_link)); |
| 390 0, views::kUnrelatedControlHorizontalSpacing); | 388 manage_link_->set_listener(this); |
| 391 double_column_set->AddColumn(GridLayout::TRAILING, GridLayout::CENTER, 0, | 389 return manage_link_; |
| 392 GridLayout::USE_PREF, 0, 0); | 390 } |
| 393 | 391 |
| 394 layout->StartRow(0, kDoubleColumnSetId); | 392 int ContentSettingBubbleContents::GetDialogButtons() const { |
| 395 manage_link_ = | 393 return ui::DIALOG_BUTTON_OK; |
| 396 new views::Link(base::UTF8ToUTF16(bubble_content.manage_link)); | 394 } |
| 397 manage_link_->set_listener(this); | |
| 398 layout->AddView(manage_link_); | |
| 399 | 395 |
| 400 close_button_ = | 396 base::string16 ContentSettingBubbleContents::GetDialogButtonLabel( |
| 401 new views::LabelButton(this, l10n_util::GetStringUTF16(IDS_DONE)); | 397 ui::DialogButton button) const { |
| 402 close_button_->SetStyle(views::Button::STYLE_BUTTON); | 398 return l10n_util::GetStringUTF16(IDS_DONE); |
| 403 layout->AddView(close_button_); | |
| 404 } | 399 } |
| 405 | 400 |
| 406 void ContentSettingBubbleContents::DidNavigateMainFrame( | 401 void ContentSettingBubbleContents::DidNavigateMainFrame( |
| 407 const content::LoadCommittedDetails& details, | 402 const content::LoadCommittedDetails& details, |
| 408 const content::FrameNavigateParams& params) { | 403 const content::FrameNavigateParams& params) { |
| 409 // Content settings are based on the main frame, so if it switches then | 404 // Content settings are based on the main frame, so if it switches then |
| 410 // close up shop. | 405 // close up shop. |
| 411 content_setting_bubble_model_->OnDoneClicked(); | 406 content_setting_bubble_model_->OnDoneClicked(); |
| 412 GetWidget()->Close(); | 407 GetWidget()->Close(); |
| 413 } | 408 } |
| (...skipping 79 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 493 // Make sure the width is at least kMinMediaMenuButtonWidth. The | 488 // Make sure the width is at least kMinMediaMenuButtonWidth. The |
| 494 // maximum width will be clamped by kMaxContentsWidth of the view. | 489 // maximum width will be clamped by kMaxContentsWidth of the view. |
| 495 menu_width = std::max(kMinMediaMenuButtonWidth, menu_width + margins); | 490 menu_width = std::max(kMinMediaMenuButtonWidth, menu_width + margins); |
| 496 | 491 |
| 497 for (MediaMenuPartsMap::const_iterator i = media_menus_.begin(); | 492 for (MediaMenuPartsMap::const_iterator i = media_menus_.begin(); |
| 498 i != media_menus_.end(); ++i) { | 493 i != media_menus_.end(); ++i) { |
| 499 i->first->SetMinSize(gfx::Size(menu_width, 0)); | 494 i->first->SetMinSize(gfx::Size(menu_width, 0)); |
| 500 i->first->SetMaxSize(gfx::Size(menu_width, 0)); | 495 i->first->SetMaxSize(gfx::Size(menu_width, 0)); |
| 501 } | 496 } |
| 502 } | 497 } |
| OLD | NEW |