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 <vector> | 5 #include <vector> |
6 | 6 |
7 #include "base/basictypes.h" | 7 #include "base/basictypes.h" |
8 #include "base/command_line.h" | 8 #include "base/command_line.h" |
9 #include "base/compiler_specific.h" | 9 #include "base/compiler_specific.h" |
10 #include "base/i18n/rtl.h" | 10 #include "base/i18n/rtl.h" |
(...skipping 116 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
127 virtual void Layout() OVERRIDE; | 127 virtual void Layout() OVERRIDE; |
128 | 128 |
129 DISALLOW_COPY_AND_ASSIGN(CustomScrollableView); | 129 DISALLOW_COPY_AND_ASSIGN(CustomScrollableView); |
130 }; | 130 }; |
131 | 131 |
132 // Implements the extension installation dialog for TOOLKIT_VIEWS. | 132 // Implements the extension installation dialog for TOOLKIT_VIEWS. |
133 class ExtensionInstallDialogView : public views::DialogDelegateView, | 133 class ExtensionInstallDialogView : public views::DialogDelegateView, |
134 public views::LinkListener, | 134 public views::LinkListener, |
135 public views::ButtonListener { | 135 public views::ButtonListener { |
136 public: | 136 public: |
137 ExtensionInstallDialogView(content::PageNavigator* navigator, | 137 ExtensionInstallDialogView( |
138 ExtensionInstallPrompt::Delegate* delegate, | 138 content::PageNavigator* navigator, |
139 const ExtensionInstallPrompt::Prompt& prompt); | 139 ExtensionInstallPrompt::Delegate* delegate, |
| 140 scoped_refptr<ExtensionInstallPrompt::Prompt> prompt); |
140 virtual ~ExtensionInstallDialogView(); | 141 virtual ~ExtensionInstallDialogView(); |
141 | 142 |
142 // Called when one of the child elements has expanded/collapsed. | 143 // Called when one of the child elements has expanded/collapsed. |
143 void ContentsChanged(); | 144 void ContentsChanged(); |
144 | 145 |
145 private: | 146 private: |
146 // views::DialogDelegateView: | 147 // views::DialogDelegateView: |
147 virtual int GetDialogButtons() const OVERRIDE; | 148 virtual int GetDialogButtons() const OVERRIDE; |
148 virtual base::string16 GetDialogButtonLabel( | 149 virtual base::string16 GetDialogButtonLabel( |
149 ui::DialogButton button) const OVERRIDE; | 150 ui::DialogButton button) const OVERRIDE; |
(...skipping 18 matching lines...) Expand all Loading... |
168 void ToggleInlineExplanations(); | 169 void ToggleInlineExplanations(); |
169 | 170 |
170 // Creates a layout consisting of dialog header, extension name and icon. | 171 // Creates a layout consisting of dialog header, extension name and icon. |
171 views::GridLayout* CreateLayout( | 172 views::GridLayout* CreateLayout( |
172 views::View* parent, | 173 views::View* parent, |
173 int left_column_width, | 174 int left_column_width, |
174 int column_set_id, | 175 int column_set_id, |
175 bool single_detail_row) const; | 176 bool single_detail_row) const; |
176 | 177 |
177 bool is_inline_install() const { | 178 bool is_inline_install() const { |
178 return prompt_.type() == ExtensionInstallPrompt::INLINE_INSTALL_PROMPT; | 179 return prompt_->type() == ExtensionInstallPrompt::INLINE_INSTALL_PROMPT; |
179 } | 180 } |
180 | 181 |
181 bool is_bundle_install() const { | 182 bool is_bundle_install() const { |
182 return prompt_.type() == ExtensionInstallPrompt::BUNDLE_INSTALL_PROMPT; | 183 return prompt_->type() == ExtensionInstallPrompt::BUNDLE_INSTALL_PROMPT; |
183 } | 184 } |
184 | 185 |
185 bool is_external_install() const { | 186 bool is_external_install() const { |
186 return prompt_.type() == ExtensionInstallPrompt::EXTERNAL_INSTALL_PROMPT; | 187 return prompt_->type() == ExtensionInstallPrompt::EXTERNAL_INSTALL_PROMPT; |
187 } | 188 } |
188 | 189 |
189 // Updates the histogram that holds installation accepted/aborted data. | 190 // Updates the histogram that holds installation accepted/aborted data. |
190 void UpdateInstallResultHistogram(bool accepted) const; | 191 void UpdateInstallResultHistogram(bool accepted) const; |
191 | 192 |
192 // Updates the histogram that holds data about whether "Show details" or | 193 // Updates the histogram that holds data about whether "Show details" or |
193 // "Show permissions" links were shown and/or clicked. | 194 // "Show permissions" links were shown and/or clicked. |
194 void UpdateLinkActionHistogram(int action_type) const; | 195 void UpdateLinkActionHistogram(int action_type) const; |
195 | 196 |
196 content::PageNavigator* navigator_; | 197 content::PageNavigator* navigator_; |
197 ExtensionInstallPrompt::Delegate* delegate_; | 198 ExtensionInstallPrompt::Delegate* delegate_; |
198 const ExtensionInstallPrompt::Prompt& prompt_; | 199 scoped_refptr<ExtensionInstallPrompt::Prompt> prompt_; |
199 | 200 |
200 // The scroll view containing all the details for the dialog (including all | 201 // The scroll view containing all the details for the dialog (including all |
201 // collapsible/expandable sections). | 202 // collapsible/expandable sections). |
202 views::ScrollView* scroll_view_; | 203 views::ScrollView* scroll_view_; |
203 | 204 |
204 // The container view for the scroll view. | 205 // The container view for the scroll view. |
205 CustomScrollableView* scrollable_; | 206 CustomScrollableView* scrollable_; |
206 | 207 |
207 // The container for the simpler view with only the dialog header and the | 208 // The container for the simpler view with only the dialog header and the |
208 // extension icon. Used for the experiment where the permissions are | 209 // extension icon. Used for the experiment where the permissions are |
(...skipping 169 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
378 | 379 |
379 // Whether the details section is expanded. | 380 // Whether the details section is expanded. |
380 bool expanded_; | 381 bool expanded_; |
381 | 382 |
382 DISALLOW_COPY_AND_ASSIGN(ExpandableContainerView); | 383 DISALLOW_COPY_AND_ASSIGN(ExpandableContainerView); |
383 }; | 384 }; |
384 | 385 |
385 void ShowExtensionInstallDialogImpl( | 386 void ShowExtensionInstallDialogImpl( |
386 const ExtensionInstallPrompt::ShowParams& show_params, | 387 const ExtensionInstallPrompt::ShowParams& show_params, |
387 ExtensionInstallPrompt::Delegate* delegate, | 388 ExtensionInstallPrompt::Delegate* delegate, |
388 const ExtensionInstallPrompt::Prompt& prompt) { | 389 scoped_refptr<ExtensionInstallPrompt::Prompt> prompt) { |
389 DCHECK_CURRENTLY_ON(content::BrowserThread::UI); | 390 DCHECK_CURRENTLY_ON(content::BrowserThread::UI); |
390 CreateBrowserModalDialogViews( | 391 CreateBrowserModalDialogViews( |
391 new ExtensionInstallDialogView(show_params.navigator, delegate, prompt), | 392 new ExtensionInstallDialogView(show_params.navigator, delegate, prompt), |
392 show_params.parent_window)->Show(); | 393 show_params.parent_window)->Show(); |
393 } | 394 } |
394 | 395 |
395 } // namespace | 396 } // namespace |
396 | 397 |
397 CustomScrollableView::CustomScrollableView() {} | 398 CustomScrollableView::CustomScrollableView() {} |
398 CustomScrollableView::~CustomScrollableView() {} | 399 CustomScrollableView::~CustomScrollableView() {} |
399 | 400 |
400 void CustomScrollableView::Layout() { | 401 void CustomScrollableView::Layout() { |
401 SetBounds(x(), y(), width(), GetHeightForWidth(width())); | 402 SetBounds(x(), y(), width(), GetHeightForWidth(width())); |
402 views::View::Layout(); | 403 views::View::Layout(); |
403 } | 404 } |
404 | 405 |
405 ExtensionInstallDialogView::ExtensionInstallDialogView( | 406 ExtensionInstallDialogView::ExtensionInstallDialogView( |
406 content::PageNavigator* navigator, | 407 content::PageNavigator* navigator, |
407 ExtensionInstallPrompt::Delegate* delegate, | 408 ExtensionInstallPrompt::Delegate* delegate, |
408 const ExtensionInstallPrompt::Prompt& prompt) | 409 scoped_refptr<ExtensionInstallPrompt::Prompt> prompt) |
409 : navigator_(navigator), | 410 : navigator_(navigator), |
410 delegate_(delegate), | 411 delegate_(delegate), |
411 prompt_(prompt), | 412 prompt_(prompt), |
412 scroll_view_(NULL), | 413 scroll_view_(NULL), |
413 scrollable_(NULL), | 414 scrollable_(NULL), |
414 scrollable_header_only_(NULL), | 415 scrollable_header_only_(NULL), |
415 show_details_link_(NULL), | 416 show_details_link_(NULL), |
416 checkbox_info_label_(NULL), | 417 checkbox_info_label_(NULL), |
417 unchecked_boxes_(0) { | 418 unchecked_boxes_(0) { |
418 // Possible grid layouts without ExtensionPermissionDialog experiment: | 419 // Possible grid layouts without ExtensionPermissionDialog experiment: |
(...skipping 70 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
489 // +--------------------| | | 490 // +--------------------| | |
490 // |checkbox|permission1| | | 491 // |checkbox|permission1| | |
491 // +--------------------| | | 492 // +--------------------| | |
492 // |checkbox|permission2| | | 493 // |checkbox|permission2| | |
493 // +--------------------+------+ | 494 // +--------------------+------+ |
494 // | 495 // |
495 // Additionally, links or informational text is added to non-client areas of | 496 // Additionally, links or informational text is added to non-client areas of |
496 // the dialog depending on the experiment group. | 497 // the dialog depending on the experiment group. |
497 | 498 |
498 int left_column_width = | 499 int left_column_width = |
499 (prompt.ShouldShowPermissions() + | 500 (prompt->ShouldShowPermissions() + prompt->GetRetainedFileCount()) > 0 |
500 prompt.GetRetainedFileCount()) > 0 ? | 501 ? kPermissionsLeftColumnWidth |
501 kPermissionsLeftColumnWidth : kNoPermissionsLeftColumnWidth; | 502 : kNoPermissionsLeftColumnWidth; |
502 if (is_bundle_install()) | 503 if (is_bundle_install()) |
503 left_column_width = kBundleLeftColumnWidth; | 504 left_column_width = kBundleLeftColumnWidth; |
504 if (is_external_install()) | 505 if (is_external_install()) |
505 left_column_width = kExternalInstallLeftColumnWidth; | 506 left_column_width = kExternalInstallLeftColumnWidth; |
506 | 507 |
507 scroll_view_ = new views::ScrollView(); | 508 scroll_view_ = new views::ScrollView(); |
508 scroll_view_->set_hide_horizontal_scrollbar(true); | 509 scroll_view_->set_hide_horizontal_scrollbar(true); |
509 AddChildView(scroll_view_); | 510 AddChildView(scroll_view_); |
510 | 511 |
511 int column_set_id = 0; | 512 int column_set_id = 0; |
512 // Create the full scrollable view which will contain all the information | 513 // Create the full scrollable view which will contain all the information |
513 // including the permissions. | 514 // including the permissions. |
514 scrollable_ = new CustomScrollableView(); | 515 scrollable_ = new CustomScrollableView(); |
515 views::GridLayout* layout = CreateLayout( | 516 views::GridLayout* layout = CreateLayout( |
516 scrollable_, left_column_width, column_set_id, false); | 517 scrollable_, left_column_width, column_set_id, false); |
517 ui::ResourceBundle& rb = ui::ResourceBundle::GetSharedInstance(); | 518 ui::ResourceBundle& rb = ui::ResourceBundle::GetSharedInstance(); |
518 | 519 |
519 if (prompt.ShouldShowPermissions() && | 520 if (prompt->ShouldShowPermissions() && |
520 prompt.experiment()->should_show_expandable_permission_list()) { | 521 prompt->experiment()->should_show_expandable_permission_list()) { |
521 // If the experiment should hide the permission list initially, create a | 522 // If the experiment should hide the permission list initially, create a |
522 // simple layout that contains only the header, extension name and icon. | 523 // simple layout that contains only the header, extension name and icon. |
523 scrollable_header_only_ = new CustomScrollableView(); | 524 scrollable_header_only_ = new CustomScrollableView(); |
524 CreateLayout(scrollable_header_only_, left_column_width, | 525 CreateLayout(scrollable_header_only_, left_column_width, |
525 column_set_id, true); | 526 column_set_id, true); |
526 scroll_view_->SetContents(scrollable_header_only_); | 527 scroll_view_->SetContents(scrollable_header_only_); |
527 } else { | 528 } else { |
528 scroll_view_->SetContents(scrollable_); | 529 scroll_view_->SetContents(scrollable_); |
529 } | 530 } |
530 | 531 |
531 int dialog_width = left_column_width + 2 * views::kPanelHorizMargin; | 532 int dialog_width = left_column_width + 2 * views::kPanelHorizMargin; |
532 if (!is_bundle_install()) | 533 if (!is_bundle_install()) |
533 dialog_width += views::kPanelHorizMargin + kIconSize + kIconOffset; | 534 dialog_width += views::kPanelHorizMargin + kIconSize + kIconOffset; |
534 | 535 |
535 // Widen the dialog for experiment with checkboxes so that the information | 536 // Widen the dialog for experiment with checkboxes so that the information |
536 // label fits the area to the left of the buttons. | 537 // label fits the area to the left of the buttons. |
537 if (prompt.experiment()->show_checkboxes()) | 538 if (prompt->experiment()->show_checkboxes()) |
538 dialog_width += 4 * views::kPanelHorizMargin; | 539 dialog_width += 4 * views::kPanelHorizMargin; |
539 | 540 |
540 if (prompt.has_webstore_data()) { | 541 if (prompt->has_webstore_data()) { |
541 layout->StartRow(0, column_set_id); | 542 layout->StartRow(0, column_set_id); |
542 views::View* rating = new views::View(); | 543 views::View* rating = new views::View(); |
543 rating->SetLayoutManager(new views::BoxLayout( | 544 rating->SetLayoutManager(new views::BoxLayout( |
544 views::BoxLayout::kHorizontal, 0, 0, 0)); | 545 views::BoxLayout::kHorizontal, 0, 0, 0)); |
545 layout->AddView(rating); | 546 layout->AddView(rating); |
546 prompt.AppendRatingStars(AddResourceIcon, rating); | 547 prompt->AppendRatingStars(AddResourceIcon, rating); |
547 | 548 |
548 const gfx::FontList& small_font_list = | 549 const gfx::FontList& small_font_list = |
549 rb.GetFontList(ui::ResourceBundle::SmallFont); | 550 rb.GetFontList(ui::ResourceBundle::SmallFont); |
550 views::Label* rating_count = | 551 views::Label* rating_count = |
551 new views::Label(prompt.GetRatingCount(), small_font_list); | 552 new views::Label(prompt->GetRatingCount(), small_font_list); |
552 // Add some space between the stars and the rating count. | 553 // Add some space between the stars and the rating count. |
553 rating_count->SetBorder(views::Border::CreateEmptyBorder(0, 2, 0, 0)); | 554 rating_count->SetBorder(views::Border::CreateEmptyBorder(0, 2, 0, 0)); |
554 rating->AddChildView(rating_count); | 555 rating->AddChildView(rating_count); |
555 | 556 |
556 layout->StartRow(0, column_set_id); | 557 layout->StartRow(0, column_set_id); |
557 views::Label* user_count = | 558 views::Label* user_count = |
558 new views::Label(prompt.GetUserCount(), small_font_list); | 559 new views::Label(prompt->GetUserCount(), small_font_list); |
559 user_count->SetAutoColorReadabilityEnabled(false); | 560 user_count->SetAutoColorReadabilityEnabled(false); |
560 user_count->SetEnabledColor(SK_ColorGRAY); | 561 user_count->SetEnabledColor(SK_ColorGRAY); |
561 layout->AddView(user_count); | 562 layout->AddView(user_count); |
562 | 563 |
563 layout->StartRow(0, column_set_id); | 564 layout->StartRow(0, column_set_id); |
564 views::Link* store_link = new views::Link( | 565 views::Link* store_link = new views::Link( |
565 l10n_util::GetStringUTF16(IDS_EXTENSION_PROMPT_STORE_LINK)); | 566 l10n_util::GetStringUTF16(IDS_EXTENSION_PROMPT_STORE_LINK)); |
566 store_link->SetFontList(small_font_list); | 567 store_link->SetFontList(small_font_list); |
567 store_link->set_listener(this); | 568 store_link->set_listener(this); |
568 layout->AddView(store_link); | 569 layout->AddView(store_link); |
569 } | 570 } |
570 | 571 |
571 if (is_bundle_install()) { | 572 if (is_bundle_install()) { |
572 BundleInstaller::ItemList items = prompt.bundle()->GetItemsWithState( | 573 BundleInstaller::ItemList items = prompt->bundle()->GetItemsWithState( |
573 BundleInstaller::Item::STATE_PENDING); | 574 BundleInstaller::Item::STATE_PENDING); |
574 for (size_t i = 0; i < items.size(); ++i) { | 575 for (size_t i = 0; i < items.size(); ++i) { |
575 base::string16 extension_name = | 576 base::string16 extension_name = |
576 base::UTF8ToUTF16(items[i].localized_name); | 577 base::UTF8ToUTF16(items[i].localized_name); |
577 base::i18n::AdjustStringForLocaleDirection(&extension_name); | 578 base::i18n::AdjustStringForLocaleDirection(&extension_name); |
578 layout->AddPaddingRow(0, views::kRelatedControlVerticalSpacing); | 579 layout->AddPaddingRow(0, views::kRelatedControlVerticalSpacing); |
579 layout->StartRow(0, column_set_id); | 580 layout->StartRow(0, column_set_id); |
580 views::Label* extension_label = new views::Label( | 581 views::Label* extension_label = new views::Label( |
581 PrepareForDisplay(extension_name, true)); | 582 PrepareForDisplay(extension_name, true)); |
582 extension_label->SetMultiLine(true); | 583 extension_label->SetMultiLine(true); |
583 extension_label->SetHorizontalAlignment(gfx::ALIGN_LEFT); | 584 extension_label->SetHorizontalAlignment(gfx::ALIGN_LEFT); |
584 extension_label->SizeToFit(left_column_width); | 585 extension_label->SizeToFit(left_column_width); |
585 layout->AddView(extension_label); | 586 layout->AddView(extension_label); |
586 } | 587 } |
587 } | 588 } |
588 | 589 |
589 if (prompt.ShouldShowPermissions()) { | 590 if (prompt->ShouldShowPermissions()) { |
590 layout->AddPaddingRow(0, views::kRelatedControlVerticalSpacing); | 591 layout->AddPaddingRow(0, views::kRelatedControlVerticalSpacing); |
591 | 592 |
592 if (prompt.GetPermissionCount() > 0) { | 593 if (prompt->GetPermissionCount() > 0) { |
593 if (is_inline_install()) { | 594 if (is_inline_install()) { |
594 layout->StartRow(0, column_set_id); | 595 layout->StartRow(0, column_set_id); |
595 layout->AddView(new views::Separator(views::Separator::HORIZONTAL), | 596 layout->AddView(new views::Separator(views::Separator::HORIZONTAL), |
596 3, 1, views::GridLayout::FILL, views::GridLayout::FILL); | 597 3, 1, views::GridLayout::FILL, views::GridLayout::FILL); |
597 layout->AddPaddingRow(0, views::kRelatedControlVerticalSpacing); | 598 layout->AddPaddingRow(0, views::kRelatedControlVerticalSpacing); |
598 } | 599 } |
599 | 600 |
600 layout->StartRow(0, column_set_id); | 601 layout->StartRow(0, column_set_id); |
601 views::Label* permissions_header = NULL; | 602 views::Label* permissions_header = NULL; |
602 if (is_bundle_install()) { | 603 if (is_bundle_install()) { |
603 // We need to pass the FontList in the constructor, rather than calling | 604 // We need to pass the FontList in the constructor, rather than calling |
604 // SetFontList later, because otherwise SizeToFit mis-judges the width | 605 // SetFontList later, because otherwise SizeToFit mis-judges the width |
605 // of the line. | 606 // of the line. |
606 permissions_header = new views::Label( | 607 permissions_header = |
607 prompt.GetPermissionsHeading(), | 608 new views::Label(prompt->GetPermissionsHeading(), |
608 rb.GetFontList(ui::ResourceBundle::MediumFont)); | 609 rb.GetFontList(ui::ResourceBundle::MediumFont)); |
609 } else { | 610 } else { |
610 permissions_header = new views::Label(prompt.GetPermissionsHeading()); | 611 permissions_header = new views::Label(prompt->GetPermissionsHeading()); |
611 } | 612 } |
612 permissions_header->SetMultiLine(true); | 613 permissions_header->SetMultiLine(true); |
613 permissions_header->SetHorizontalAlignment(gfx::ALIGN_LEFT); | 614 permissions_header->SetHorizontalAlignment(gfx::ALIGN_LEFT); |
614 permissions_header->SizeToFit(left_column_width); | 615 permissions_header->SizeToFit(left_column_width); |
615 layout->AddView(permissions_header); | 616 layout->AddView(permissions_header); |
616 | 617 |
617 for (size_t i = 0; i < prompt.GetPermissionCount(); ++i) { | 618 for (size_t i = 0; i < prompt->GetPermissionCount(); ++i) { |
618 layout->AddPaddingRow(0, views::kRelatedControlVerticalSpacing); | 619 layout->AddPaddingRow(0, views::kRelatedControlVerticalSpacing); |
619 layout->StartRow(0, column_set_id); | 620 layout->StartRow(0, column_set_id); |
620 views::Label* permission_label = | 621 views::Label* permission_label = |
621 new views::Label(prompt.GetPermission(i)); | 622 new views::Label(prompt->GetPermission(i)); |
622 | 623 |
623 const SkColor kTextHighlight = SK_ColorRED; | 624 const SkColor kTextHighlight = SK_ColorRED; |
624 const SkColor kBackgroundHighlight = SkColorSetRGB(0xFB, 0xF7, 0xA3); | 625 const SkColor kBackgroundHighlight = SkColorSetRGB(0xFB, 0xF7, 0xA3); |
625 if (prompt.experiment()->ShouldHighlightText( | 626 if (prompt->experiment()->ShouldHighlightText( |
626 prompt.GetPermission(i))) { | 627 prompt->GetPermission(i))) { |
627 permission_label->SetAutoColorReadabilityEnabled(false); | 628 permission_label->SetAutoColorReadabilityEnabled(false); |
628 permission_label->SetEnabledColor(kTextHighlight); | 629 permission_label->SetEnabledColor(kTextHighlight); |
629 } else if (prompt.experiment()->ShouldHighlightBackground( | 630 } else if (prompt->experiment()->ShouldHighlightBackground( |
630 prompt.GetPermission(i))) { | 631 prompt->GetPermission(i))) { |
631 permission_label->SetLineHeight(18); | 632 permission_label->SetLineHeight(18); |
632 permission_label->set_background( | 633 permission_label->set_background( |
633 views::Background::CreateSolidBackground(kBackgroundHighlight)); | 634 views::Background::CreateSolidBackground(kBackgroundHighlight)); |
634 } | 635 } |
635 | 636 |
636 permission_label->SetMultiLine(true); | 637 permission_label->SetMultiLine(true); |
637 permission_label->SetHorizontalAlignment(gfx::ALIGN_LEFT); | 638 permission_label->SetHorizontalAlignment(gfx::ALIGN_LEFT); |
638 permission_label->SizeToFit(left_column_width); | 639 permission_label->SizeToFit(left_column_width); |
639 | 640 |
640 if (prompt.experiment()->show_checkboxes()) { | 641 if (prompt->experiment()->show_checkboxes()) { |
641 layout->AddView(new CheckboxedView(permission_label, this)); | 642 layout->AddView(new CheckboxedView(permission_label, this)); |
642 ++unchecked_boxes_; | 643 ++unchecked_boxes_; |
643 } else { | 644 } else { |
644 layout->AddView(new BulletedView(permission_label)); | 645 layout->AddView(new BulletedView(permission_label)); |
645 } | 646 } |
646 // If we have more details to provide, show them in collapsed form. | 647 // If we have more details to provide, show them in collapsed form. |
647 if (!prompt.GetPermissionsDetails(i).empty()) { | 648 if (!prompt->GetPermissionsDetails(i).empty()) { |
648 layout->StartRow(0, column_set_id); | 649 layout->StartRow(0, column_set_id); |
649 PermissionDetails details; | 650 PermissionDetails details; |
650 details.push_back( | 651 details.push_back( |
651 PrepareForDisplay(prompt.GetPermissionsDetails(i), false)); | 652 PrepareForDisplay(prompt->GetPermissionsDetails(i), false)); |
652 ExpandableContainerView* details_container = | 653 ExpandableContainerView* details_container = |
653 new ExpandableContainerView( | 654 new ExpandableContainerView( |
654 this, base::string16(), details, left_column_width, | 655 this, base::string16(), details, left_column_width, |
655 true, true, false); | 656 true, true, false); |
656 layout->AddView(details_container); | 657 layout->AddView(details_container); |
657 } | 658 } |
658 | 659 |
659 if (prompt.experiment()->should_show_inline_explanations()) { | 660 if (prompt->experiment()->should_show_inline_explanations()) { |
660 base::string16 explanation = | 661 base::string16 explanation = |
661 prompt.experiment()->GetInlineExplanation( | 662 prompt->experiment()->GetInlineExplanation( |
662 prompt.GetPermission(i)); | 663 prompt->GetPermission(i)); |
663 if (!explanation.empty()) { | 664 if (!explanation.empty()) { |
664 PermissionDetails details; | 665 PermissionDetails details; |
665 details.push_back(explanation); | 666 details.push_back(explanation); |
666 ExpandableContainerView* container = | 667 ExpandableContainerView* container = |
667 new ExpandableContainerView(this, base::string16(), details, | 668 new ExpandableContainerView(this, base::string16(), details, |
668 left_column_width, | 669 left_column_width, |
669 false, false, true); | 670 false, false, true); |
670 // Inline explanations are expanded by default if there is | 671 // Inline explanations are expanded by default if there is |
671 // no "Show details" link. | 672 // no "Show details" link. |
672 if (!prompt.experiment()->show_details_link()) | 673 if (!prompt->experiment()->show_details_link()) |
673 container->ExpandWithoutAnimation(); | 674 container->ExpandWithoutAnimation(); |
674 layout->StartRow(0, column_set_id); | 675 layout->StartRow(0, column_set_id); |
675 layout->AddView(container); | 676 layout->AddView(container); |
676 inline_explanations_.push_back(container); | 677 inline_explanations_.push_back(container); |
677 } | 678 } |
678 } | 679 } |
679 } | 680 } |
680 } else { | 681 } else { |
681 layout->AddPaddingRow(0, views::kRelatedControlVerticalSpacing); | 682 layout->AddPaddingRow(0, views::kRelatedControlVerticalSpacing); |
682 layout->StartRow(0, column_set_id); | 683 layout->StartRow(0, column_set_id); |
683 views::Label* permission_label = new views::Label( | 684 views::Label* permission_label = new views::Label( |
684 l10n_util::GetStringUTF16(IDS_EXTENSION_NO_SPECIAL_PERMISSIONS)); | 685 l10n_util::GetStringUTF16(IDS_EXTENSION_NO_SPECIAL_PERMISSIONS)); |
685 permission_label->SetMultiLine(true); | 686 permission_label->SetMultiLine(true); |
686 permission_label->SetHorizontalAlignment(gfx::ALIGN_LEFT); | 687 permission_label->SetHorizontalAlignment(gfx::ALIGN_LEFT); |
687 permission_label->SizeToFit(left_column_width); | 688 permission_label->SizeToFit(left_column_width); |
688 layout->AddView(permission_label); | 689 layout->AddView(permission_label); |
689 } | 690 } |
690 } | 691 } |
691 | 692 |
692 if (prompt.GetRetainedFileCount()) { | 693 if (prompt->GetRetainedFileCount()) { |
693 // Slide in under the permissions, if there are any. If there are | 694 // Slide in under the permissions, if there are any. If there are |
694 // either, the retained files prompt stretches all the way to the | 695 // either, the retained files prompt stretches all the way to the |
695 // right of the dialog. If there are no permissions, the retained | 696 // right of the dialog. If there are no permissions, the retained |
696 // files prompt just takes up the left column. | 697 // files prompt just takes up the left column. |
697 int space_for_files = left_column_width; | 698 int space_for_files = left_column_width; |
698 if (prompt.GetPermissionCount()) { | 699 if (prompt->GetPermissionCount()) { |
699 space_for_files += kIconSize; | 700 space_for_files += kIconSize; |
700 views::ColumnSet* column_set = layout->AddColumnSet(++column_set_id); | 701 views::ColumnSet* column_set = layout->AddColumnSet(++column_set_id); |
701 column_set->AddColumn(views::GridLayout::FILL, | 702 column_set->AddColumn(views::GridLayout::FILL, |
702 views::GridLayout::FILL, | 703 views::GridLayout::FILL, |
703 1, | 704 1, |
704 views::GridLayout::USE_PREF, | 705 views::GridLayout::USE_PREF, |
705 0, // no fixed width | 706 0, // no fixed width |
706 space_for_files); | 707 space_for_files); |
707 } | 708 } |
708 | 709 |
709 layout->AddPaddingRow(0, views::kRelatedControlVerticalSpacing); | 710 layout->AddPaddingRow(0, views::kRelatedControlVerticalSpacing); |
710 | 711 |
711 layout->StartRow(0, column_set_id); | 712 layout->StartRow(0, column_set_id); |
712 views::Label* retained_files_header = NULL; | 713 views::Label* retained_files_header = NULL; |
713 retained_files_header = | 714 retained_files_header = new views::Label(prompt->GetRetainedFilesHeading()); |
714 new views::Label(prompt.GetRetainedFilesHeading()); | |
715 retained_files_header->SetMultiLine(true); | 715 retained_files_header->SetMultiLine(true); |
716 retained_files_header->SetHorizontalAlignment(gfx::ALIGN_LEFT); | 716 retained_files_header->SetHorizontalAlignment(gfx::ALIGN_LEFT); |
717 retained_files_header->SizeToFit(space_for_files); | 717 retained_files_header->SizeToFit(space_for_files); |
718 layout->AddView(retained_files_header); | 718 layout->AddView(retained_files_header); |
719 | 719 |
720 layout->StartRow(0, column_set_id); | 720 layout->StartRow(0, column_set_id); |
721 PermissionDetails details; | 721 PermissionDetails details; |
722 for (size_t i = 0; i < prompt.GetRetainedFileCount(); ++i) | 722 for (size_t i = 0; i < prompt->GetRetainedFileCount(); ++i) |
723 details.push_back(prompt.GetRetainedFile(i)); | 723 details.push_back(prompt->GetRetainedFile(i)); |
724 ExpandableContainerView* issue_advice_view = | 724 ExpandableContainerView* issue_advice_view = |
725 new ExpandableContainerView( | 725 new ExpandableContainerView( |
726 this, base::string16(), details, space_for_files, | 726 this, base::string16(), details, space_for_files, |
727 false, true, false); | 727 false, true, false); |
728 layout->AddView(issue_advice_view); | 728 layout->AddView(issue_advice_view); |
729 } | 729 } |
730 | 730 |
731 DCHECK(prompt.type() >= 0); | 731 DCHECK(prompt->type() >= 0); |
732 UMA_HISTOGRAM_ENUMERATION("Extensions.InstallPrompt.Type", | 732 UMA_HISTOGRAM_ENUMERATION("Extensions.InstallPrompt.Type", |
733 prompt.type(), | 733 prompt->type(), |
734 ExtensionInstallPrompt::NUM_PROMPT_TYPES); | 734 ExtensionInstallPrompt::NUM_PROMPT_TYPES); |
735 | 735 |
736 if (prompt.ShouldShowPermissions()) { | 736 if (prompt->ShouldShowPermissions()) { |
737 if (prompt.ShouldShowExplanationText()) { | 737 if (prompt->ShouldShowExplanationText()) { |
738 views::ColumnSet* column_set = layout->AddColumnSet(++column_set_id); | 738 views::ColumnSet* column_set = layout->AddColumnSet(++column_set_id); |
739 column_set->AddColumn(views::GridLayout::LEADING, | 739 column_set->AddColumn(views::GridLayout::LEADING, |
740 views::GridLayout::FILL, | 740 views::GridLayout::FILL, |
741 1, | 741 1, |
742 views::GridLayout::USE_PREF, | 742 views::GridLayout::USE_PREF, |
743 0, | 743 0, |
744 0); | 744 0); |
745 // Add two rows of space so that the text stands out. | 745 // Add two rows of space so that the text stands out. |
746 layout->AddPaddingRow(0, 2 * views::kRelatedControlVerticalSpacing); | 746 layout->AddPaddingRow(0, 2 * views::kRelatedControlVerticalSpacing); |
747 | 747 |
748 layout->StartRow(0, column_set_id); | 748 layout->StartRow(0, column_set_id); |
749 views::Label* explanation = new views::Label( | 749 views::Label* explanation = |
750 prompt.experiment()->GetExplanationText()); | 750 new views::Label(prompt->experiment()->GetExplanationText()); |
751 explanation->SetMultiLine(true); | 751 explanation->SetMultiLine(true); |
752 explanation->SetHorizontalAlignment(gfx::ALIGN_LEFT); | 752 explanation->SetHorizontalAlignment(gfx::ALIGN_LEFT); |
753 explanation->SizeToFit(left_column_width + kIconSize); | 753 explanation->SizeToFit(left_column_width + kIconSize); |
754 layout->AddView(explanation); | 754 layout->AddView(explanation); |
755 } | 755 } |
756 | 756 |
757 if (prompt.experiment()->should_show_expandable_permission_list() || | 757 if (prompt->experiment()->should_show_expandable_permission_list() || |
758 (prompt.experiment()->show_details_link() && | 758 (prompt->experiment()->show_details_link() && |
759 prompt.experiment()->should_show_inline_explanations() && | 759 prompt->experiment()->should_show_inline_explanations() && |
760 !inline_explanations_.empty())) { | 760 !inline_explanations_.empty())) { |
761 // Don't show the "Show details" link if there are retained | 761 // Don't show the "Show details" link if there are retained |
762 // files. These have their own "Show details" links and having | 762 // files. These have their own "Show details" links and having |
763 // multiple levels of links is confusing. | 763 // multiple levels of links is confusing. |
764 if (prompt.GetRetainedFileCount() == 0) { | 764 if (prompt->GetRetainedFileCount() == 0) { |
765 int text_id = | 765 int text_id = |
766 prompt.experiment()->should_show_expandable_permission_list() ? | 766 prompt->experiment()->should_show_expandable_permission_list() |
767 IDS_EXTENSION_PROMPT_EXPERIMENT_SHOW_PERMISSIONS : | 767 ? IDS_EXTENSION_PROMPT_EXPERIMENT_SHOW_PERMISSIONS |
768 IDS_EXTENSION_PROMPT_EXPERIMENT_SHOW_DETAILS; | 768 : IDS_EXTENSION_PROMPT_EXPERIMENT_SHOW_DETAILS; |
769 show_details_link_ = new views::Link( | 769 show_details_link_ = new views::Link( |
770 l10n_util::GetStringUTF16(text_id)); | 770 l10n_util::GetStringUTF16(text_id)); |
771 show_details_link_->SetHorizontalAlignment(gfx::ALIGN_LEFT); | 771 show_details_link_->SetHorizontalAlignment(gfx::ALIGN_LEFT); |
772 show_details_link_->set_listener(this); | 772 show_details_link_->set_listener(this); |
773 UpdateLinkActionHistogram(LINK_SHOWN); | 773 UpdateLinkActionHistogram(LINK_SHOWN); |
774 } else { | 774 } else { |
775 UpdateLinkActionHistogram(LINK_NOT_SHOWN); | 775 UpdateLinkActionHistogram(LINK_NOT_SHOWN); |
776 } | 776 } |
777 } | 777 } |
778 | 778 |
779 if (prompt.experiment()->show_checkboxes()) { | 779 if (prompt->experiment()->show_checkboxes()) { |
780 checkbox_info_label_ = new views::Label( | 780 checkbox_info_label_ = new views::Label( |
781 l10n_util::GetStringUTF16( | 781 l10n_util::GetStringUTF16( |
782 IDS_EXTENSION_PROMPT_EXPERIMENT_CHECKBOX_INFO)); | 782 IDS_EXTENSION_PROMPT_EXPERIMENT_CHECKBOX_INFO)); |
783 checkbox_info_label_->SetMultiLine(true); | 783 checkbox_info_label_->SetMultiLine(true); |
784 checkbox_info_label_->SetHorizontalAlignment(gfx::ALIGN_LEFT); | 784 checkbox_info_label_->SetHorizontalAlignment(gfx::ALIGN_LEFT); |
785 checkbox_info_label_->SetAutoColorReadabilityEnabled(false); | 785 checkbox_info_label_->SetAutoColorReadabilityEnabled(false); |
786 checkbox_info_label_->SetEnabledColor(kLighterLabelColor); | 786 checkbox_info_label_->SetEnabledColor(kLighterLabelColor); |
787 } | 787 } |
788 } | 788 } |
789 | 789 |
(...skipping 36 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
826 views::GridLayout::USE_PREF, | 826 views::GridLayout::USE_PREF, |
827 0, // no fixed width | 827 0, // no fixed width |
828 kIconSize); | 828 kIconSize); |
829 } | 829 } |
830 | 830 |
831 layout->StartRow(0, column_set_id); | 831 layout->StartRow(0, column_set_id); |
832 | 832 |
833 ui::ResourceBundle& rb = ui::ResourceBundle::GetSharedInstance(); | 833 ui::ResourceBundle& rb = ui::ResourceBundle::GetSharedInstance(); |
834 | 834 |
835 views::Label* heading = new views::Label( | 835 views::Label* heading = new views::Label( |
836 prompt_.GetHeading(), rb.GetFontList(ui::ResourceBundle::MediumFont)); | 836 prompt_->GetHeading(), rb.GetFontList(ui::ResourceBundle::MediumFont)); |
837 heading->SetMultiLine(true); | 837 heading->SetMultiLine(true); |
838 heading->SetHorizontalAlignment(gfx::ALIGN_LEFT); | 838 heading->SetHorizontalAlignment(gfx::ALIGN_LEFT); |
839 heading->SizeToFit(left_column_width); | 839 heading->SizeToFit(left_column_width); |
840 layout->AddView(heading); | 840 layout->AddView(heading); |
841 | 841 |
842 if (!is_bundle_install()) { | 842 if (!is_bundle_install()) { |
843 // Scale down to icon size, but allow smaller icons (don't scale up). | 843 // Scale down to icon size, but allow smaller icons (don't scale up). |
844 const gfx::ImageSkia* image = prompt_.icon().ToImageSkia(); | 844 const gfx::ImageSkia* image = prompt_->icon().ToImageSkia(); |
845 gfx::Size size(image->width(), image->height()); | 845 gfx::Size size(image->width(), image->height()); |
846 if (size.width() > kIconSize || size.height() > kIconSize) | 846 if (size.width() > kIconSize || size.height() > kIconSize) |
847 size = gfx::Size(kIconSize, kIconSize); | 847 size = gfx::Size(kIconSize, kIconSize); |
848 views::ImageView* icon = new views::ImageView(); | 848 views::ImageView* icon = new views::ImageView(); |
849 icon->SetImageSize(size); | 849 icon->SetImageSize(size); |
850 icon->SetImage(*image); | 850 icon->SetImage(*image); |
851 icon->SetHorizontalAlignment(views::ImageView::CENTER); | 851 icon->SetHorizontalAlignment(views::ImageView::CENTER); |
852 icon->SetVerticalAlignment(views::ImageView::CENTER); | 852 icon->SetVerticalAlignment(views::ImageView::CENTER); |
853 if (single_detail_row) { | 853 if (single_detail_row) { |
854 layout->AddView(icon); | 854 layout->AddView(icon); |
855 } else { | 855 } else { |
856 int icon_row_span = 1; | 856 int icon_row_span = 1; |
857 if (is_inline_install()) { | 857 if (is_inline_install()) { |
858 // Also span the rating, user_count and store_link rows. | 858 // Also span the rating, user_count and store_link rows. |
859 icon_row_span = 4; | 859 icon_row_span = 4; |
860 } else if (prompt_.ShouldShowPermissions()) { | 860 } else if (prompt_->ShouldShowPermissions()) { |
861 size_t permission_count = prompt_.GetPermissionCount(); | 861 size_t permission_count = prompt_->GetPermissionCount(); |
862 // Also span the permission header and each of the permission rows (all | 862 // Also span the permission header and each of the permission rows (all |
863 // have a padding row above it). This also works for the 'no special | 863 // have a padding row above it). This also works for the 'no special |
864 // permissions' case. | 864 // permissions' case. |
865 icon_row_span = 3 + permission_count * 2; | 865 icon_row_span = 3 + permission_count * 2; |
866 } else if (prompt_.GetRetainedFileCount()) { | 866 } else if (prompt_->GetRetainedFileCount()) { |
867 // Also span the permission header and the retained files container. | 867 // Also span the permission header and the retained files container. |
868 icon_row_span = 4; | 868 icon_row_span = 4; |
869 } | 869 } |
870 layout->AddView(icon, 1, icon_row_span); | 870 layout->AddView(icon, 1, icon_row_span); |
871 } | 871 } |
872 } | 872 } |
873 return layout; | 873 return layout; |
874 } | 874 } |
875 | 875 |
876 void ExtensionInstallDialogView::ContentsChanged() { | 876 void ExtensionInstallDialogView::ContentsChanged() { |
(...skipping 16 matching lines...) Expand all Loading... |
893 } else { | 893 } else { |
894 if (show_details_link_) | 894 if (show_details_link_) |
895 details.parent->RemoveChildView(show_details_link_); | 895 details.parent->RemoveChildView(show_details_link_); |
896 if (checkbox_info_label_) | 896 if (checkbox_info_label_) |
897 details.parent->RemoveChildView(checkbox_info_label_); | 897 details.parent->RemoveChildView(checkbox_info_label_); |
898 } | 898 } |
899 } | 899 } |
900 } | 900 } |
901 | 901 |
902 int ExtensionInstallDialogView::GetDialogButtons() const { | 902 int ExtensionInstallDialogView::GetDialogButtons() const { |
903 int buttons = prompt_.GetDialogButtons(); | 903 int buttons = prompt_->GetDialogButtons(); |
904 // Simply having just an OK button is *not* supported. See comment on function | 904 // Simply having just an OK button is *not* supported. See comment on function |
905 // GetDialogButtons in dialog_delegate.h for reasons. | 905 // GetDialogButtons in dialog_delegate.h for reasons. |
906 DCHECK_GT(buttons & ui::DIALOG_BUTTON_CANCEL, 0); | 906 DCHECK_GT(buttons & ui::DIALOG_BUTTON_CANCEL, 0); |
907 return buttons; | 907 return buttons; |
908 } | 908 } |
909 | 909 |
910 base::string16 ExtensionInstallDialogView::GetDialogButtonLabel( | 910 base::string16 ExtensionInstallDialogView::GetDialogButtonLabel( |
911 ui::DialogButton button) const { | 911 ui::DialogButton button) const { |
912 switch (button) { | 912 switch (button) { |
913 case ui::DIALOG_BUTTON_OK: | 913 case ui::DIALOG_BUTTON_OK: |
914 return prompt_.GetAcceptButtonLabel(); | 914 return prompt_->GetAcceptButtonLabel(); |
915 case ui::DIALOG_BUTTON_CANCEL: | 915 case ui::DIALOG_BUTTON_CANCEL: |
916 return prompt_.HasAbortButtonLabel() ? | 916 return prompt_->HasAbortButtonLabel() |
917 prompt_.GetAbortButtonLabel() : | 917 ? prompt_->GetAbortButtonLabel() |
918 l10n_util::GetStringUTF16(IDS_CANCEL); | 918 : l10n_util::GetStringUTF16(IDS_CANCEL); |
919 default: | 919 default: |
920 NOTREACHED(); | 920 NOTREACHED(); |
921 return base::string16(); | 921 return base::string16(); |
922 } | 922 } |
923 } | 923 } |
924 | 924 |
925 int ExtensionInstallDialogView::GetDefaultDialogButton() const { | 925 int ExtensionInstallDialogView::GetDefaultDialogButton() const { |
926 return ui::DIALOG_BUTTON_CANCEL; | 926 return ui::DIALOG_BUTTON_CANCEL; |
927 } | 927 } |
928 | 928 |
929 bool ExtensionInstallDialogView::Cancel() { | 929 bool ExtensionInstallDialogView::Cancel() { |
930 UpdateInstallResultHistogram(false); | 930 UpdateInstallResultHistogram(false); |
931 delegate_->InstallUIAbort(true); | 931 delegate_->InstallUIAbort(true); |
932 return true; | 932 return true; |
933 } | 933 } |
934 | 934 |
935 bool ExtensionInstallDialogView::Accept() { | 935 bool ExtensionInstallDialogView::Accept() { |
936 UpdateInstallResultHistogram(true); | 936 UpdateInstallResultHistogram(true); |
937 delegate_->InstallUIProceed(); | 937 delegate_->InstallUIProceed(); |
938 return true; | 938 return true; |
939 } | 939 } |
940 | 940 |
941 ui::ModalType ExtensionInstallDialogView::GetModalType() const { | 941 ui::ModalType ExtensionInstallDialogView::GetModalType() const { |
942 return ui::MODAL_TYPE_WINDOW; | 942 return ui::MODAL_TYPE_WINDOW; |
943 } | 943 } |
944 | 944 |
945 base::string16 ExtensionInstallDialogView::GetWindowTitle() const { | 945 base::string16 ExtensionInstallDialogView::GetWindowTitle() const { |
946 return prompt_.GetDialogTitle(); | 946 return prompt_->GetDialogTitle(); |
947 } | 947 } |
948 | 948 |
949 void ExtensionInstallDialogView::LinkClicked(views::Link* source, | 949 void ExtensionInstallDialogView::LinkClicked(views::Link* source, |
950 int event_flags) { | 950 int event_flags) { |
951 if (source == show_details_link_) { | 951 if (source == show_details_link_) { |
952 UpdateLinkActionHistogram(LINK_CLICKED); | 952 UpdateLinkActionHistogram(LINK_CLICKED); |
953 // Show details link is used to either reveal whole permission list or to | 953 // Show details link is used to either reveal whole permission list or to |
954 // reveal inline explanations. | 954 // reveal inline explanations. |
955 if (prompt_.experiment()->should_show_expandable_permission_list()) { | 955 if (prompt_->experiment()->should_show_expandable_permission_list()) { |
956 gfx::Rect bounds = GetWidget()->GetWindowBoundsInScreen(); | 956 gfx::Rect bounds = GetWidget()->GetWindowBoundsInScreen(); |
957 int spacing = bounds.height() - | 957 int spacing = bounds.height() - |
958 scrollable_header_only_->GetPreferredSize().height(); | 958 scrollable_header_only_->GetPreferredSize().height(); |
959 int content_height = std::min(scrollable_->GetPreferredSize().height(), | 959 int content_height = std::min(scrollable_->GetPreferredSize().height(), |
960 kDialogMaxHeight); | 960 kDialogMaxHeight); |
961 bounds.set_height(spacing + content_height); | 961 bounds.set_height(spacing + content_height); |
962 scroll_view_->SetContents(scrollable_); | 962 scroll_view_->SetContents(scrollable_); |
963 GetWidget()->SetBoundsConstrained(bounds); | 963 GetWidget()->SetBoundsConstrained(bounds); |
964 ContentsChanged(); | 964 ContentsChanged(); |
965 } else { | 965 } else { |
966 ToggleInlineExplanations(); | 966 ToggleInlineExplanations(); |
967 } | 967 } |
968 show_details_link_->SetVisible(false); | 968 show_details_link_->SetVisible(false); |
969 } else { | 969 } else { |
970 GURL store_url(extension_urls::GetWebstoreItemDetailURLPrefix() + | 970 GURL store_url(extension_urls::GetWebstoreItemDetailURLPrefix() + |
971 prompt_.extension()->id()); | 971 prompt_->extension()->id()); |
972 OpenURLParams params( | 972 OpenURLParams params( |
973 store_url, Referrer(), NEW_FOREGROUND_TAB, | 973 store_url, Referrer(), NEW_FOREGROUND_TAB, |
974 content::PAGE_TRANSITION_LINK, | 974 content::PAGE_TRANSITION_LINK, |
975 false); | 975 false); |
976 navigator_->OpenURL(params); | 976 navigator_->OpenURL(params); |
977 GetWidget()->Close(); | 977 GetWidget()->Close(); |
978 } | 978 } |
979 } | 979 } |
980 | 980 |
981 void ExtensionInstallDialogView::ToggleInlineExplanations() { | 981 void ExtensionInstallDialogView::ToggleInlineExplanations() { |
(...skipping 28 matching lines...) Expand all Loading... |
1010 gfx::Size label_size = checkbox_info_label_->GetPreferredSize(); | 1010 gfx::Size label_size = checkbox_info_label_->GetPreferredSize(); |
1011 checkbox_info_label_->SetBounds( | 1011 checkbox_info_label_->SetBounds( |
1012 horizontal_margin, | 1012 horizontal_margin, |
1013 y_buttons + (cancel_button->height() - label_size.height()) / 2, | 1013 y_buttons + (cancel_button->height() - label_size.height()) / 2, |
1014 label_size.width(), label_size.height()); | 1014 label_size.width(), label_size.height()); |
1015 checkbox_info_label_->SizeToFit(max_width); | 1015 checkbox_info_label_->SizeToFit(max_width); |
1016 } | 1016 } |
1017 } | 1017 } |
1018 // Disable accept button if there are unchecked boxes and | 1018 // Disable accept button if there are unchecked boxes and |
1019 // the experiment is on. | 1019 // the experiment is on. |
1020 if (prompt_.experiment()->show_checkboxes()) | 1020 if (prompt_->experiment()->show_checkboxes()) |
1021 GetDialogClientView()->ok_button()->SetEnabled(unchecked_boxes_ == 0); | 1021 GetDialogClientView()->ok_button()->SetEnabled(unchecked_boxes_ == 0); |
1022 | 1022 |
1023 DialogDelegateView::Layout(); | 1023 DialogDelegateView::Layout(); |
1024 } | 1024 } |
1025 | 1025 |
1026 gfx::Size ExtensionInstallDialogView::GetPreferredSize() const { | 1026 gfx::Size ExtensionInstallDialogView::GetPreferredSize() const { |
1027 return dialog_size_; | 1027 return dialog_size_; |
1028 } | 1028 } |
1029 | 1029 |
1030 void ExtensionInstallDialogView::ButtonPressed(views::Button* sender, | 1030 void ExtensionInstallDialogView::ButtonPressed(views::Button* sender, |
1031 const ui::Event& event) { | 1031 const ui::Event& event) { |
1032 if (std::string(views::Checkbox::kViewClassName) == sender->GetClassName()) { | 1032 if (std::string(views::Checkbox::kViewClassName) == sender->GetClassName()) { |
1033 views::Checkbox* checkbox = static_cast<views::Checkbox*>(sender); | 1033 views::Checkbox* checkbox = static_cast<views::Checkbox*>(sender); |
1034 if (checkbox->checked()) | 1034 if (checkbox->checked()) |
1035 --unchecked_boxes_; | 1035 --unchecked_boxes_; |
1036 else | 1036 else |
1037 ++unchecked_boxes_; | 1037 ++unchecked_boxes_; |
1038 | 1038 |
1039 GetDialogClientView()->ok_button()->SetEnabled(unchecked_boxes_ == 0); | 1039 GetDialogClientView()->ok_button()->SetEnabled(unchecked_boxes_ == 0); |
1040 checkbox_info_label_->SetVisible(unchecked_boxes_ > 0); | 1040 checkbox_info_label_->SetVisible(unchecked_boxes_ > 0); |
1041 } | 1041 } |
1042 } | 1042 } |
1043 | 1043 |
1044 void ExtensionInstallDialogView::UpdateInstallResultHistogram(bool accepted) | 1044 void ExtensionInstallDialogView::UpdateInstallResultHistogram(bool accepted) |
1045 const { | 1045 const { |
1046 if (prompt_.type() == ExtensionInstallPrompt::INSTALL_PROMPT) | 1046 if (prompt_->type() == ExtensionInstallPrompt::INSTALL_PROMPT) |
1047 UMA_HISTOGRAM_BOOLEAN("Extensions.InstallPrompt.Accepted", accepted); | 1047 UMA_HISTOGRAM_BOOLEAN("Extensions.InstallPrompt.Accepted", accepted); |
1048 } | 1048 } |
1049 | 1049 |
1050 void ExtensionInstallDialogView::UpdateLinkActionHistogram(int action_type) | 1050 void ExtensionInstallDialogView::UpdateLinkActionHistogram(int action_type) |
1051 const { | 1051 const { |
1052 if (prompt_.experiment()->should_show_expandable_permission_list()) { | 1052 if (prompt_->experiment()->should_show_expandable_permission_list()) { |
1053 // The clickable link in the UI is "Show Permissions". | 1053 // The clickable link in the UI is "Show Permissions". |
1054 UMA_HISTOGRAM_ENUMERATION( | 1054 UMA_HISTOGRAM_ENUMERATION( |
1055 "Extensions.InstallPromptExperiment.ShowPermissions", | 1055 "Extensions.InstallPromptExperiment.ShowPermissions", |
1056 action_type, | 1056 action_type, |
1057 NUM_LINK_ACTIONS); | 1057 NUM_LINK_ACTIONS); |
1058 } else { | 1058 } else { |
1059 // The clickable link in the UI is "Show Details". | 1059 // The clickable link in the UI is "Show Details". |
1060 UMA_HISTOGRAM_ENUMERATION( | 1060 UMA_HISTOGRAM_ENUMERATION( |
1061 "Extensions.InstallPromptExperiment.ShowDetails", | 1061 "Extensions.InstallPromptExperiment.ShowDetails", |
1062 action_type, | 1062 action_type, |
(...skipping 213 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
1276 if (slide_animation_.IsShowing()) | 1276 if (slide_animation_.IsShowing()) |
1277 slide_animation_.Hide(); | 1277 slide_animation_.Hide(); |
1278 else | 1278 else |
1279 slide_animation_.Show(); | 1279 slide_animation_.Show(); |
1280 } | 1280 } |
1281 | 1281 |
1282 void ExpandableContainerView::ExpandWithoutAnimation() { | 1282 void ExpandableContainerView::ExpandWithoutAnimation() { |
1283 expanded_ = true; | 1283 expanded_ = true; |
1284 details_view_->AnimateToState(1.0); | 1284 details_view_->AnimateToState(1.0); |
1285 } | 1285 } |
OLD | NEW |