| 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 "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 #include <string> | 8 #include <string> |
| 9 | 9 |
| 10 #include "base/bind.h" | 10 #include "base/bind.h" |
| 11 #include "base/i18n/rtl.h" | 11 #include "base/i18n/rtl.h" |
| 12 #include "base/message_loop.h" | 12 #include "base/message_loop.h" |
| 13 #include "base/utf_string_conversions.h" | 13 #include "base/utf_string_conversions.h" |
| 14 #include "chrome/browser/extensions/api/commands/command_service.h" | 14 #include "chrome/browser/extensions/api/commands/command_service.h" |
| 15 #include "chrome/browser/extensions/api/commands/command_service_factory.h" | 15 #include "chrome/browser/extensions/api/commands/command_service_factory.h" |
| 16 #include "chrome/browser/extensions/api/omnibox/omnibox_api.h" |
| 16 #include "chrome/browser/extensions/extension_action.h" | 17 #include "chrome/browser/extensions/extension_action.h" |
| 17 #include "chrome/browser/extensions/extension_action_manager.h" | 18 #include "chrome/browser/extensions/extension_action_manager.h" |
| 18 #include "chrome/browser/extensions/extension_install_ui.h" | 19 #include "chrome/browser/extensions/extension_install_ui.h" |
| 19 #include "chrome/browser/profiles/profile.h" | 20 #include "chrome/browser/profiles/profile.h" |
| 20 #include "chrome/browser/ui/browser.h" | 21 #include "chrome/browser/ui/browser.h" |
| 21 #include "chrome/browser/ui/browser_window.h" | 22 #include "chrome/browser/ui/browser_window.h" |
| 22 #include "chrome/browser/ui/singleton_tabs.h" | 23 #include "chrome/browser/ui/singleton_tabs.h" |
| 23 #include "chrome/browser/ui/views/browser_action_view.h" | 24 #include "chrome/browser/ui/views/browser_action_view.h" |
| 24 #include "chrome/browser/ui/views/browser_actions_container.h" | 25 #include "chrome/browser/ui/views/browser_actions_container.h" |
| 25 #include "chrome/browser/ui/views/frame/browser_view.h" | 26 #include "chrome/browser/ui/views/frame/browser_view.h" |
| (...skipping 175 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 201 | 202 |
| 202 info_->SetFont(font); | 203 info_->SetFont(font); |
| 203 info_->SetMultiLine(true); | 204 info_->SetMultiLine(true); |
| 204 info_->SetHorizontalAlignment(gfx::ALIGN_LEFT); | 205 info_->SetHorizontalAlignment(gfx::ALIGN_LEFT); |
| 205 AddChildView(info_); | 206 AddChildView(info_); |
| 206 break; | 207 break; |
| 207 } | 208 } |
| 208 case ExtensionInstalledBubble::OMNIBOX_KEYWORD: { | 209 case ExtensionInstalledBubble::OMNIBOX_KEYWORD: { |
| 209 info_ = new views::Label(l10n_util::GetStringFUTF16( | 210 info_ = new views::Label(l10n_util::GetStringFUTF16( |
| 210 IDS_EXTENSION_INSTALLED_OMNIBOX_KEYWORD_INFO, | 211 IDS_EXTENSION_INSTALLED_OMNIBOX_KEYWORD_INFO, |
| 211 UTF8ToUTF16(extension->omnibox_keyword()))); | 212 UTF8ToUTF16(extensions::OmniboxAPI::GetKeyword(extension)))); |
| 212 info_->SetFont(font); | 213 info_->SetFont(font); |
| 213 info_->SetMultiLine(true); | 214 info_->SetMultiLine(true); |
| 214 info_->SetHorizontalAlignment(gfx::ALIGN_LEFT); | 215 info_->SetHorizontalAlignment(gfx::ALIGN_LEFT); |
| 215 AddChildView(info_); | 216 AddChildView(info_); |
| 216 break; | 217 break; |
| 217 } | 218 } |
| 218 case ExtensionInstalledBubble::APP: { | 219 case ExtensionInstalledBubble::APP: { |
| 219 views::Link* link = new views::Link( | 220 views::Link* link = new views::Link( |
| 220 l10n_util::GetStringUTF16(IDS_EXTENSION_INSTALLED_APP_INFO)); | 221 l10n_util::GetStringUTF16(IDS_EXTENSION_INSTALLED_APP_INFO)); |
| 221 link->set_listener(this); | 222 link->set_listener(this); |
| (...skipping 163 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 385 Browser *browser, | 386 Browser *browser, |
| 386 const SkBitmap& icon) | 387 const SkBitmap& icon) |
| 387 : extension_(extension), | 388 : extension_(extension), |
| 388 browser_(browser), | 389 browser_(browser), |
| 389 icon_(icon), | 390 icon_(icon), |
| 390 animation_wait_retries_(0) { | 391 animation_wait_retries_(0) { |
| 391 extensions::ExtensionActionManager* extension_action_manager = | 392 extensions::ExtensionActionManager* extension_action_manager = |
| 392 extensions::ExtensionActionManager::Get(browser_->profile()); | 393 extensions::ExtensionActionManager::Get(browser_->profile()); |
| 393 if (extension->is_app()) | 394 if (extension->is_app()) |
| 394 type_ = APP; | 395 type_ = APP; |
| 395 else if (!extension_->omnibox_keyword().empty()) | 396 else if (!extensions::OmniboxAPI::GetKeyword(extension).empty()) |
| 396 type_ = OMNIBOX_KEYWORD; | 397 type_ = OMNIBOX_KEYWORD; |
| 397 else if (extension_action_manager->GetBrowserAction(*extension_)) | 398 else if (extension_action_manager->GetBrowserAction(*extension_)) |
| 398 type_ = BROWSER_ACTION; | 399 type_ = BROWSER_ACTION; |
| 399 else if (extension_action_manager->GetPageAction(*extension) && | 400 else if (extension_action_manager->GetPageAction(*extension) && |
| 400 extension->is_verbose_install_message()) | 401 extensions::OmniboxAPI::IsVerboseInstallMessage(extension)) |
| 401 type_ = PAGE_ACTION; | 402 type_ = PAGE_ACTION; |
| 402 else | 403 else |
| 403 type_ = GENERIC; | 404 type_ = GENERIC; |
| 404 | 405 |
| 405 // |extension| has been initialized but not loaded at this point. We need | 406 // |extension| has been initialized but not loaded at this point. We need |
| 406 // to wait on showing the Bubble until not only the EXTENSION_LOADED gets | 407 // to wait on showing the Bubble until not only the EXTENSION_LOADED gets |
| 407 // fired, but all of the EXTENSION_LOADED Observers have run. Only then can we | 408 // fired, but all of the EXTENSION_LOADED Observers have run. Only then can we |
| 408 // be sure that a BrowserAction or PageAction has had views created which we | 409 // be sure that a BrowserAction or PageAction has had views created which we |
| 409 // can inspect for the purpose of previewing of pointing to them. | 410 // can inspect for the purpose of previewing of pointing to them. |
| 410 registrar_.Add(this, chrome::NOTIFICATION_EXTENSION_LOADED, | 411 registrar_.Add(this, chrome::NOTIFICATION_EXTENSION_LOADED, |
| (...skipping 112 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 523 | 524 |
| 524 void ExtensionInstalledBubble::WindowClosing() { | 525 void ExtensionInstalledBubble::WindowClosing() { |
| 525 if (extension_ && type_ == PAGE_ACTION) { | 526 if (extension_ && type_ == PAGE_ACTION) { |
| 526 BrowserView* browser_view = BrowserView::GetBrowserViewForBrowser(browser_); | 527 BrowserView* browser_view = BrowserView::GetBrowserViewForBrowser(browser_); |
| 527 browser_view->GetLocationBarView()->SetPreviewEnabledPageAction( | 528 browser_view->GetLocationBarView()->SetPreviewEnabledPageAction( |
| 528 extensions::ExtensionActionManager::Get(browser_->profile())-> | 529 extensions::ExtensionActionManager::Get(browser_->profile())-> |
| 529 GetPageAction(*extension_), | 530 GetPageAction(*extension_), |
| 530 false); // preview_enabled | 531 false); // preview_enabled |
| 531 } | 532 } |
| 532 } | 533 } |
| OLD | NEW |