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/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" |
(...skipping 57 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
68 image_view->SetImage(*skia_image); | 68 image_view->SetImage(*skia_image); |
69 parent->AddChildView(image_view); | 69 parent->AddChildView(image_view); |
70 } | 70 } |
71 | 71 |
72 } // namespace | 72 } // namespace |
73 | 73 |
74 // Implements the extension installation dialog for TOOLKIT_VIEWS. | 74 // Implements the extension installation dialog for TOOLKIT_VIEWS. |
75 class ExtensionInstallDialogView : public views::DialogDelegateView, | 75 class ExtensionInstallDialogView : public views::DialogDelegateView, |
76 public views::LinkListener { | 76 public views::LinkListener { |
77 public: | 77 public: |
78 ExtensionInstallDialogView(ExtensionInstallUI::Delegate* delegate, | 78 ExtensionInstallDialogView(ExtensionInstallPrompt::Delegate* delegate, |
79 const ExtensionInstallUI::Prompt& prompt); | 79 const ExtensionInstallPrompt::Prompt& prompt); |
80 virtual ~ExtensionInstallDialogView(); | 80 virtual ~ExtensionInstallDialogView(); |
81 | 81 |
82 private: | 82 private: |
83 // views::DialogDelegateView: | 83 // views::DialogDelegateView: |
84 virtual string16 GetDialogButtonLabel(ui::DialogButton button) const OVERRIDE; | 84 virtual string16 GetDialogButtonLabel(ui::DialogButton button) const OVERRIDE; |
85 virtual int GetDefaultDialogButton() const OVERRIDE; | 85 virtual int GetDefaultDialogButton() const OVERRIDE; |
86 virtual bool Cancel() OVERRIDE; | 86 virtual bool Cancel() OVERRIDE; |
87 virtual bool Accept() OVERRIDE; | 87 virtual bool Accept() OVERRIDE; |
88 | 88 |
89 // views::WidgetDelegate: | 89 // views::WidgetDelegate: |
90 virtual ui::ModalType GetModalType() const OVERRIDE; | 90 virtual ui::ModalType GetModalType() const OVERRIDE; |
91 virtual string16 GetWindowTitle() const OVERRIDE; | 91 virtual string16 GetWindowTitle() const OVERRIDE; |
92 virtual views::View* GetContentsView() OVERRIDE; | 92 virtual views::View* GetContentsView() OVERRIDE; |
93 | 93 |
94 // views::LinkListener: | 94 // views::LinkListener: |
95 virtual void LinkClicked(views::Link* source, int event_flags) OVERRIDE; | 95 virtual void LinkClicked(views::Link* source, int event_flags) OVERRIDE; |
96 | 96 |
97 bool is_inline_install() { | 97 bool is_inline_install() { |
98 return prompt_.type() == ExtensionInstallUI::INLINE_INSTALL_PROMPT; | 98 return prompt_.type() == ExtensionInstallPrompt::INLINE_INSTALL_PROMPT; |
99 } | 99 } |
100 | 100 |
101 bool is_bundle_install() { | 101 bool is_bundle_install() { |
102 return prompt_.type() == ExtensionInstallUI::BUNDLE_INSTALL_PROMPT; | 102 return prompt_.type() == ExtensionInstallPrompt::BUNDLE_INSTALL_PROMPT; |
103 } | 103 } |
104 | 104 |
105 ExtensionInstallUI::Delegate* delegate_; | 105 ExtensionInstallPrompt::Delegate* delegate_; |
106 ExtensionInstallUI::Prompt prompt_; | 106 ExtensionInstallPrompt::Prompt prompt_; |
107 | 107 |
108 DISALLOW_COPY_AND_ASSIGN(ExtensionInstallDialogView); | 108 DISALLOW_COPY_AND_ASSIGN(ExtensionInstallDialogView); |
109 }; | 109 }; |
110 | 110 |
111 ExtensionInstallDialogView::ExtensionInstallDialogView( | 111 ExtensionInstallDialogView::ExtensionInstallDialogView( |
112 ExtensionInstallUI::Delegate* delegate, | 112 ExtensionInstallPrompt::Delegate* delegate, |
113 const ExtensionInstallUI::Prompt& prompt) | 113 const ExtensionInstallPrompt::Prompt& prompt) |
114 : delegate_(delegate), | 114 : delegate_(delegate), |
115 prompt_(prompt) { | 115 prompt_(prompt) { |
116 // Possible grid layouts: | 116 // Possible grid layouts: |
117 // Inline install | 117 // Inline install |
118 // w/ permissions no permissions | 118 // w/ permissions no permissions |
119 // +--------------------+------+ +--------------+------+ | 119 // +--------------------+------+ +--------------+------+ |
120 // | heading | icon | | heading | icon | | 120 // | heading | icon | | heading | icon | |
121 // +--------------------| | +--------------| | | 121 // +--------------------| | +--------------| | |
122 // | rating | | | rating | | | 122 // | rating | | | rating | | |
123 // +--------------------| | +--------------+ | | 123 // +--------------------| | +--------------+ | |
(...skipping 220 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
344 prompt_.extension()->id()); | 344 prompt_.extension()->id()); |
345 OpenURLParams params( | 345 OpenURLParams params( |
346 store_url, Referrer(), NEW_FOREGROUND_TAB, content::PAGE_TRANSITION_LINK, | 346 store_url, Referrer(), NEW_FOREGROUND_TAB, content::PAGE_TRANSITION_LINK, |
347 false); | 347 false); |
348 BrowserList::GetLastActive()->OpenURL(params); | 348 BrowserList::GetLastActive()->OpenURL(params); |
349 GetWidget()->Close(); | 349 GetWidget()->Close(); |
350 } | 350 } |
351 | 351 |
352 void ShowExtensionInstallDialogImpl( | 352 void ShowExtensionInstallDialogImpl( |
353 Profile* profile, | 353 Profile* profile, |
354 ExtensionInstallUI::Delegate* delegate, | 354 ExtensionInstallPrompt::Delegate* delegate, |
355 const ExtensionInstallUI::Prompt& prompt) { | 355 const ExtensionInstallPrompt::Prompt& prompt) { |
356 Browser* browser = browser::FindLastActiveWithProfile(profile); | 356 Browser* browser = browser::FindLastActiveWithProfile(profile); |
357 if (!browser) { | 357 if (!browser) { |
358 delegate->InstallUIAbort(false); | 358 delegate->InstallUIAbort(false); |
359 return; | 359 return; |
360 } | 360 } |
361 | 361 |
362 BrowserWindow* browser_window = browser->window(); | 362 BrowserWindow* browser_window = browser->window(); |
363 if (!browser_window) { | 363 if (!browser_window) { |
364 delegate->InstallUIAbort(false); | 364 delegate->InstallUIAbort(false); |
365 return; | 365 return; |
366 } | 366 } |
367 | 367 |
368 ExtensionInstallDialogView* dialog = new ExtensionInstallDialogView( | 368 ExtensionInstallDialogView* dialog = new ExtensionInstallDialogView( |
369 delegate, prompt); | 369 delegate, prompt); |
370 | 370 |
371 views::Widget* window = views::Widget::CreateWindowWithParent( | 371 views::Widget* window = views::Widget::CreateWindowWithParent( |
372 dialog, browser_window->GetNativeWindow()); | 372 dialog, browser_window->GetNativeWindow()); |
373 window->Show(); | 373 window->Show(); |
374 } | 374 } |
OLD | NEW |