| 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" |
| (...skipping 10 matching lines...) Expand all Loading... |
| 21 #include "chrome/browser/ui/browser_window.h" | 21 #include "chrome/browser/ui/browser_window.h" |
| 22 #include "chrome/browser/ui/singleton_tabs.h" | 22 #include "chrome/browser/ui/singleton_tabs.h" |
| 23 #include "chrome/browser/ui/views/browser_action_view.h" | 23 #include "chrome/browser/ui/views/browser_action_view.h" |
| 24 #include "chrome/browser/ui/views/browser_actions_container.h" | 24 #include "chrome/browser/ui/views/browser_actions_container.h" |
| 25 #include "chrome/browser/ui/views/frame/browser_view.h" | 25 #include "chrome/browser/ui/views/frame/browser_view.h" |
| 26 #include "chrome/browser/ui/views/location_bar/location_bar_view.h" | 26 #include "chrome/browser/ui/views/location_bar/location_bar_view.h" |
| 27 #include "chrome/browser/ui/views/tabs/tab_strip.h" | 27 #include "chrome/browser/ui/views/tabs/tab_strip.h" |
| 28 #include "chrome/browser/ui/views/toolbar_view.h" | 28 #include "chrome/browser/ui/views/toolbar_view.h" |
| 29 #include "chrome/browser/ui/webui/ntp/new_tab_ui.h" | 29 #include "chrome/browser/ui/webui/ntp/new_tab_ui.h" |
| 30 #include "chrome/common/chrome_notification_types.h" | 30 #include "chrome/common/chrome_notification_types.h" |
| 31 #include "chrome/common/extensions/api/omnibox/omnibox_handler.h" |
| 31 #include "chrome/common/extensions/extension.h" | 32 #include "chrome/common/extensions/extension.h" |
| 32 #include "chrome/common/url_constants.h" | 33 #include "chrome/common/url_constants.h" |
| 33 #include "content/public/browser/notification_details.h" | 34 #include "content/public/browser/notification_details.h" |
| 34 #include "content/public/browser/notification_source.h" | 35 #include "content/public/browser/notification_source.h" |
| 35 #include "grit/chromium_strings.h" | 36 #include "grit/chromium_strings.h" |
| 36 #include "grit/generated_resources.h" | 37 #include "grit/generated_resources.h" |
| 37 #include "grit/ui_resources.h" | 38 #include "grit/ui_resources.h" |
| 38 #include "ui/base/l10n/l10n_util.h" | 39 #include "ui/base/l10n/l10n_util.h" |
| 39 #include "ui/base/resource/resource_bundle.h" | 40 #include "ui/base/resource/resource_bundle.h" |
| 40 #include "ui/views/controls/button/image_button.h" | 41 #include "ui/views/controls/button/image_button.h" |
| (...skipping 160 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::OmniboxInfo::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::OmniboxInfo::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::OmniboxInfo::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 |