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

Side by Side Diff: chrome/browser/ui/views/extensions/extension_install_dialog_view.cc

Issue 660643002: [Refactor] Move creating a browser if necessary to ExtensionInstallDialogView (Closed) Base URL: https://chromium.googlesource.com/chromium/src.git@master
Patch Set: Created 6 years, 2 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/extensions/extension_install_dialog_view.h" 5 #include "chrome/browser/ui/views/extensions/extension_install_dialog_view.h"
6 6
7 #include <vector> 7 #include <vector>
8 8
9 #include "base/basictypes.h" 9 #include "base/basictypes.h"
10 #include "base/command_line.h" 10 #include "base/command_line.h"
11 #include "base/compiler_specific.h" 11 #include "base/compiler_specific.h"
12 #include "base/i18n/rtl.h" 12 #include "base/i18n/rtl.h"
13 #include "base/metrics/histogram.h" 13 #include "base/metrics/histogram.h"
14 #include "base/strings/string_util.h" 14 #include "base/strings/string_util.h"
15 #include "base/strings/utf_string_conversions.h" 15 #include "base/strings/utf_string_conversions.h"
16 #include "chrome/browser/browser_process.h" 16 #include "chrome/browser/browser_process.h"
17 #include "chrome/browser/extensions/api/experience_sampling_private/experience_s ampling.h" 17 #include "chrome/browser/extensions/api/experience_sampling_private/experience_s ampling.h"
18 #include "chrome/browser/extensions/bundle_installer.h" 18 #include "chrome/browser/extensions/bundle_installer.h"
19 #include "chrome/browser/extensions/extension_install_prompt_experiment.h" 19 #include "chrome/browser/extensions/extension_install_prompt_experiment.h"
20 #include "chrome/browser/profiles/profile.h" 20 #include "chrome/browser/profiles/profile.h"
21 #include "chrome/browser/profiles/profile_manager.h" 21 #include "chrome/browser/profiles/profile_manager.h"
22 #include "chrome/browser/ui/browser.h"
23 #include "chrome/browser/ui/scoped_tabbed_browser_displayer.h"
22 #include "chrome/browser/ui/views/constrained_window_views.h" 24 #include "chrome/browser/ui/views/constrained_window_views.h"
23 #include "chrome/common/extensions/extension_constants.h" 25 #include "chrome/common/extensions/extension_constants.h"
24 #include "chrome/grit/generated_resources.h" 26 #include "chrome/grit/generated_resources.h"
25 #include "chrome/installer/util/browser_distribution.h" 27 #include "chrome/installer/util/browser_distribution.h"
26 #include "content/public/browser/page_navigator.h" 28 #include "content/public/browser/page_navigator.h"
27 #include "content/public/browser/web_contents.h" 29 #include "content/public/browser/web_contents.h"
28 #include "extensions/common/extension.h" 30 #include "extensions/common/extension.h"
29 #include "extensions/common/extension_urls.h" 31 #include "extensions/common/extension_urls.h"
30 #include "grit/theme_resources.h" 32 #include "grit/theme_resources.h"
31 #include "ui/base/l10n/l10n_util.h" 33 #include "ui/base/l10n/l10n_util.h"
(...skipping 131 matching lines...) Expand 10 before | Expand all | Expand 10 after
163 views::GridLayout::LEADING, views::GridLayout::CENTER); 165 views::GridLayout::LEADING, views::GridLayout::CENTER);
164 layout->AddView(view, 1, 1, 166 layout->AddView(view, 1, 1,
165 views::GridLayout::LEADING, views::GridLayout::CENTER); 167 views::GridLayout::LEADING, views::GridLayout::CENTER);
166 } 168 }
167 169
168 void ShowExtensionInstallDialogImpl( 170 void ShowExtensionInstallDialogImpl(
169 const ExtensionInstallPrompt::ShowParams& show_params, 171 const ExtensionInstallPrompt::ShowParams& show_params,
170 ExtensionInstallPrompt::Delegate* delegate, 172 ExtensionInstallPrompt::Delegate* delegate,
171 scoped_refptr<ExtensionInstallPrompt::Prompt> prompt) { 173 scoped_refptr<ExtensionInstallPrompt::Prompt> prompt) {
172 DCHECK_CURRENTLY_ON(content::BrowserThread::UI); 174 DCHECK_CURRENTLY_ON(content::BrowserThread::UI);
173 CreateBrowserModalDialogViews( 175 ExtensionInstallDialogView* dialog =
174 new ExtensionInstallDialogView(show_params.navigator, delegate, prompt), 176 new ExtensionInstallDialogView(show_params.profile,
175 show_params.parent_window)->Show(); 177 show_params.parent_web_contents,
178 delegate,
179 prompt);
180 CreateBrowserModalDialogViews(dialog, show_params.parent_window)->Show();
176 } 181 }
177 182
178 CustomScrollableView::CustomScrollableView() {} 183 CustomScrollableView::CustomScrollableView() {}
179 CustomScrollableView::~CustomScrollableView() {} 184 CustomScrollableView::~CustomScrollableView() {}
180 185
181 void CustomScrollableView::Layout() { 186 void CustomScrollableView::Layout() {
182 SetBounds(x(), y(), width(), GetHeightForWidth(width())); 187 SetBounds(x(), y(), width(), GetHeightForWidth(width()));
183 views::View::Layout(); 188 views::View::Layout();
184 } 189 }
185 190
186 ExtensionInstallDialogView::ExtensionInstallDialogView( 191 ExtensionInstallDialogView::ExtensionInstallDialogView(
192 Profile* profile,
187 content::PageNavigator* navigator, 193 content::PageNavigator* navigator,
188 ExtensionInstallPrompt::Delegate* delegate, 194 ExtensionInstallPrompt::Delegate* delegate,
189 scoped_refptr<ExtensionInstallPrompt::Prompt> prompt) 195 scoped_refptr<ExtensionInstallPrompt::Prompt> prompt)
190 : navigator_(navigator), 196 : profile_(profile),
197 navigator_(navigator),
191 delegate_(delegate), 198 delegate_(delegate),
192 prompt_(prompt), 199 prompt_(prompt),
193 scroll_view_(NULL), 200 scroll_view_(NULL),
194 scrollable_(NULL), 201 scrollable_(NULL),
195 scrollable_header_only_(NULL), 202 scrollable_header_only_(NULL),
196 show_details_link_(NULL), 203 show_details_link_(NULL),
197 checkbox_info_label_(NULL), 204 checkbox_info_label_(NULL),
198 unchecked_boxes_(0), 205 unchecked_boxes_(0),
199 handled_result_(false) { 206 handled_result_(false) {
200 InitView(); 207 InitView();
(...skipping 643 matching lines...) Expand 10 before | Expand all | Expand 10 after
844 ToggleInlineExplanations(); 851 ToggleInlineExplanations();
845 } 852 }
846 show_details_link_->SetVisible(false); 853 show_details_link_->SetVisible(false);
847 } else { 854 } else {
848 GURL store_url(extension_urls::GetWebstoreItemDetailURLPrefix() + 855 GURL store_url(extension_urls::GetWebstoreItemDetailURLPrefix() +
849 prompt_->extension()->id()); 856 prompt_->extension()->id());
850 OpenURLParams params( 857 OpenURLParams params(
851 store_url, Referrer(), NEW_FOREGROUND_TAB, 858 store_url, Referrer(), NEW_FOREGROUND_TAB,
852 ui::PAGE_TRANSITION_LINK, 859 ui::PAGE_TRANSITION_LINK,
853 false); 860 false);
854 navigator_->OpenURL(params); 861
862 if (navigator_) {
863 navigator_->OpenURL(params);
864 } else {
865 chrome::ScopedTabbedBrowserDisplayer displayer(
866 profile_, chrome::GetActiveDesktop());
867 displayer.browser()->OpenURL(params);
868 }
855 GetWidget()->Close(); 869 GetWidget()->Close();
856 } 870 }
857 } 871 }
858 872
859 void ExtensionInstallDialogView::ToggleInlineExplanations() { 873 void ExtensionInstallDialogView::ToggleInlineExplanations() {
860 for (InlineExplanations::iterator it = inline_explanations_.begin(); 874 for (InlineExplanations::iterator it = inline_explanations_.begin();
861 it != inline_explanations_.end(); ++it) 875 it != inline_explanations_.end(); ++it)
862 (*it)->ToggleDetailLevel(); 876 (*it)->ToggleDetailLevel();
863 } 877 }
864 878
(...skipping 289 matching lines...) Expand 10 before | Expand all | Expand 10 after
1154 void ExpandableContainerView::ExpandWithoutAnimation() { 1168 void ExpandableContainerView::ExpandWithoutAnimation() {
1155 expanded_ = true; 1169 expanded_ = true;
1156 details_view_->AnimateToState(1.0); 1170 details_view_->AnimateToState(1.0);
1157 } 1171 }
1158 1172
1159 // static 1173 // static
1160 ExtensionInstallPrompt::ShowDialogCallback 1174 ExtensionInstallPrompt::ShowDialogCallback
1161 ExtensionInstallPrompt::GetDefaultShowDialogCallback() { 1175 ExtensionInstallPrompt::GetDefaultShowDialogCallback() {
1162 return base::Bind(&ShowExtensionInstallDialogImpl); 1176 return base::Bind(&ShowExtensionInstallDialogImpl);
1163 } 1177 }
OLDNEW

Powered by Google App Engine
This is Rietveld 408576698