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

Side by Side Diff: chrome/browser/views/extensions/extension_install_prompt.cc

Issue 173604: Adds a default icon to the install dialog if the extension (Closed)
Patch Set: Created 11 years, 3 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
« no previous file with comments | « chrome/browser/resources/default_extension_icon_128.png ('k') | no next file » | 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) 2009 The Chromium Authors. All rights reserved. 1 // Copyright (c) 2009 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 "app/l10n_util.h" 5 #include "app/l10n_util.h"
6 #include "base/file_util.h" 6 #include "base/file_util.h"
7 #include "base/rand_util.h" 7 #include "base/rand_util.h"
8 #include "base/string_util.h" 8 #include "base/string_util.h"
9 #include "chrome/browser/browser_list.h" 9 #include "chrome/browser/browser_list.h"
10 #include "chrome/browser/browser_window.h" 10 #include "chrome/browser/browser_window.h"
(...skipping 14 matching lines...) Expand all
25 25
26 const int kRightColumnWidth = 270; 26 const int kRightColumnWidth = 270;
27 const int kIconSize = 85; 27 const int kIconSize = 85;
28 28
29 // Implements the extension installation prompt for Windows. 29 // Implements the extension installation prompt for Windows.
30 class InstallDialogContent : public views::View, public views::DialogDelegate { 30 class InstallDialogContent : public views::View, public views::DialogDelegate {
31 public: 31 public:
32 InstallDialogContent(ExtensionInstallUI::Delegate* delegate, 32 InstallDialogContent(ExtensionInstallUI::Delegate* delegate,
33 Extension* extension, SkBitmap* icon, const std::wstring& warning_text) 33 Extension* extension, SkBitmap* icon, const std::wstring& warning_text)
34 : delegate_(delegate), icon_(NULL) { 34 : delegate_(delegate), icon_(NULL) {
35 if (icon) { 35 icon_ = new views::ImageView();
36 icon_ = new views::ImageView(); 36 icon_->SetImageSize(gfx::Size(kIconSize, kIconSize));
37 icon_->SetImageSize(gfx::Size(kIconSize, kIconSize)); 37 icon_->SetImage(*icon);
38 icon_->SetImage(*icon); 38 AddChildView(icon_);
39 AddChildView(icon_);
40 }
41 39
42 heading_ = new views::Label( 40 heading_ = new views::Label(
43 l10n_util::GetStringF(IDS_EXTENSION_PROMPT_HEADING, 41 l10n_util::GetStringF(IDS_EXTENSION_PROMPT_HEADING,
44 UTF8ToWide(extension->name()))); 42 UTF8ToWide(extension->name())));
45 heading_->SetFont(heading_->GetFont().DeriveFont(1, gfx::Font::BOLD)); 43 heading_->SetFont(heading_->GetFont().DeriveFont(1, gfx::Font::BOLD));
46 heading_->SetMultiLine(true); 44 heading_->SetMultiLine(true);
47 heading_->SetHorizontalAlignment(views::Label::ALIGN_LEFT); 45 heading_->SetHorizontalAlignment(views::Label::ALIGN_LEFT);
48 AddChildView(heading_); 46 AddChildView(heading_);
49 47
50 warning_ = new views::Label(warning_text); 48 warning_ = new views::Label(warning_text);
(...skipping 35 matching lines...) Expand 10 before | Expand all | Expand 10 after
86 // WindowDelegate 84 // WindowDelegate
87 virtual bool IsModal() const { return true; } 85 virtual bool IsModal() const { return true; }
88 virtual std::wstring GetWindowTitle() const { 86 virtual std::wstring GetWindowTitle() const {
89 return l10n_util::GetString(IDS_EXTENSION_PROMPT_TITLE); 87 return l10n_util::GetString(IDS_EXTENSION_PROMPT_TITLE);
90 } 88 }
91 virtual views::View* GetContentsView() { return this; } 89 virtual views::View* GetContentsView() { return this; }
92 90
93 // View 91 // View
94 virtual gfx::Size GetPreferredSize() { 92 virtual gfx::Size GetPreferredSize() {
95 int width = kRightColumnWidth + kPanelHorizMargin + kPanelHorizMargin; 93 int width = kRightColumnWidth + kPanelHorizMargin + kPanelHorizMargin;
96 94 width += kIconSize;
97 if (icon_) { 95 width += kPanelHorizMargin;
98 width += kIconSize;
99 width += kPanelHorizMargin;
100 }
101 96
102 int height = kPanelVertMargin * 2; 97 int height = kPanelVertMargin * 2;
103 height += heading_->GetHeightForWidth(kRightColumnWidth); 98 height += heading_->GetHeightForWidth(kRightColumnWidth);
104 height += kPanelVertMargin; 99 height += kPanelVertMargin;
105 height += warning_->GetHeightForWidth(kRightColumnWidth); 100 height += warning_->GetHeightForWidth(kRightColumnWidth);
106 height += kPanelVertMargin; 101 height += kPanelVertMargin;
107 102
108 return gfx::Size(width, std::max(height, kIconSize)); 103 return gfx::Size(width, std::max(height, kIconSize + kPanelVertMargin * 2));
109 } 104 }
110 105
111 virtual void Layout() { 106 virtual void Layout() {
112 int x = kPanelHorizMargin; 107 int x = kPanelHorizMargin;
113 int y = kPanelVertMargin; 108 int y = kPanelVertMargin;
114 109
115 if (icon_) { 110 icon_->SetBounds(x, y, kIconSize, kIconSize);
116 icon_->SetBounds(x, y, kIconSize, kIconSize); 111 x += kIconSize;
117 x += kIconSize; 112 x += kPanelHorizMargin;
118 x += kPanelHorizMargin;
119 }
120 113
121 heading_->SizeToFit(kRightColumnWidth); 114 heading_->SizeToFit(kRightColumnWidth);
122 heading_->SetX(x); 115 heading_->SetX(x);
123 heading_->SetY(y); 116 heading_->SetY(y);
124 y += heading_->height(); 117 y += heading_->height();
125 118
126 y += kPanelVertMargin; 119 y += kPanelVertMargin;
127 120
128 warning_->SizeToFit(kRightColumnWidth); 121 warning_->SizeToFit(kRightColumnWidth);
129 warning_->SetX(x); 122 warning_->SetX(x);
(...skipping 25 matching lines...) Expand all
155 BrowserWindow* window = browser->window(); 148 BrowserWindow* window = browser->window();
156 if (!window) { 149 if (!window) {
157 delegate->AbortInstall(); 150 delegate->AbortInstall();
158 return; 151 return;
159 } 152 }
160 153
161 views::Window::CreateChromeWindow(window->GetNativeHandle(), gfx::Rect(), 154 views::Window::CreateChromeWindow(window->GetNativeHandle(), gfx::Rect(),
162 new InstallDialogContent(delegate, extension, icon, 155 new InstallDialogContent(delegate, extension, icon,
163 warning_text))->Show(); 156 warning_text))->Show();
164 } 157 }
OLDNEW
« no previous file with comments | « chrome/browser/resources/default_extension_icon_128.png ('k') | no next file » | no next file with comments »

Powered by Google App Engine
This is Rietveld 408576698