| 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/extensions/extension_install_dialog_view.h" | 5 #include "chrome/browser/ui/views/extensions/extension_install_dialog_view.h" |
| 6 | 6 |
| 7 #include <algorithm> |
| 8 #include <string> |
| 7 #include <vector> | 9 #include <vector> |
| 8 | 10 |
| 9 #include "base/basictypes.h" | 11 #include "base/basictypes.h" |
| 10 #include "base/command_line.h" | 12 #include "base/command_line.h" |
| 11 #include "base/compiler_specific.h" | 13 #include "base/compiler_specific.h" |
| 12 #include "base/i18n/rtl.h" | 14 #include "base/i18n/rtl.h" |
| 13 #include "base/metrics/histogram.h" | 15 #include "base/metrics/histogram.h" |
| 14 #include "base/strings/string_util.h" | 16 #include "base/strings/string_util.h" |
| 15 #include "base/strings/utf_string_conversions.h" | 17 #include "base/strings/utf_string_conversions.h" |
| 16 #include "chrome/browser/browser_process.h" | 18 #include "chrome/browser/browser_process.h" |
| (...skipping 83 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 100 void ShowExtensionInstallDialogImpl( | 102 void ShowExtensionInstallDialogImpl( |
| 101 ExtensionInstallPromptShowParams* show_params, | 103 ExtensionInstallPromptShowParams* show_params, |
| 102 ExtensionInstallPrompt::Delegate* delegate, | 104 ExtensionInstallPrompt::Delegate* delegate, |
| 103 scoped_refptr<ExtensionInstallPrompt::Prompt> prompt) { | 105 scoped_refptr<ExtensionInstallPrompt::Prompt> prompt) { |
| 104 DCHECK_CURRENTLY_ON(content::BrowserThread::UI); | 106 DCHECK_CURRENTLY_ON(content::BrowserThread::UI); |
| 105 ExtensionInstallDialogView* dialog = | 107 ExtensionInstallDialogView* dialog = |
| 106 new ExtensionInstallDialogView(show_params->profile(), | 108 new ExtensionInstallDialogView(show_params->profile(), |
| 107 show_params->GetParentWebContents(), | 109 show_params->GetParentWebContents(), |
| 108 delegate, | 110 delegate, |
| 109 prompt); | 111 prompt); |
| 110 constrained_window::CreateBrowserModalDialogViews( | 112 if (prompt->ShouldUseTabModalDialog()) { |
| 111 dialog, show_params->GetParentWindow())->Show(); | 113 content::WebContents* parent_web_contents = |
| 114 show_params->GetParentWebContents(); |
| 115 if (parent_web_contents) |
| 116 constrained_window::ShowWebModalDialogViews(dialog, parent_web_contents); |
| 117 } else { |
| 118 constrained_window::CreateBrowserModalDialogViews( |
| 119 dialog, show_params->GetParentWindow()) |
| 120 ->Show(); |
| 121 } |
| 112 } | 122 } |
| 113 | 123 |
| 114 // A custom scrollable view implementation for the dialog. | 124 // A custom scrollable view implementation for the dialog. |
| 115 class CustomScrollableView : public views::View { | 125 class CustomScrollableView : public views::View { |
| 116 public: | 126 public: |
| 117 CustomScrollableView() {} | 127 CustomScrollableView() {} |
| 118 ~CustomScrollableView() override {} | 128 ~CustomScrollableView() override {} |
| 119 | 129 |
| 120 // Called when one of the child elements has expanded/collapsed. | 130 // Called when one of the child elements has expanded/collapsed. |
| 121 void ChildPreferredSizeChanged(views::View* child) override { | 131 void ChildPreferredSizeChanged(views::View* child) override { |
| (...skipping 283 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 405 } | 415 } |
| 406 ExpandableContainerView* issue_advice_view = | 416 ExpandableContainerView* issue_advice_view = |
| 407 new ExpandableContainerView(this, | 417 new ExpandableContainerView(this, |
| 408 base::string16(), | 418 base::string16(), |
| 409 details, | 419 details, |
| 410 scrollable_width, | 420 scrollable_width, |
| 411 false); | 421 false); |
| 412 scroll_layout->AddView(issue_advice_view); | 422 scroll_layout->AddView(issue_advice_view); |
| 413 } | 423 } |
| 414 | 424 |
| 415 DCHECK(prompt_->type() >= 0); | 425 DCHECK_GE(prompt_->type(), 0); |
| 416 UMA_HISTOGRAM_ENUMERATION("Extensions.InstallPrompt.Type", | 426 UMA_HISTOGRAM_ENUMERATION("Extensions.InstallPrompt.Type", |
| 417 prompt_->type(), | 427 prompt_->type(), |
| 418 ExtensionInstallPrompt::NUM_PROMPT_TYPES); | 428 ExtensionInstallPrompt::NUM_PROMPT_TYPES); |
| 419 | 429 |
| 420 scroll_view_->ClipHeightTo( | 430 scroll_view_->ClipHeightTo( |
| 421 0, | 431 0, |
| 422 std::min(kScrollViewMaxHeight, scrollable->GetPreferredSize().height())); | 432 std::min(kScrollViewMaxHeight, scrollable->GetPreferredSize().height())); |
| 423 | 433 |
| 424 dialog_size_ = gfx::Size( | 434 dialog_size_ = gfx::Size( |
| 425 content_width + 2 * views::kButtonHEdgeMarginNew, | 435 content_width + 2 * views::kButtonHEdgeMarginNew, |
| (...skipping 165 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 591 | 601 |
| 592 handled_result_ = true; | 602 handled_result_ = true; |
| 593 UpdateInstallResultHistogram(true); | 603 UpdateInstallResultHistogram(true); |
| 594 if (sampling_event_) | 604 if (sampling_event_) |
| 595 sampling_event_->CreateUserDecisionEvent(ExperienceSamplingEvent::kProceed); | 605 sampling_event_->CreateUserDecisionEvent(ExperienceSamplingEvent::kProceed); |
| 596 delegate_->InstallUIProceed(); | 606 delegate_->InstallUIProceed(); |
| 597 return true; | 607 return true; |
| 598 } | 608 } |
| 599 | 609 |
| 600 ui::ModalType ExtensionInstallDialogView::GetModalType() const { | 610 ui::ModalType ExtensionInstallDialogView::GetModalType() const { |
| 601 return ui::MODAL_TYPE_WINDOW; | 611 return prompt_->ShouldUseTabModalDialog() ? ui::MODAL_TYPE_CHILD |
| 612 : ui::MODAL_TYPE_WINDOW; |
| 602 } | 613 } |
| 603 | 614 |
| 604 void ExtensionInstallDialogView::LinkClicked(views::Link* source, | 615 void ExtensionInstallDialogView::LinkClicked(views::Link* source, |
| 605 int event_flags) { | 616 int event_flags) { |
| 606 GURL store_url(extension_urls::GetWebstoreItemDetailURLPrefix() + | 617 GURL store_url(extension_urls::GetWebstoreItemDetailURLPrefix() + |
| 607 prompt_->extension()->id()); | 618 prompt_->extension()->id()); |
| 608 OpenURLParams params( | 619 OpenURLParams params( |
| 609 store_url, Referrer(), NEW_FOREGROUND_TAB, | 620 store_url, Referrer(), NEW_FOREGROUND_TAB, |
| 610 ui::PAGE_TRANSITION_LINK, | 621 ui::PAGE_TRANSITION_LINK, |
| 611 false); | 622 false); |
| (...skipping 206 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 818 expanded ? gfx::VectorIconId::FIND_PREV : gfx::VectorIconId::FIND_NEXT, | 829 expanded ? gfx::VectorIconId::FIND_PREV : gfx::VectorIconId::FIND_NEXT, |
| 819 16, gfx::kChromeIconGrey); | 830 16, gfx::kChromeIconGrey); |
| 820 arrow_toggle_->SetImage(views::Button::STATE_NORMAL, &icon); | 831 arrow_toggle_->SetImage(views::Button::STATE_NORMAL, &icon); |
| 821 } | 832 } |
| 822 | 833 |
| 823 // static | 834 // static |
| 824 ExtensionInstallPrompt::ShowDialogCallback | 835 ExtensionInstallPrompt::ShowDialogCallback |
| 825 ExtensionInstallPrompt::GetDefaultShowDialogCallback() { | 836 ExtensionInstallPrompt::GetDefaultShowDialogCallback() { |
| 826 return base::Bind(&ShowExtensionInstallDialogImpl); | 837 return base::Bind(&ShowExtensionInstallDialogImpl); |
| 827 } | 838 } |
| OLD | NEW |