| 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/extensions/extension_installed_bubble.h" | 5 #include "chrome/browser/ui/extensions/extension_installed_bubble.h" |
| 6 | 6 |
| 7 #include <string> | 7 #include <string> |
| 8 #include <utility> | 8 #include <utility> |
| 9 | 9 |
| 10 #include "base/bind.h" | 10 #include "base/bind.h" |
| (...skipping 232 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 243 if (message_id == 0) | 243 if (message_id == 0) |
| 244 return base::string16(); | 244 return base::string16(); |
| 245 return extra.empty() ? l10n_util::GetStringUTF16(message_id) : | 245 return extra.empty() ? l10n_util::GetStringUTF16(message_id) : |
| 246 l10n_util::GetStringFUTF16(message_id, extra); | 246 l10n_util::GetStringFUTF16(message_id, extra); |
| 247 } | 247 } |
| 248 | 248 |
| 249 void ExtensionInstalledBubble::Initialize() { | 249 void ExtensionInstalledBubble::Initialize() { |
| 250 bool extension_action_redesign_on = | 250 bool extension_action_redesign_on = |
| 251 extensions::FeatureSwitch::extension_action_redesign()->IsEnabled(); | 251 extensions::FeatureSwitch::extension_action_redesign()->IsEnabled(); |
| 252 | 252 |
| 253 if (extensions::ActionInfo::GetBrowserActionInfo(extension_)) { | 253 const extensions::ActionInfo* action_info = nullptr; |
| 254 if ((action_info = extensions::ActionInfo::GetBrowserActionInfo( |
| 255 extension_)) != nullptr) { |
| 254 type_ = BROWSER_ACTION; | 256 type_ = BROWSER_ACTION; |
| 255 } else if (extensions::ActionInfo::GetPageActionInfo(extension_) && | 257 } else if ((action_info = extensions::ActionInfo::GetPageActionInfo( |
| 258 extension_)) != nullptr && |
| 256 (extensions::ActionInfo::IsVerboseInstallMessage(extension_) || | 259 (extensions::ActionInfo::IsVerboseInstallMessage(extension_) || |
| 257 extension_action_redesign_on)) { | 260 extension_action_redesign_on)) { |
| 258 type_ = PAGE_ACTION; | 261 type_ = PAGE_ACTION; |
| 259 } else if (!extensions::OmniboxInfo::GetKeyword(extension_).empty()) { | 262 } else if (!extensions::OmniboxInfo::GetKeyword(extension_).empty()) { |
| 260 type_ = OMNIBOX_KEYWORD; | 263 type_ = OMNIBOX_KEYWORD; |
| 261 } else { | 264 } else { |
| 262 type_ = GENERIC; | 265 type_ = GENERIC; |
| 263 } | 266 } |
| 264 | 267 |
| 265 action_command_ = GetCommand(extension_->id(), browser_->profile(), type_); | 268 action_command_ = GetCommand(extension_->id(), browser_->profile(), type_); |
| 266 if (extensions::sync_helper::IsSyncable(extension_) && | 269 if (extensions::sync_helper::IsSyncable(extension_) && |
| 267 SyncPromoUI::ShouldShowSyncPromo(browser_->profile())) | 270 SyncPromoUI::ShouldShowSyncPromo(browser_->profile())) |
| 268 options_ |= SIGN_IN_PROMO; | 271 options_ |= SIGN_IN_PROMO; |
| 269 | 272 |
| 270 // Determine the bubble options we want, based on the extension type. | 273 // Determine the bubble options we want, based on the extension type. |
| 271 switch (type_) { | 274 switch (type_) { |
| 272 case BROWSER_ACTION: | 275 case BROWSER_ACTION: |
| 273 case PAGE_ACTION: | 276 case PAGE_ACTION: |
| 274 options_ |= HOW_TO_USE; | 277 DCHECK(action_info); |
| 278 if (!action_info->synthesized) |
| 279 options_ |= HOW_TO_USE; |
| 280 |
| 275 if (has_command_keybinding()) { | 281 if (has_command_keybinding()) { |
| 276 options_ |= SHOW_KEYBINDING; | 282 options_ |= SHOW_KEYBINDING; |
| 277 } else { | 283 } else { |
| 278 // The How-To-Use text makes the bubble seem a little crowded when the | 284 // The How-To-Use text makes the bubble seem a little crowded when the |
| 279 // extension has a keybinding, so the How-To-Manage text is not shown | 285 // extension has a keybinding, so the How-To-Manage text is not shown |
| 280 // in those cases. | 286 // in those cases. |
| 281 options_ |= HOW_TO_MANAGE; | 287 options_ |= HOW_TO_MANAGE; |
| 282 } | 288 } |
| 283 | 289 |
| 284 if (type_ == BROWSER_ACTION || extension_action_redesign_on) { | 290 if (type_ == BROWSER_ACTION || extension_action_redesign_on) { |
| 285 // If the toolbar redesign is enabled, all bubbles for extensions point | 291 // If the toolbar redesign is enabled, all bubbles for extensions point |
| 286 // to their toolbar action. | 292 // to their toolbar action. |
| 287 anchor_position_ = ANCHOR_BROWSER_ACTION; | 293 anchor_position_ = ANCHOR_BROWSER_ACTION; |
| 288 } else { | 294 } else { |
| 289 DCHECK_EQ(type_, PAGE_ACTION); | 295 DCHECK_EQ(type_, PAGE_ACTION); |
| 290 anchor_position_ = ANCHOR_PAGE_ACTION; | 296 anchor_position_ = ANCHOR_PAGE_ACTION; |
| 291 } | 297 } |
| 292 break; | 298 break; |
| 293 case OMNIBOX_KEYWORD: | 299 case OMNIBOX_KEYWORD: |
| 294 options_ |= HOW_TO_USE | HOW_TO_MANAGE; | 300 options_ |= HOW_TO_USE | HOW_TO_MANAGE; |
| 295 anchor_position_ = ANCHOR_OMNIBOX; | 301 anchor_position_ = ANCHOR_OMNIBOX; |
| 296 break; | 302 break; |
| 297 case GENERIC: | 303 case GENERIC: |
| 298 anchor_position_ = ANCHOR_APP_MENU; | 304 anchor_position_ = ANCHOR_APP_MENU; |
| 299 break; | 305 break; |
| 300 } | 306 } |
| 301 } | 307 } |
| OLD | NEW |