Chromium Code Reviews| OLD | NEW |
|---|---|
| 1 // Copyright 2013 The Chromium Authors. All rights reserved. | 1 // Copyright 2013 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_view.h" | 5 #include "chrome/browser/ui/views/extensions/extension_installed_bubble_view.h" |
| 6 | 6 |
| 7 #include <algorithm> | 7 #include <algorithm> |
| 8 #include <string> | 8 #include <string> |
| 9 | 9 |
| 10 #include "base/macros.h" | 10 #include "base/macros.h" |
| (...skipping 95 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... | |
| 106 private: | 106 private: |
| 107 views::Label* heading_; | 107 views::Label* heading_; |
| 108 views::LabelButton* close_; | 108 views::LabelButton* close_; |
| 109 | 109 |
| 110 DISALLOW_COPY_AND_ASSIGN(HeadingAndCloseButtonView); | 110 DISALLOW_COPY_AND_ASSIGN(HeadingAndCloseButtonView); |
| 111 }; | 111 }; |
| 112 | 112 |
| 113 } // namespace | 113 } // namespace |
| 114 | 114 |
| 115 ExtensionInstalledBubbleView::ExtensionInstalledBubbleView( | 115 ExtensionInstalledBubbleView::ExtensionInstalledBubbleView( |
| 116 ExtensionInstalledBubble* bubble, | 116 ExtensionInstalledBubble* controller) |
| 117 BubbleReference bubble_reference) | 117 : BubbleDialogDelegateView(nullptr, views::BubbleBorder::TOP_RIGHT), |
| 118 : bubble_(bubble), | |
| 119 bubble_reference_(bubble_reference), | |
| 120 extension_(bubble->extension()), | |
| 121 browser_(bubble->browser()), | |
| 122 type_(bubble->type()), | |
| 123 anchor_position_(bubble->anchor_position()), | |
| 124 close_(nullptr), | 118 close_(nullptr), |
| 125 manage_shortcut_(nullptr) {} | 119 manage_shortcut_(nullptr) {} |
| 126 | 120 |
| 127 ExtensionInstalledBubbleView::~ExtensionInstalledBubbleView() {} | 121 ExtensionInstalledBubbleView::~ExtensionInstalledBubbleView() {} |
| 128 | 122 |
| 129 void ExtensionInstalledBubbleView::UpdateAnchorView() { | 123 void ExtensionInstalledBubbleView::UpdateAnchorView() { |
| 130 BrowserView* browser_view = BrowserView::GetBrowserViewForBrowser(browser_); | 124 BrowserView* browser_view = BrowserView::GetBrowserViewForBrowser(browser()); |
| 131 | 125 |
| 132 views::View* reference_view = nullptr; | 126 views::View* reference_view = nullptr; |
| 133 switch (anchor_position_) { | 127 switch (controller_->anchor_position()) { |
| 134 case ExtensionInstalledBubble::ANCHOR_BROWSER_ACTION: { | 128 case ExtensionInstalledBubble::ANCHOR_BROWSER_ACTION: { |
| 135 BrowserActionsContainer* container = | 129 BrowserActionsContainer* container = |
| 136 browser_view->GetToolbarView()->browser_actions(); | 130 browser_view->GetToolbarView()->browser_actions(); |
| 137 // Hitting this DCHECK means |ShouldShow| failed. | 131 // Hitting this DCHECK means |ShouldShow| failed. |
| 138 DCHECK(!container->animating()); | 132 DCHECK(!container->animating()); |
| 139 | 133 |
| 140 reference_view = container->GetViewForId(extension_->id()); | 134 reference_view = container->GetViewForId(controller_->extension()->id()); |
| 141 // If the view is not visible then it is in the chevron, so point the | 135 // If the view is not visible then it is in the chevron, so point the |
| 142 // install bubble to the chevron instead. If this is an incognito window, | 136 // install bubble to the chevron instead. If this is an incognito window, |
| 143 // both could be invisible. | 137 // both could be invisible. |
| 144 if (!reference_view || !reference_view->visible()) { | 138 if (!reference_view || !reference_view->visible()) { |
| 145 reference_view = container->chevron(); | 139 reference_view = container->chevron(); |
| 146 if (!reference_view || !reference_view->visible()) | 140 if (!reference_view || !reference_view->visible()) |
| 147 reference_view = nullptr; // fall back to app menu below. | 141 reference_view = nullptr; // fall back to app menu below. |
| 148 } | 142 } |
| 149 break; | 143 break; |
| 150 } | 144 } |
| 151 case ExtensionInstalledBubble::ANCHOR_PAGE_ACTION: { | 145 case ExtensionInstalledBubble::ANCHOR_PAGE_ACTION: { |
| 152 LocationBarView* location_bar_view = browser_view->GetLocationBarView(); | 146 LocationBarView* location_bar_view = browser_view->GetLocationBarView(); |
| 153 ExtensionAction* page_action = | 147 ExtensionAction* page_action = |
| 154 extensions::ExtensionActionManager::Get(browser_->profile()) | 148 extensions::ExtensionActionManager::Get(browser()->profile()) |
| 155 ->GetPageAction(*extension_); | 149 ->GetPageAction(*controller_->extension()); |
| 156 location_bar_view->SetPreviewEnabledPageAction(page_action, | 150 location_bar_view->SetPreviewEnabledPageAction(page_action, |
| 157 true); // preview_enabled | 151 true); // preview_enabled |
| 158 reference_view = location_bar_view->GetPageActionView(page_action); | 152 reference_view = location_bar_view->GetPageActionView(page_action); |
| 159 DCHECK(reference_view); | 153 DCHECK(reference_view); |
| 160 break; | 154 break; |
| 161 } | 155 } |
| 162 case ExtensionInstalledBubble::ANCHOR_OMNIBOX: { | 156 case ExtensionInstalledBubble::ANCHOR_OMNIBOX: { |
| 163 LocationBarView* location_bar_view = browser_view->GetLocationBarView(); | 157 // TODO(estade): remove ANCHOR_OMNIBOX. |
| 164 reference_view = location_bar_view; | 158 NOTREACHED(); |
| 165 DCHECK(reference_view); | |
| 166 break; | 159 break; |
| 167 } | 160 } |
| 168 case ExtensionInstalledBubble::ANCHOR_APP_MENU: | 161 case ExtensionInstalledBubble::ANCHOR_APP_MENU: |
| 169 // Will be caught below. | 162 // Will be caught below. |
| 170 break; | 163 break; |
| 171 } | 164 } |
| 172 | 165 |
| 173 // Default case. | 166 // Default case. |
| 174 if (!reference_view) | 167 if (!reference_view) |
| 175 reference_view = browser_view->GetToolbarView()->app_menu_button(); | 168 reference_view = browser_view->GetToolbarView()->app_menu_button(); |
| 176 SetAnchorView(reference_view); | 169 SetAnchorView(reference_view); |
| 177 } | 170 } |
| 178 | 171 |
| 179 views::View* ExtensionInstalledBubbleView::CreateFootnoteView() { | 172 views::View* ExtensionInstalledBubbleView::CreateFootnoteView() { |
| 180 if (!(bubble_->options() & ExtensionInstalledBubble::SIGN_IN_PROMO)) | 173 if (!(controller_->options() & ExtensionInstalledBubble::SIGN_IN_PROMO)) |
| 181 return nullptr; | 174 return nullptr; |
| 182 | 175 |
| 183 return new BubbleSyncPromoView(this, | 176 return new BubbleSyncPromoView(this, |
| 184 IDS_EXTENSION_INSTALLED_SYNC_PROMO_LINK_NEW, | 177 IDS_EXTENSION_INSTALLED_SYNC_PROMO_LINK_NEW, |
| 185 IDS_EXTENSION_INSTALLED_SYNC_PROMO_NEW); | 178 IDS_EXTENSION_INSTALLED_SYNC_PROMO_NEW); |
| 186 } | 179 } |
| 187 | 180 |
| 181 int ExtensionInstalledBubbleView::GetDialogButtons() const { | |
| 182 return ui::DIALOG_BUTTON_NONE; | |
| 183 } | |
| 184 | |
| 188 void ExtensionInstalledBubbleView::WindowClosing() { | 185 void ExtensionInstalledBubbleView::WindowClosing() { |
| 189 if (anchor_position_ == ExtensionInstalledBubble::ANCHOR_PAGE_ACTION) { | 186 if (controller_->anchor_position() == |
| 190 BrowserView* browser_view = BrowserView::GetBrowserViewForBrowser(browser_); | 187 ExtensionInstalledBubble::ANCHOR_PAGE_ACTION) { |
| 188 BrowserView* browser_view = | |
| 189 BrowserView::GetBrowserViewForBrowser(browser()); | |
| 191 browser_view->GetLocationBarView()->SetPreviewEnabledPageAction( | 190 browser_view->GetLocationBarView()->SetPreviewEnabledPageAction( |
| 192 extensions::ExtensionActionManager::Get(browser_->profile()) | 191 extensions::ExtensionActionManager::Get(browser()->profile()) |
| 193 ->GetPageAction(*extension_), | 192 ->GetPageAction(*controller_->extension()), |
| 194 false); // preview_enabled | 193 false); // preview_enabled |
| 195 } | 194 } |
| 196 } | 195 } |
| 197 | 196 |
| 198 gfx::Rect ExtensionInstalledBubbleView::GetAnchorRect() const { | |
| 199 // For omnibox keyword bubbles, move the arrow to point to the left edge | |
| 200 // of the omnibox, just to the right of the icon. | |
| 201 if (type_ == ExtensionInstalledBubble::OMNIBOX_KEYWORD) { | |
| 202 const LocationBarView* location_bar_view = | |
| 203 BrowserView::GetBrowserViewForBrowser(browser_)->GetLocationBarView(); | |
| 204 return gfx::Rect(location_bar_view->GetOmniboxViewOrigin(), | |
| 205 gfx::Size(0, location_bar_view->omnibox_view()->height())); | |
| 206 } | |
| 207 return views::BubbleDelegateView::GetAnchorRect(); | |
| 208 } | |
| 209 | |
| 210 void ExtensionInstalledBubbleView::OnWidgetClosing(views::Widget* widget) { | |
| 211 if (bubble_reference_) { | |
| 212 DCHECK_EQ(widget, GetWidget()); | |
| 213 // A more specific close reason should already be recorded. | |
| 214 // This is the catch-all close reason for this bubble. | |
| 215 bubble_reference_->CloseBubble(BUBBLE_CLOSE_FOCUS_LOST); | |
| 216 } | |
| 217 } | |
| 218 | |
| 219 void ExtensionInstalledBubbleView::OnWidgetActivationChanged( | |
| 220 views::Widget* widget, | |
| 221 bool active) { | |
| 222 if (!active && bubble_reference_ && widget == GetWidget()) | |
| 223 bubble_reference_->CloseBubble(BUBBLE_CLOSE_FOCUS_LOST); | |
| 224 } | |
| 225 | |
| 226 bool ExtensionInstalledBubbleView::AcceleratorPressed( | |
| 227 const ui::Accelerator& accelerator) { | |
| 228 if (!close_on_esc() || accelerator.key_code() != ui::VKEY_ESCAPE) | |
| 229 return false; | |
| 230 DCHECK(bubble_reference_); | |
| 231 bool did_close = bubble_reference_->CloseBubble(BUBBLE_CLOSE_USER_DISMISSED); | |
| 232 DCHECK(did_close); | |
| 233 return true; | |
| 234 } | |
| 235 | |
| 236 void ExtensionInstalledBubbleView::OnSignInLinkClicked() { | 197 void ExtensionInstalledBubbleView::OnSignInLinkClicked() { |
| 237 GetWidget()->Close(); | 198 GetWidget()->Close(); |
| 238 chrome::ShowBrowserSignin( | 199 chrome::ShowBrowserSignin( |
| 239 browser_, | 200 browser(), |
| 240 signin_metrics::AccessPoint::ACCESS_POINT_EXTENSION_INSTALL_BUBBLE); | 201 signin_metrics::AccessPoint::ACCESS_POINT_EXTENSION_INSTALL_BUBBLE); |
| 241 } | 202 } |
| 242 | 203 |
| 243 void ExtensionInstalledBubbleView::ButtonPressed(views::Button* sender, | 204 void ExtensionInstalledBubbleView::ButtonPressed(views::Button* sender, |
| 244 const ui::Event& event) { | 205 const ui::Event& event) { |
| 245 DCHECK_EQ(sender, close_); | 206 DCHECK_EQ(sender, close_); |
| 246 GetWidget()->Close(); | 207 GetWidget()->Close(); |
| 247 } | 208 } |
| 248 | 209 |
| 249 void ExtensionInstalledBubbleView::LinkClicked(views::Link* source, | 210 void ExtensionInstalledBubbleView::LinkClicked(views::Link* source, |
| 250 int event_flags) { | 211 int event_flags) { |
| 251 DCHECK_EQ(manage_shortcut_, source); | 212 DCHECK_EQ(manage_shortcut_, source); |
| 252 GetWidget()->Close(); | 213 GetWidget()->Close(); |
| 253 | 214 |
| 254 std::string configure_url = chrome::kChromeUIExtensionsURL; | 215 std::string configure_url = chrome::kChromeUIExtensionsURL; |
| 255 configure_url += chrome::kExtensionConfigureCommandsSubPage; | 216 configure_url += chrome::kExtensionConfigureCommandsSubPage; |
| 256 chrome::NavigateParams params( | 217 chrome::NavigateParams params( |
| 257 chrome::GetSingletonTabNavigateParams(browser_, GURL(configure_url))); | 218 chrome::GetSingletonTabNavigateParams(browser(), GURL(configure_url))); |
| 258 chrome::Navigate(¶ms); | 219 chrome::Navigate(¶ms); |
| 259 } | 220 } |
| 260 | 221 |
| 261 void ExtensionInstalledBubbleView::InitLayout() { | 222 void ExtensionInstalledBubbleView::Init() { |
| 223 UpdateAnchorView(); | |
| 224 | |
| 262 // The Extension Installed bubble takes on various forms, depending on the | 225 // The Extension Installed bubble takes on various forms, depending on the |
| 263 // type of extension installed. In general, though, they are all similar: | 226 // type of extension installed. In general, though, they are all similar: |
| 264 // | 227 // |
| 265 // ------------------------- | 228 // ------------------------- |
| 266 // | | Heading [X] | | 229 // | | Heading [X] | |
| 267 // | Icon | Info | | 230 // | Icon | Info | |
| 268 // | | Extra info | | 231 // | | Extra info | |
| 269 // ------------------------- | 232 // ------------------------- |
| 270 // | 233 // |
| 271 // Icon and Heading are always shown (as well as the close button). | 234 // Icon and Heading are always shown (as well as the close button). |
| 272 // Info is shown for browser actions, page actions and Omnibox keyword | 235 // Info is shown for browser actions, page actions and Omnibox keyword |
| 273 // extensions and might list keyboard shorcut for the former two types. | 236 // extensions and might list keyboard shorcut for the former two types. |
| 274 // Extra info is... | 237 // Extra info is... |
| 275 // ... for other types, either a description of how to manage the extension | 238 // ... for other types, either a description of how to manage the extension |
| 276 // or a link to configure the keybinding shortcut (if one exists). | 239 // or a link to configure the keybinding shortcut (if one exists). |
| 277 // Extra info can include a promo for signing into sync. | 240 // Extra info can include a promo for signing into sync. |
| 278 | 241 |
| 279 const ExtensionInstalledBubble& bubble = *bubble_; | |
| 280 // The number of rows in the content section of the bubble. | 242 // The number of rows in the content section of the bubble. |
| 281 int main_content_row_count = 1; | 243 int main_content_row_count = 1; |
| 282 if (bubble.options() & ExtensionInstalledBubble::HOW_TO_USE) | 244 if (controller_->options() & ExtensionInstalledBubble::HOW_TO_USE) |
| 283 ++main_content_row_count; | 245 ++main_content_row_count; |
| 284 if (bubble.options() & ExtensionInstalledBubble::SHOW_KEYBINDING) | 246 if (controller_->options() & ExtensionInstalledBubble::SHOW_KEYBINDING) |
| 285 ++main_content_row_count; | 247 ++main_content_row_count; |
| 286 if (bubble.options() & ExtensionInstalledBubble::HOW_TO_MANAGE) | 248 if (controller_->options() & ExtensionInstalledBubble::HOW_TO_MANAGE) |
| 287 ++main_content_row_count; | 249 ++main_content_row_count; |
| 288 | 250 |
| 289 views::GridLayout* layout = new views::GridLayout(this); | 251 views::GridLayout* layout = new views::GridLayout(this); |
| 290 SetLayoutManager(layout); | 252 SetLayoutManager(layout); |
| 291 | 253 |
| 292 const int cs_id = 0; | 254 const int cs_id = 0; |
| 293 | 255 |
| 294 views::ColumnSet* main_cs = layout->AddColumnSet(cs_id); | 256 views::ColumnSet* main_cs = layout->AddColumnSet(cs_id); |
| 295 // Icon column. | 257 // Icon column. |
| 296 main_cs->AddColumn(views::GridLayout::CENTER, views::GridLayout::LEADING, 0, | 258 main_cs->AddColumn(views::GridLayout::CENTER, views::GridLayout::LEADING, 0, |
| 297 views::GridLayout::USE_PREF, 0, 0); | 259 views::GridLayout::USE_PREF, 0, 0); |
| 298 main_cs->AddPaddingColumn(0, views::kUnrelatedControlHorizontalSpacing); | 260 main_cs->AddPaddingColumn(0, views::kUnrelatedControlHorizontalSpacing); |
| 299 // Heading column. | 261 // Heading column. |
| 300 main_cs->AddColumn(views::GridLayout::LEADING, views::GridLayout::LEADING, 0, | 262 main_cs->AddColumn(views::GridLayout::LEADING, views::GridLayout::LEADING, 0, |
| 301 views::GridLayout::FIXED, kRightColumnWidth, 0); | 263 views::GridLayout::FIXED, kRightColumnWidth, 0); |
| 302 | 264 |
| 303 ui::ResourceBundle& rb = ui::ResourceBundle::GetSharedInstance(); | 265 ui::ResourceBundle& rb = ui::ResourceBundle::GetSharedInstance(); |
| 304 const gfx::FontList& font_list = rb.GetFontList(ui::ResourceBundle::BaseFont); | 266 const gfx::FontList& font_list = rb.GetFontList(ui::ResourceBundle::BaseFont); |
| 305 | 267 |
| 306 const SkBitmap& bitmap = bubble.icon(); | 268 const SkBitmap& bitmap = controller_->icon(); |
| 307 // Add the icon (for all options). | 269 // Add the icon (for all options). |
| 308 // Scale down to 43x43, but allow smaller icons (don't scale up). | 270 // Scale down to 43x43, but allow smaller icons (don't scale up). |
| 309 gfx::Size size(bitmap.width(), bitmap.height()); | 271 gfx::Size size(bitmap.width(), bitmap.height()); |
| 310 if (size.width() > kIconSize || size.height() > kIconSize) | 272 if (size.width() > kIconSize || size.height() > kIconSize) |
| 311 size = gfx::Size(kIconSize, kIconSize); | 273 size = gfx::Size(kIconSize, kIconSize); |
| 312 views::ImageView* icon = new views::ImageView(); | 274 views::ImageView* icon = new views::ImageView(); |
| 313 icon->SetImageSize(size); | 275 icon->SetImageSize(size); |
| 314 icon->SetImage(gfx::ImageSkia::CreateFrom1xBitmap(bitmap)); | 276 icon->SetImage(gfx::ImageSkia::CreateFrom1xBitmap(bitmap)); |
| 315 | 277 |
| 316 layout->StartRow(0, cs_id); | 278 layout->StartRow(0, cs_id); |
| 317 layout->AddView(icon, 1, main_content_row_count); | 279 layout->AddView(icon, 1, main_content_row_count); |
| 318 | 280 |
| 319 // Add the heading (for all options). | 281 // Add the heading (for all options). |
| 320 base::string16 extension_name = base::UTF8ToUTF16(extension_->name()); | 282 base::string16 extension_name = |
| 283 base::UTF8ToUTF16(controller_->extension()->name()); | |
| 321 base::i18n::AdjustStringForLocaleDirection(&extension_name); | 284 base::i18n::AdjustStringForLocaleDirection(&extension_name); |
| 322 views::Label* heading = | 285 views::Label* heading = |
| 323 CreateLabel(l10n_util::GetStringFUTF16(IDS_EXTENSION_INSTALLED_HEADING, | 286 CreateLabel(l10n_util::GetStringFUTF16(IDS_EXTENSION_INSTALLED_HEADING, |
| 324 extension_name), | 287 extension_name), |
| 325 rb.GetFontList(ui::ResourceBundle::MediumFont)); | 288 rb.GetFontList(ui::ResourceBundle::MediumFont)); |
| 326 | 289 |
| 327 close_ = views::BubbleFrameView::CreateCloseButton(this); | 290 close_ = views::BubbleFrameView::CreateCloseButton(this); |
| 328 | 291 |
| 329 HeadingAndCloseButtonView* heading_and_close = | 292 HeadingAndCloseButtonView* heading_and_close = |
| 330 new HeadingAndCloseButtonView(heading, close_); | 293 new HeadingAndCloseButtonView(heading, close_); |
| 331 | 294 |
| 332 layout->AddView(heading_and_close); | 295 layout->AddView(heading_and_close); |
| 333 layout->AddPaddingRow(0, views::kRelatedControlVerticalSpacing); | 296 layout->AddPaddingRow(0, views::kRelatedControlVerticalSpacing); |
| 334 | 297 |
| 335 auto add_content_view = [&layout, &cs_id](views::View* view) { | 298 auto add_content_view = [&layout, &cs_id](views::View* view) { |
| 336 layout->StartRow(0, cs_id); | 299 layout->StartRow(0, cs_id); |
| 337 // Skip the icon column. | 300 // Skip the icon column. |
| 338 layout->SkipColumns(1); | 301 layout->SkipColumns(1); |
| 339 layout->AddView(view); | 302 layout->AddView(view); |
| 340 layout->AddPaddingRow(0, views::kRelatedControlVerticalSpacing); | 303 layout->AddPaddingRow(0, views::kRelatedControlVerticalSpacing); |
| 341 }; | 304 }; |
| 342 | 305 |
| 343 if (bubble.options() & ExtensionInstalledBubble::HOW_TO_USE) { | 306 if (controller_->options() & ExtensionInstalledBubble::HOW_TO_USE) { |
| 344 add_content_view(CreateLabel(bubble.GetHowToUseDescription(), font_list)); | 307 add_content_view( |
| 308 CreateLabel(controller_->GetHowToUseDescription(), font_list)); | |
| 345 } | 309 } |
| 346 | 310 |
| 347 if (bubble.options() & ExtensionInstalledBubble::SHOW_KEYBINDING) { | 311 if (controller_->options() & ExtensionInstalledBubble::SHOW_KEYBINDING) { |
| 348 manage_shortcut_ = new views::Link( | 312 manage_shortcut_ = new views::Link( |
| 349 l10n_util::GetStringUTF16(IDS_EXTENSION_INSTALLED_MANAGE_SHORTCUTS)); | 313 l10n_util::GetStringUTF16(IDS_EXTENSION_INSTALLED_MANAGE_SHORTCUTS)); |
| 350 manage_shortcut_->set_listener(this); | 314 manage_shortcut_->set_listener(this); |
| 351 manage_shortcut_->SetUnderline(false); | 315 manage_shortcut_->SetUnderline(false); |
| 352 add_content_view(manage_shortcut_); | 316 add_content_view(manage_shortcut_); |
| 353 } | 317 } |
| 354 | 318 |
| 355 if (bubble.options() & ExtensionInstalledBubble::HOW_TO_MANAGE) { | 319 if (controller_->options() & ExtensionInstalledBubble::HOW_TO_MANAGE) { |
| 356 add_content_view(CreateLabel( | 320 add_content_view(CreateLabel( |
| 357 l10n_util::GetStringUTF16(IDS_EXTENSION_INSTALLED_MANAGE_INFO), | 321 l10n_util::GetStringUTF16(IDS_EXTENSION_INSTALLED_MANAGE_INFO), |
| 358 font_list)); | 322 font_list)); |
| 359 } | 323 } |
| 360 } | 324 } |
| 361 | 325 |
| 362 // Views specific implementation. | 326 // Views specific implementation. |
| 363 bool ExtensionInstalledBubble::ShouldShow() { | 327 bool ExtensionInstalledBubble::ShouldShow() { |
| 364 if (anchor_position() == ANCHOR_BROWSER_ACTION) { | 328 if (anchor_position() == ANCHOR_BROWSER_ACTION) { |
| 365 BrowserActionsContainer* container = | 329 BrowserActionsContainer* container = |
| 366 BrowserView::GetBrowserViewForBrowser(browser()) | 330 BrowserView::GetBrowserViewForBrowser(browser()) |
| 367 ->GetToolbarView() | 331 ->GetToolbarView() |
| 368 ->browser_actions(); | 332 ->browser_actions(); |
| 369 return !container->animating(); | 333 return !container->animating(); |
| 370 } | 334 } |
| 371 return true; | 335 return true; |
| 372 } | 336 } |
| 373 | 337 |
| 338 // NB: This bubble is using the temporarily-deprecated bubble manager interface | |
|
Devlin
2016/04/07 19:02:51
This is deprecated now? I thought it was just add
Evan Stade
2016/04/07 20:02:50
Yes, but it's already been de-staffed (at least te
| |
| 339 // BubbleUi. Do not copy this pattern. | |
| 374 class ExtensionInstalledBubbleUi : public BubbleUi { | 340 class ExtensionInstalledBubbleUi : public BubbleUi { |
| 375 public: | 341 public: |
| 376 explicit ExtensionInstalledBubbleUi(ExtensionInstalledBubble* bubble); | 342 explicit ExtensionInstalledBubbleUi(ExtensionInstalledBubble* bubble); |
| 377 ~ExtensionInstalledBubbleUi() override; | 343 ~ExtensionInstalledBubbleUi() override; |
| 378 | 344 |
| 379 private: | 345 private: |
| 380 // BubbleUi: | 346 // BubbleUi: |
| 381 void Show(BubbleReference bubble_reference) override; | 347 void Show(BubbleReference bubble_reference) override; |
| 382 void Close() override; | 348 void Close() override; |
| 383 void UpdateAnchorPosition() override; | 349 void UpdateAnchorPosition() override; |
| 384 | 350 |
| 385 ExtensionInstalledBubble* bubble_; | 351 ExtensionInstalledBubble* bubble_; |
| 386 ExtensionInstalledBubbleView* delegate_view_; | 352 ExtensionInstalledBubbleView* bubble_view_; |
| 387 | 353 |
| 388 DISALLOW_COPY_AND_ASSIGN(ExtensionInstalledBubbleUi); | 354 DISALLOW_COPY_AND_ASSIGN(ExtensionInstalledBubbleUi); |
| 389 }; | 355 }; |
| 390 | 356 |
| 391 // Implemented here to create the platform specific instance of the BubbleUi. | 357 // Implemented here to create the platform specific instance of the BubbleUi. |
| 392 scoped_ptr<BubbleUi> ExtensionInstalledBubble::BuildBubbleUi() { | 358 scoped_ptr<BubbleUi> ExtensionInstalledBubble::BuildBubbleUi() { |
| 393 return make_scoped_ptr(new ExtensionInstalledBubbleUi(this)); | 359 return make_scoped_ptr(new ExtensionInstalledBubbleUi(this)); |
| 394 } | 360 } |
| 395 | 361 |
| 396 ExtensionInstalledBubbleUi::ExtensionInstalledBubbleUi( | 362 ExtensionInstalledBubbleUi::ExtensionInstalledBubbleUi( |
| 397 ExtensionInstalledBubble* bubble) | 363 ExtensionInstalledBubble* bubble) |
| 398 : bubble_(bubble), delegate_view_(nullptr) { | 364 : bubble_(bubble), bubble_view_(nullptr) { |
| 399 DCHECK(bubble_); | 365 DCHECK(bubble_); |
| 400 } | 366 } |
| 401 | 367 |
| 402 ExtensionInstalledBubbleUi::~ExtensionInstalledBubbleUi() {} | 368 ExtensionInstalledBubbleUi::~ExtensionInstalledBubbleUi() {} |
| 403 | 369 |
| 404 void ExtensionInstalledBubbleUi::Show(BubbleReference bubble_reference) { | 370 void ExtensionInstalledBubbleUi::Show(BubbleReference /*bubble_reference*/) { |
|
Devlin
2016/04/07 19:02:50
nit: is this part of the styleguide? I don't see
Evan Stade
2016/04/07 20:02:50
yes, it's in the style guide but not commonly done
| |
| 405 // Owned by widget. | 371 bubble_view_ = new ExtensionInstalledBubbleView(bubble_); |
| 406 delegate_view_ = new ExtensionInstalledBubbleView(bubble_, bubble_reference); | |
| 407 delegate_view_->UpdateAnchorView(); | |
| 408 | 372 |
| 409 delegate_view_->set_arrow(bubble_->type() == bubble_->OMNIBOX_KEYWORD | 373 views::BubbleDialogDelegateView::CreateBubble(bubble_view_)->Show(); |
| 410 ? views::BubbleBorder::TOP_LEFT | |
| 411 : views::BubbleBorder::TOP_RIGHT); | |
| 412 | |
| 413 delegate_view_->InitLayout(); | |
| 414 | |
| 415 views::BubbleDelegateView::CreateBubble(delegate_view_)->Show(); | |
| 416 content::RecordAction( | 374 content::RecordAction( |
| 417 base::UserMetricsAction("Signin_Impression_FromExtensionInstallBubble")); | 375 base::UserMetricsAction("Signin_Impression_FromExtensionInstallBubble")); |
| 418 } | 376 } |
| 419 | 377 |
| 420 void ExtensionInstalledBubbleUi::Close() { | 378 void ExtensionInstalledBubbleUi::Close() { |
| 421 if (delegate_view_) { | 379 if (bubble_view_) { |
| 422 delegate_view_->GetWidget()->Close(); | 380 bubble_view_->GetWidget()->Close(); |
| 423 delegate_view_ = nullptr; | 381 bubble_view_ = nullptr; |
| 424 } | 382 } |
| 425 } | 383 } |
| 426 | 384 |
| 427 void ExtensionInstalledBubbleUi::UpdateAnchorPosition() { | 385 void ExtensionInstalledBubbleUi::UpdateAnchorPosition() { |
| 428 DCHECK(delegate_view_); | 386 DCHECK(bubble_view_); |
| 429 delegate_view_->UpdateAnchorView(); | 387 bubble_view_->UpdateAnchorView(); |
| 430 } | 388 } |
| OLD | NEW |