OLD | NEW |
---|---|
1 // Copyright (c) 2011 The Chromium Authors. All rights reserved. | 1 // Copyright (c) 2011 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_installed_bubble.h" | 5 #include "chrome/browser/ui/views/extensions/extension_installed_bubble.h" |
6 | 6 |
7 #include <algorithm> | 7 #include <algorithm> |
8 | 8 |
9 #include "base/i18n/rtl.h" | 9 #include "base/i18n/rtl.h" |
10 #include "base/message_loop.h" | 10 #include "base/message_loop.h" |
11 #include "base/utf_string_conversions.h" | 11 #include "base/utf_string_conversions.h" |
12 #include "chrome/browser/extensions/extension_install_ui.h" | |
12 #include "chrome/browser/profiles/profile.h" | 13 #include "chrome/browser/profiles/profile.h" |
13 #include "chrome/browser/ui/browser.h" | 14 #include "chrome/browser/ui/browser.h" |
14 #include "chrome/browser/ui/browser_window.h" | 15 #include "chrome/browser/ui/browser_window.h" |
15 #include "chrome/browser/ui/views/browser_actions_container.h" | 16 #include "chrome/browser/ui/views/browser_actions_container.h" |
16 #include "chrome/browser/ui/views/frame/browser_view.h" | 17 #include "chrome/browser/ui/views/frame/browser_view.h" |
17 #include "chrome/browser/ui/views/location_bar/location_bar_view.h" | 18 #include "chrome/browser/ui/views/location_bar/location_bar_view.h" |
19 #include "chrome/browser/ui/views/tabs/tab_strip.h" | |
18 #include "chrome/browser/ui/views/toolbar_view.h" | 20 #include "chrome/browser/ui/views/toolbar_view.h" |
19 #include "chrome/common/chrome_notification_types.h" | 21 #include "chrome/common/chrome_notification_types.h" |
20 #include "chrome/common/extensions/extension.h" | 22 #include "chrome/common/extensions/extension.h" |
21 #include "chrome/common/extensions/extension_action.h" | 23 #include "chrome/common/extensions/extension_action.h" |
22 #include "content/common/notification_details.h" | 24 #include "content/common/notification_details.h" |
23 #include "content/common/notification_source.h" | 25 #include "content/common/notification_source.h" |
24 #include "grit/generated_resources.h" | 26 #include "grit/generated_resources.h" |
25 #include "grit/theme_resources_standard.h" | 27 #include "grit/theme_resources_standard.h" |
26 #include "ui/base/l10n/l10n_util.h" | 28 #include "ui/base/l10n/l10n_util.h" |
27 #include "ui/base/resource/resource_bundle.h" | 29 #include "ui/base/resource/resource_bundle.h" |
28 #include "views/controls/button/image_button.h" | 30 #include "views/controls/button/image_button.h" |
29 #include "views/controls/image_view.h" | 31 #include "views/controls/image_view.h" |
30 #include "views/controls/label.h" | 32 #include "views/controls/label.h" |
33 #include "views/controls/link.h" | |
34 #include "views/controls/link_listener.h" | |
31 #include "views/layout/layout_constants.h" | 35 #include "views/layout/layout_constants.h" |
32 #include "views/view.h" | 36 #include "views/view.h" |
33 | 37 |
34 namespace { | 38 namespace { |
35 | 39 |
36 const int kIconSize = 43; | 40 const int kIconSize = 43; |
37 | 41 |
38 const int kRightColumnWidth = 285; | 42 const int kRightColumnWidth = 285; |
39 | 43 |
40 // The Bubble uses a BubbleBorder which adds about 6 pixels of whitespace | 44 // The Bubble uses a BubbleBorder which adds about 6 pixels of whitespace |
(...skipping 30 matching lines...) Expand all Loading... | |
71 Profile* profile) { | 75 Profile* profile) { |
72 ExtensionInstalledBubble::Show(extension, browser, icon); | 76 ExtensionInstalledBubble::Show(extension, browser, icon); |
73 } | 77 } |
74 | 78 |
75 } // namespace browser | 79 } // namespace browser |
76 | 80 |
77 // InstalledBubbleContent is the content view which is placed in the | 81 // InstalledBubbleContent is the content view which is placed in the |
78 // ExtensionInstalledBubble. It displays the install icon and explanatory | 82 // ExtensionInstalledBubble. It displays the install icon and explanatory |
79 // text about the installed extension. | 83 // text about the installed extension. |
80 class InstalledBubbleContent : public views::View, | 84 class InstalledBubbleContent : public views::View, |
81 public views::ButtonListener { | 85 public views::ButtonListener, |
86 public views::LinkListener { | |
82 public: | 87 public: |
83 InstalledBubbleContent(const Extension* extension, | 88 InstalledBubbleContent(Browser* browser, |
89 const Extension* extension, | |
84 ExtensionInstalledBubble::BubbleType type, | 90 ExtensionInstalledBubble::BubbleType type, |
85 SkBitmap* icon) | 91 SkBitmap* icon) |
86 : bubble_(NULL), | 92 : browser_(browser), |
93 extension_id_(extension->id()), | |
94 bubble_(NULL), | |
87 type_(type), | 95 type_(type), |
88 info_(NULL) { | 96 info_(NULL) { |
89 ResourceBundle& rb = ResourceBundle::GetSharedInstance(); | 97 ResourceBundle& rb = ResourceBundle::GetSharedInstance(); |
90 const gfx::Font& font = rb.GetFont(ResourceBundle::BaseFont); | 98 const gfx::Font& font = rb.GetFont(ResourceBundle::BaseFont); |
91 | 99 |
92 // Scale down to 43x43, but allow smaller icons (don't scale up). | 100 // Scale down to 43x43, but allow smaller icons (don't scale up). |
93 gfx::Size size(icon->width(), icon->height()); | 101 gfx::Size size(icon->width(), icon->height()); |
94 if (size.width() > kIconSize || size.height() > kIconSize) | 102 if (size.width() > kIconSize || size.height() > kIconSize) |
95 size = gfx::Size(kIconSize, kIconSize); | 103 size = gfx::Size(kIconSize, kIconSize); |
96 icon_ = new views::ImageView(); | 104 icon_ = new views::ImageView(); |
97 icon_->SetImageSize(size); | 105 icon_->SetImageSize(size); |
98 icon_->SetImage(*icon); | 106 icon_->SetImage(*icon); |
99 AddChildView(icon_); | 107 AddChildView(icon_); |
100 | 108 |
101 string16 extension_name = UTF8ToUTF16(extension->name()); | 109 string16 extension_name = UTF8ToUTF16(extension->name()); |
102 base::i18n::AdjustStringForLocaleDirection(&extension_name); | 110 base::i18n::AdjustStringForLocaleDirection(&extension_name); |
103 heading_ = new views::Label(UTF16ToWide( | 111 heading_ = new views::Label(UTF16ToWide( |
104 l10n_util::GetStringFUTF16(IDS_EXTENSION_INSTALLED_HEADING, | 112 l10n_util::GetStringFUTF16(IDS_EXTENSION_INSTALLED_HEADING, |
105 extension_name))); | 113 extension_name))); |
106 heading_->SetFont(rb.GetFont(ResourceBundle::MediumFont)); | 114 heading_->SetFont(rb.GetFont(ResourceBundle::MediumFont)); |
107 heading_->SetMultiLine(true); | 115 heading_->SetMultiLine(true); |
108 heading_->SetHorizontalAlignment(views::Label::ALIGN_LEFT); | 116 heading_->SetHorizontalAlignment(views::Label::ALIGN_LEFT); |
109 AddChildView(heading_); | 117 AddChildView(heading_); |
110 | 118 |
111 if (type_ == ExtensionInstalledBubble::PAGE_ACTION) { | 119 if (type_ == ExtensionInstalledBubble::PAGE_ACTION) { |
sky
2011/08/03 22:23:24
nit: seems weird to have three separate ifs for th
asargent_no_longer_on_chrome
2011/08/04 00:00:16
Good suggestion - that looks a little cleaner.
| |
112 info_ = new views::Label(UTF16ToWide(l10n_util::GetStringUTF16( | 120 info_ = new views::Label(UTF16ToWide(l10n_util::GetStringUTF16( |
113 IDS_EXTENSION_INSTALLED_PAGE_ACTION_INFO))); | 121 IDS_EXTENSION_INSTALLED_PAGE_ACTION_INFO))); |
114 info_->SetFont(font); | 122 info_->SetFont(font); |
115 info_->SetMultiLine(true); | 123 info_->SetMultiLine(true); |
116 info_->SetHorizontalAlignment(views::Label::ALIGN_LEFT); | 124 info_->SetHorizontalAlignment(views::Label::ALIGN_LEFT); |
117 AddChildView(info_); | 125 AddChildView(info_); |
118 } | 126 } |
119 | 127 |
120 if (type_ == ExtensionInstalledBubble::OMNIBOX_KEYWORD) { | 128 if (type_ == ExtensionInstalledBubble::OMNIBOX_KEYWORD) { |
121 info_ = new views::Label(UTF16ToWide(l10n_util::GetStringFUTF16( | 129 info_ = new views::Label(UTF16ToWide(l10n_util::GetStringFUTF16( |
122 IDS_EXTENSION_INSTALLED_OMNIBOX_KEYWORD_INFO, | 130 IDS_EXTENSION_INSTALLED_OMNIBOX_KEYWORD_INFO, |
123 UTF8ToUTF16(extension->omnibox_keyword())))); | 131 UTF8ToUTF16(extension->omnibox_keyword())))); |
124 info_->SetFont(font); | 132 info_->SetFont(font); |
125 info_->SetMultiLine(true); | 133 info_->SetMultiLine(true); |
126 info_->SetHorizontalAlignment(views::Label::ALIGN_LEFT); | 134 info_->SetHorizontalAlignment(views::Label::ALIGN_LEFT); |
127 AddChildView(info_); | 135 AddChildView(info_); |
128 } | 136 } |
129 | 137 |
130 manage_ = new views::Label(UTF16ToWide( | 138 if (type_ == ExtensionInstalledBubble::APP) { |
131 l10n_util::GetStringUTF16(IDS_EXTENSION_INSTALLED_MANAGE_INFO))); | 139 views::Link* link = new views::Link(UTF16ToWide(l10n_util::GetStringUTF16( |
132 manage_->SetFont(font); | 140 IDS_EXTENSION_INSTALLED_APP_INFO))); |
133 manage_->SetMultiLine(true); | 141 link->set_listener(this); |
134 manage_->SetHorizontalAlignment(views::Label::ALIGN_LEFT); | 142 manage_ = link; |
135 AddChildView(manage_); | 143 manage_->SetFont(font); |
144 manage_->SetMultiLine(true); | |
145 manage_->SetHorizontalAlignment(views::Label::ALIGN_LEFT); | |
146 AddChildView(manage_); | |
147 } else { | |
148 manage_ = new views::Label(UTF16ToWide( | |
149 l10n_util::GetStringUTF16(IDS_EXTENSION_INSTALLED_MANAGE_INFO))); | |
150 manage_->SetFont(font); | |
151 manage_->SetMultiLine(true); | |
152 manage_->SetHorizontalAlignment(views::Label::ALIGN_LEFT); | |
153 AddChildView(manage_); | |
154 } | |
136 | 155 |
137 close_button_ = new views::ImageButton(this); | 156 close_button_ = new views::ImageButton(this); |
138 close_button_->SetImage(views::CustomButton::BS_NORMAL, | 157 close_button_->SetImage(views::CustomButton::BS_NORMAL, |
139 rb.GetBitmapNamed(IDR_CLOSE_BAR)); | 158 rb.GetBitmapNamed(IDR_CLOSE_BAR)); |
140 close_button_->SetImage(views::CustomButton::BS_HOT, | 159 close_button_->SetImage(views::CustomButton::BS_HOT, |
141 rb.GetBitmapNamed(IDR_CLOSE_BAR_H)); | 160 rb.GetBitmapNamed(IDR_CLOSE_BAR_H)); |
142 close_button_->SetImage(views::CustomButton::BS_PUSHED, | 161 close_button_->SetImage(views::CustomButton::BS_PUSHED, |
143 rb.GetBitmapNamed(IDR_CLOSE_BAR_P)); | 162 rb.GetBitmapNamed(IDR_CLOSE_BAR_P)); |
144 AddChildView(close_button_); | 163 AddChildView(close_button_); |
145 } | 164 } |
146 | 165 |
147 void set_bubble(Bubble* bubble) { bubble_ = bubble; } | 166 void set_bubble(Bubble* bubble) { bubble_ = bubble; } |
148 | 167 |
149 virtual void ButtonPressed( | 168 virtual void ButtonPressed( |
150 views::Button* sender, | 169 views::Button* sender, |
151 const views::Event& event) { | 170 const views::Event& event) { |
152 if (sender == close_button_) { | 171 if (sender == close_button_) { |
153 bubble_->set_fade_away_on_close(true); | 172 bubble_->set_fade_away_on_close(true); |
154 GetWidget()->Close(); | 173 GetWidget()->Close(); |
155 } else { | 174 } else { |
156 NOTREACHED() << "Unknown view"; | 175 NOTREACHED() << "Unknown view"; |
157 } | 176 } |
158 } | 177 } |
159 | 178 |
179 // Implements the views::LinkListener interface. | |
180 virtual void LinkClicked(views::Link* source, int event_flags) OVERRIDE { | |
181 GetWidget()->Close(); | |
182 ExtensionInstallUI::OpenAppInstalledNTP(browser_, extension_id_); | |
183 }; | |
sky
2011/08/03 22:23:24
nit: no ;
asargent_no_longer_on_chrome
2011/08/04 00:00:16
oops! Done.
| |
184 | |
160 private: | 185 private: |
161 virtual gfx::Size GetPreferredSize() { | 186 virtual gfx::Size GetPreferredSize() { |
162 int width = kHorizOuterMargin; | 187 int width = kHorizOuterMargin; |
163 width += kIconSize; | 188 width += kIconSize; |
164 width += views::kPanelHorizMargin; | 189 width += views::kPanelHorizMargin; |
165 width += kRightColumnWidth; | 190 width += kRightColumnWidth; |
166 width += 2 * views::kPanelHorizMargin; | 191 width += 2 * views::kPanelHorizMargin; |
167 width += kHorizOuterMargin; | 192 width += kHorizOuterMargin; |
168 | 193 |
169 int height = kVertOuterMargin; | 194 int height = kVertOuterMargin; |
170 height += heading_->GetHeightForWidth(kRightColumnWidth); | 195 height += heading_->GetHeightForWidth(kRightColumnWidth); |
171 height += kVertInnerMargin; | 196 height += kVertInnerMargin; |
172 if (type_ == ExtensionInstalledBubble::PAGE_ACTION || | 197 if (info_) { |
173 type_ == ExtensionInstalledBubble::OMNIBOX_KEYWORD) { | |
174 height += info_->GetHeightForWidth(kRightColumnWidth); | 198 height += info_->GetHeightForWidth(kRightColumnWidth); |
175 height += kVertInnerMargin; | 199 height += kVertInnerMargin; |
176 } | 200 } |
177 height += manage_->GetHeightForWidth(kRightColumnWidth); | 201 height += manage_->GetHeightForWidth(kRightColumnWidth); |
178 height += kVertOuterMargin; | 202 height += kVertOuterMargin; |
179 | 203 |
180 return gfx::Size(width, std::max(height, kIconSize + 2 * kVertOuterMargin)); | 204 return gfx::Size(width, std::max(height, kIconSize + 2 * kVertOuterMargin)); |
181 } | 205 } |
182 | 206 |
183 virtual void Layout() { | 207 virtual void Layout() { |
184 int x = kHorizOuterMargin; | 208 int x = kHorizOuterMargin; |
185 int y = kVertOuterMargin; | 209 int y = kVertOuterMargin; |
186 | 210 |
187 icon_->SetBounds(x, y, kIconSize, kIconSize); | 211 icon_->SetBounds(x, y, kIconSize, kIconSize); |
188 x += kIconSize; | 212 x += kIconSize; |
189 x += views::kPanelHorizMargin; | 213 x += views::kPanelHorizMargin; |
190 | 214 |
191 y += kRightcolumnVerticalShift; | 215 y += kRightcolumnVerticalShift; |
192 heading_->SizeToFit(kRightColumnWidth); | 216 heading_->SizeToFit(kRightColumnWidth); |
193 heading_->SetX(x); | 217 heading_->SetX(x); |
194 heading_->SetY(y); | 218 heading_->SetY(y); |
195 y += heading_->height(); | 219 y += heading_->height(); |
196 y += kVertInnerMargin; | 220 y += kVertInnerMargin; |
197 | 221 |
198 if (type_ == ExtensionInstalledBubble::PAGE_ACTION || | 222 if (info_) { |
199 type_ == ExtensionInstalledBubble::OMNIBOX_KEYWORD) { | |
200 info_->SizeToFit(kRightColumnWidth); | 223 info_->SizeToFit(kRightColumnWidth); |
201 info_->SetX(x); | 224 info_->SetX(x); |
202 info_->SetY(y); | 225 info_->SetY(y); |
203 y += info_->height(); | 226 y += info_->height(); |
204 y += kVertInnerMargin; | 227 y += kVertInnerMargin; |
205 } | 228 } |
206 | 229 |
207 manage_->SizeToFit(kRightColumnWidth); | 230 manage_->SizeToFit(kRightColumnWidth); |
208 manage_->SetX(x); | 231 manage_->SetX(x); |
209 manage_->SetY(y); | 232 manage_->SetY(y); |
210 y += manage_->height(); | 233 y += manage_->height(); |
211 y += kVertInnerMargin; | 234 y += kVertInnerMargin; |
212 | 235 |
213 gfx::Size sz; | 236 gfx::Size sz; |
214 x += kRightColumnWidth + 2 * views::kPanelHorizMargin + kHorizOuterMargin - | 237 x += kRightColumnWidth + 2 * views::kPanelHorizMargin + kHorizOuterMargin - |
215 close_button_->GetPreferredSize().width(); | 238 close_button_->GetPreferredSize().width(); |
216 y = kVertOuterMargin; | 239 y = kVertOuterMargin; |
217 sz = close_button_->GetPreferredSize(); | 240 sz = close_button_->GetPreferredSize(); |
218 // x-1 & y-1 is just slop to get the close button visually aligned with the | 241 // x-1 & y-1 is just slop to get the close button visually aligned with the |
219 // title text and bubble arrow. | 242 // title text and bubble arrow. |
220 close_button_->SetBounds(x - 1, y - 1, sz.width(), sz.height()); | 243 close_button_->SetBounds(x - 1, y - 1, sz.width(), sz.height()); |
221 } | 244 } |
222 | 245 |
246 // The browser we're associated with. | |
247 Browser* browser_; | |
248 | |
249 // The id of the extension just installed. | |
250 std::string extension_id_; | |
sky
2011/08/03 22:23:24
nit: const
asargent_no_longer_on_chrome
2011/08/04 00:00:16
Done.
| |
251 | |
223 // The Bubble showing us. | 252 // The Bubble showing us. |
224 Bubble* bubble_; | 253 Bubble* bubble_; |
225 | 254 |
226 ExtensionInstalledBubble::BubbleType type_; | 255 ExtensionInstalledBubble::BubbleType type_; |
227 views::ImageView* icon_; | 256 views::ImageView* icon_; |
228 views::Label* heading_; | 257 views::Label* heading_; |
229 views::Label* info_; | 258 views::Label* info_; |
230 views::Label* manage_; | 259 views::Label* manage_; |
231 views::ImageButton* close_button_; | 260 views::ImageButton* close_button_; |
232 | 261 |
233 DISALLOW_COPY_AND_ASSIGN(InstalledBubbleContent); | 262 DISALLOW_COPY_AND_ASSIGN(InstalledBubbleContent); |
234 }; | 263 }; |
235 | 264 |
236 void ExtensionInstalledBubble::Show(const Extension* extension, | 265 void ExtensionInstalledBubble::Show(const Extension* extension, |
237 Browser *browser, | 266 Browser *browser, |
238 const SkBitmap& icon) { | 267 const SkBitmap& icon) { |
239 new ExtensionInstalledBubble(extension, browser, icon); | 268 new ExtensionInstalledBubble(extension, browser, icon); |
240 } | 269 } |
241 | 270 |
242 ExtensionInstalledBubble::ExtensionInstalledBubble(const Extension* extension, | 271 ExtensionInstalledBubble::ExtensionInstalledBubble(const Extension* extension, |
243 Browser *browser, | 272 Browser *browser, |
244 const SkBitmap& icon) | 273 const SkBitmap& icon) |
245 : extension_(extension), | 274 : extension_(extension), |
246 browser_(browser), | 275 browser_(browser), |
247 icon_(icon), | 276 icon_(icon), |
248 animation_wait_retries_(0) { | 277 animation_wait_retries_(0) { |
249 AddRef(); // Balanced in BubbleClosing. | 278 AddRef(); // Balanced in BubbleClosing. |
250 | 279 |
251 if (!extension_->omnibox_keyword().empty()) { | 280 if (extension->is_app()) { |
281 type_ = APP; | |
282 } else if (!extension_->omnibox_keyword().empty()) { | |
252 type_ = OMNIBOX_KEYWORD; | 283 type_ = OMNIBOX_KEYWORD; |
253 } else if (extension_->browser_action()) { | 284 } else if (extension_->browser_action()) { |
254 type_ = BROWSER_ACTION; | 285 type_ = BROWSER_ACTION; |
255 } else if (extension->page_action() && | 286 } else if (extension->page_action() && |
256 !extension->page_action()->default_icon_path().empty()) { | 287 !extension->page_action()->default_icon_path().empty()) { |
257 type_ = PAGE_ACTION; | 288 type_ = PAGE_ACTION; |
258 } else { | 289 } else { |
259 type_ = GENERIC; | 290 type_ = GENERIC; |
260 } | 291 } |
261 | 292 |
(...skipping 29 matching lines...) Expand all Loading... | |
291 } else { | 322 } else { |
292 NOTREACHED() << L"Received unexpected notification"; | 323 NOTREACHED() << L"Received unexpected notification"; |
293 } | 324 } |
294 } | 325 } |
295 | 326 |
296 void ExtensionInstalledBubble::ShowInternal() { | 327 void ExtensionInstalledBubble::ShowInternal() { |
297 BrowserView* browser_view = BrowserView::GetBrowserViewForNativeWindow( | 328 BrowserView* browser_view = BrowserView::GetBrowserViewForNativeWindow( |
298 browser_->window()->GetNativeHandle()); | 329 browser_->window()->GetNativeHandle()); |
299 | 330 |
300 const views::View* reference_view = NULL; | 331 const views::View* reference_view = NULL; |
301 if (type_ == BROWSER_ACTION) { | 332 if (type_ == APP) { |
333 AbstractTabStripView* tabstrip = browser_view->tabstrip(); | |
sky
2011/08/03 22:23:24
There are two cases that are probably worth checki
asargent_no_longer_on_chrome
2011/08/04 00:00:16
Thanks for pointing this out! I've modified the CL
| |
334 if (tabstrip->GetNewTabButton()) { | |
335 reference_view = tabstrip->GetNewTabButton(); | |
336 } else { | |
337 // If this tab strip doesn't have a new tab button, just have the bubble | |
338 // point at the tab strip. | |
339 reference_view = tabstrip; | |
340 } | |
341 } else if (type_ == BROWSER_ACTION) { | |
302 BrowserActionsContainer* container = | 342 BrowserActionsContainer* container = |
303 browser_view->GetToolbarView()->browser_actions(); | 343 browser_view->GetToolbarView()->browser_actions(); |
304 if (container->animating() && | 344 if (container->animating() && |
305 animation_wait_retries_++ < kAnimationWaitMaxRetry) { | 345 animation_wait_retries_++ < kAnimationWaitMaxRetry) { |
306 // We don't know where the view will be until the container has stopped | 346 // We don't know where the view will be until the container has stopped |
307 // animating, so check back in a little while. | 347 // animating, so check back in a little while. |
308 MessageLoopForUI::current()->PostDelayedTask( | 348 MessageLoopForUI::current()->PostDelayedTask( |
309 FROM_HERE, NewRunnableMethod(this, | 349 FROM_HERE, NewRunnableMethod(this, |
310 &ExtensionInstalledBubble::ShowInternal), kAnimationWaitTime); | 350 &ExtensionInstalledBubble::ShowInternal), kAnimationWaitTime); |
311 return; | 351 return; |
(...skipping 33 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... | |
345 | 385 |
346 // For omnibox keyword bubbles, move the arrow to point to the left edge | 386 // For omnibox keyword bubbles, move the arrow to point to the left edge |
347 // of the omnibox, just to the right of the icon. | 387 // of the omnibox, just to the right of the icon. |
348 if (type_ == OMNIBOX_KEYWORD) { | 388 if (type_ == OMNIBOX_KEYWORD) { |
349 bounds.set_origin( | 389 bounds.set_origin( |
350 browser_view->GetLocationBarView()->GetLocationEntryOrigin()); | 390 browser_view->GetLocationBarView()->GetLocationEntryOrigin()); |
351 bounds.set_width(0); | 391 bounds.set_width(0); |
352 arrow_location = BubbleBorder::TOP_LEFT; | 392 arrow_location = BubbleBorder::TOP_LEFT; |
353 } | 393 } |
354 | 394 |
355 bubble_content_ = new InstalledBubbleContent(extension_, type_, &icon_); | 395 bubble_content_ = new InstalledBubbleContent( |
396 browser_, extension_, type_, &icon_); | |
356 Bubble* bubble = Bubble::Show(browser_view->GetWidget(), bounds, | 397 Bubble* bubble = Bubble::Show(browser_view->GetWidget(), bounds, |
357 arrow_location, bubble_content_, this); | 398 arrow_location, bubble_content_, this); |
358 bubble_content_->set_bubble(bubble); | 399 bubble_content_->set_bubble(bubble); |
359 } | 400 } |
360 | 401 |
361 // BubbleDelegate | 402 // BubbleDelegate |
362 void ExtensionInstalledBubble::BubbleClosing(Bubble* bubble, | 403 void ExtensionInstalledBubble::BubbleClosing(Bubble* bubble, |
363 bool closed_by_escape) { | 404 bool closed_by_escape) { |
364 if (extension_ && type_ == PAGE_ACTION) { | 405 if (extension_ && type_ == PAGE_ACTION) { |
365 BrowserView* browser_view = BrowserView::GetBrowserViewForNativeWindow( | 406 BrowserView* browser_view = BrowserView::GetBrowserViewForNativeWindow( |
366 browser_->window()->GetNativeHandle()); | 407 browser_->window()->GetNativeHandle()); |
367 browser_view->GetLocationBarView()->SetPreviewEnabledPageAction( | 408 browser_view->GetLocationBarView()->SetPreviewEnabledPageAction( |
368 extension_->page_action(), | 409 extension_->page_action(), |
369 false); // preview_enabled | 410 false); // preview_enabled |
370 } | 411 } |
371 | 412 |
372 Release(); // Balanced in ctor. | 413 Release(); // Balanced in ctor. |
373 } | 414 } |
374 | 415 |
375 bool ExtensionInstalledBubble::CloseOnEscape() { | 416 bool ExtensionInstalledBubble::CloseOnEscape() { |
376 return true; | 417 return true; |
377 } | 418 } |
378 | 419 |
379 bool ExtensionInstalledBubble::FadeInOnShow() { | 420 bool ExtensionInstalledBubble::FadeInOnShow() { |
380 return true; | 421 return true; |
381 } | 422 } |
OLD | NEW |