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

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

Issue 10699057: Move application creation and extension install prompt showing off Browser and onto ExtensionTabHel… (Closed) Base URL: svn://svn.chromium.org/chrome/trunk/src/
Patch Set: Created 8 years, 5 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 | Annotate | Revision Log
« no previous file with comments | « chrome/browser/ui/views/browser_dialogs.h ('k') | chrome/browser/ui/views/frame/browser_view.h » ('j') | no next file with comments »
Toggle Intra-line Diffs ('i') | Expand Comments ('e') | Collapse Comments ('c') | Show Comments Hide Comments ('s')
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 <vector> 5 #include <vector>
6 6
7 #include "base/basictypes.h" 7 #include "base/basictypes.h"
8 #include "base/compiler_specific.h" 8 #include "base/compiler_specific.h"
9 #include "base/i18n/rtl.h" 9 #include "base/i18n/rtl.h"
10 #include "base/string_util.h" 10 #include "base/string_util.h"
11 #include "base/utf_string_conversions.h" 11 #include "base/utf_string_conversions.h"
12 #include "chrome/browser/extensions/bundle_installer.h" 12 #include "chrome/browser/extensions/bundle_installer.h"
13 #include "chrome/browser/extensions/extension_install_dialog.h" 13 #include "chrome/browser/extensions/extension_install_dialog.h"
14 #include "chrome/browser/profiles/profile.h" 14 #include "chrome/browser/profiles/profile.h"
15 #include "chrome/browser/ui/browser_finder.h"
16 #include "chrome/browser/ui/browser_list.h"
17 #include "chrome/browser/ui/browser_window.h"
18 #include "chrome/common/extensions/extension.h" 15 #include "chrome/common/extensions/extension.h"
16 #include "content/public/browser/page_navigator.h"
19 #include "grit/generated_resources.h" 17 #include "grit/generated_resources.h"
20 #include "ui/base/l10n/l10n_util.h" 18 #include "ui/base/l10n/l10n_util.h"
21 #include "ui/base/resource/resource_bundle.h" 19 #include "ui/base/resource/resource_bundle.h"
22 #include "ui/views/border.h" 20 #include "ui/views/border.h"
23 #include "ui/views/controls/image_view.h" 21 #include "ui/views/controls/image_view.h"
24 #include "ui/views/controls/label.h" 22 #include "ui/views/controls/label.h"
25 #include "ui/views/controls/link.h" 23 #include "ui/views/controls/link.h"
26 #include "ui/views/controls/link_listener.h" 24 #include "ui/views/controls/link_listener.h"
27 #include "ui/views/controls/separator.h" 25 #include "ui/views/controls/separator.h"
28 #include "ui/views/layout/box_layout.h" 26 #include "ui/views/layout/box_layout.h"
(...skipping 39 matching lines...) Expand 10 before | Expand all | Expand 10 after
68 image_view->SetImage(*skia_image); 66 image_view->SetImage(*skia_image);
69 parent->AddChildView(image_view); 67 parent->AddChildView(image_view);
70 } 68 }
71 69
72 } // namespace 70 } // namespace
73 71
74 // Implements the extension installation dialog for TOOLKIT_VIEWS. 72 // Implements the extension installation dialog for TOOLKIT_VIEWS.
75 class ExtensionInstallDialogView : public views::DialogDelegateView, 73 class ExtensionInstallDialogView : public views::DialogDelegateView,
76 public views::LinkListener { 74 public views::LinkListener {
77 public: 75 public:
78 ExtensionInstallDialogView(Browser* browser, 76 ExtensionInstallDialogView(content::PageNavigator* navigator,
79 ExtensionInstallPrompt::Delegate* delegate, 77 ExtensionInstallPrompt::Delegate* delegate,
80 const ExtensionInstallPrompt::Prompt& prompt); 78 const ExtensionInstallPrompt::Prompt& prompt);
81 virtual ~ExtensionInstallDialogView(); 79 virtual ~ExtensionInstallDialogView();
82 80
83 private: 81 private:
84 // views::DialogDelegateView: 82 // views::DialogDelegateView:
85 virtual string16 GetDialogButtonLabel(ui::DialogButton button) const OVERRIDE; 83 virtual string16 GetDialogButtonLabel(ui::DialogButton button) const OVERRIDE;
86 virtual int GetDefaultDialogButton() const OVERRIDE; 84 virtual int GetDefaultDialogButton() const OVERRIDE;
87 virtual bool Cancel() OVERRIDE; 85 virtual bool Cancel() OVERRIDE;
88 virtual bool Accept() OVERRIDE; 86 virtual bool Accept() OVERRIDE;
89 87
90 // views::WidgetDelegate: 88 // views::WidgetDelegate:
91 virtual ui::ModalType GetModalType() const OVERRIDE; 89 virtual ui::ModalType GetModalType() const OVERRIDE;
92 virtual string16 GetWindowTitle() const OVERRIDE; 90 virtual string16 GetWindowTitle() const OVERRIDE;
93 virtual views::View* GetContentsView() OVERRIDE; 91 virtual views::View* GetContentsView() OVERRIDE;
94 92
95 // views::LinkListener: 93 // views::LinkListener:
96 virtual void LinkClicked(views::Link* source, int event_flags) OVERRIDE; 94 virtual void LinkClicked(views::Link* source, int event_flags) OVERRIDE;
97 95
98 bool is_inline_install() { 96 bool is_inline_install() {
99 return prompt_.type() == ExtensionInstallPrompt::INLINE_INSTALL_PROMPT; 97 return prompt_.type() == ExtensionInstallPrompt::INLINE_INSTALL_PROMPT;
100 } 98 }
101 99
102 bool is_bundle_install() { 100 bool is_bundle_install() {
103 return prompt_.type() == ExtensionInstallPrompt::BUNDLE_INSTALL_PROMPT; 101 return prompt_.type() == ExtensionInstallPrompt::BUNDLE_INSTALL_PROMPT;
104 } 102 }
105 103
106 Browser* browser_; 104 content::PageNavigator* navigator_;
107 ExtensionInstallPrompt::Delegate* delegate_; 105 ExtensionInstallPrompt::Delegate* delegate_;
108 ExtensionInstallPrompt::Prompt prompt_; 106 ExtensionInstallPrompt::Prompt prompt_;
109 107
110 DISALLOW_COPY_AND_ASSIGN(ExtensionInstallDialogView); 108 DISALLOW_COPY_AND_ASSIGN(ExtensionInstallDialogView);
111 }; 109 };
112 110
113 ExtensionInstallDialogView::ExtensionInstallDialogView( 111 ExtensionInstallDialogView::ExtensionInstallDialogView(
114 Browser* browser, 112 content::PageNavigator* navigator,
115 ExtensionInstallPrompt::Delegate* delegate, 113 ExtensionInstallPrompt::Delegate* delegate,
116 const ExtensionInstallPrompt::Prompt& prompt) 114 const ExtensionInstallPrompt::Prompt& prompt)
117 : browser_(browser), 115 : navigator_(navigator),
118 delegate_(delegate), 116 delegate_(delegate),
119 prompt_(prompt) { 117 prompt_(prompt) {
120 // Possible grid layouts: 118 // Possible grid layouts:
121 // Inline install 119 // Inline install
122 // w/ permissions no permissions 120 // w/ permissions no permissions
123 // +--------------------+------+ +--------------+------+ 121 // +--------------------+------+ +--------------+------+
124 // | heading | icon | | heading | icon | 122 // | heading | icon | | heading | icon |
125 // +--------------------| | +--------------| | 123 // +--------------------| | +--------------| |
126 // | rating | | | rating | | 124 // | rating | | | rating | |
127 // +--------------------| | +--------------+ | 125 // +--------------------| | +--------------+ |
(...skipping 214 matching lines...) Expand 10 before | Expand all | Expand 10 after
342 return this; 340 return this;
343 } 341 }
344 342
345 void ExtensionInstallDialogView::LinkClicked(views::Link* source, 343 void ExtensionInstallDialogView::LinkClicked(views::Link* source,
346 int event_flags) { 344 int event_flags) {
347 GURL store_url(extension_urls::GetWebstoreItemDetailURLPrefix() + 345 GURL store_url(extension_urls::GetWebstoreItemDetailURLPrefix() +
348 prompt_.extension()->id()); 346 prompt_.extension()->id());
349 OpenURLParams params( 347 OpenURLParams params(
350 store_url, Referrer(), NEW_FOREGROUND_TAB, content::PAGE_TRANSITION_LINK, 348 store_url, Referrer(), NEW_FOREGROUND_TAB, content::PAGE_TRANSITION_LINK,
351 false); 349 false);
352 browser_->OpenURL(params); 350 navigator_->OpenURL(params);
353 GetWidget()->Close(); 351 GetWidget()->Close();
354 } 352 }
355 353
356 void ShowExtensionInstallDialogImpl( 354 void ShowExtensionInstallDialogImpl(
357 Browser* browser, 355 gfx::NativeWindow parent,
356 content::PageNavigator* navigator,
358 ExtensionInstallPrompt::Delegate* delegate, 357 ExtensionInstallPrompt::Delegate* delegate,
359 const ExtensionInstallPrompt::Prompt& prompt) { 358 const ExtensionInstallPrompt::Prompt& prompt) {
360 BrowserWindow* browser_window = browser->window(); 359 views::Widget::CreateWindowWithParent(
361 if (!browser_window) { 360 new ExtensionInstallDialogView(navigator, delegate, prompt),
362 delegate->InstallUIAbort(false); 361 parent)->Show();
363 return;
364 }
365
366 ExtensionInstallDialogView* dialog = new ExtensionInstallDialogView(
367 browser, delegate, prompt);
368
369 views::Widget* window = views::Widget::CreateWindowWithParent(
370 dialog, browser_window->GetNativeWindow());
371 window->Show();
372 } 362 }
OLDNEW
« no previous file with comments | « chrome/browser/ui/views/browser_dialogs.h ('k') | chrome/browser/ui/views/frame/browser_view.h » ('j') | no next file with comments »

Powered by Google App Engine
This is Rietveld 408576698