| 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/gtk/extensions/extension_installed_bubble_gtk.h" | 5 #include "chrome/browser/ui/gtk/extensions/extension_installed_bubble_gtk.h" |
| 6 | 6 |
| 7 #include <string> | 7 #include <string> |
| 8 | 8 |
| 9 #include "base/bind.h" | 9 #include "base/bind.h" |
| 10 #include "base/bind_helpers.h" | 10 #include "base/bind_helpers.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/extension_action.h" | 16 #include "chrome/browser/extensions/extension_action.h" |
| 17 #include "chrome/browser/extensions/extension_action_manager.h" | 17 #include "chrome/browser/extensions/extension_action_manager.h" |
| 18 #include "chrome/browser/ui/browser.h" | 18 #include "chrome/browser/ui/browser.h" |
| 19 #include "chrome/browser/ui/browser_dialogs.h" | 19 #include "chrome/browser/ui/browser_dialogs.h" |
| 20 #include "chrome/browser/ui/gtk/browser_actions_toolbar_gtk.h" | 20 #include "chrome/browser/ui/gtk/browser_actions_toolbar_gtk.h" |
| 21 #include "chrome/browser/ui/gtk/browser_toolbar_gtk.h" | 21 #include "chrome/browser/ui/gtk/browser_toolbar_gtk.h" |
| 22 #include "chrome/browser/ui/gtk/browser_window_gtk.h" | 22 #include "chrome/browser/ui/gtk/browser_window_gtk.h" |
| 23 #include "chrome/browser/ui/gtk/gtk_theme_service.h" | 23 #include "chrome/browser/ui/gtk/gtk_theme_service.h" |
| 24 #include "chrome/browser/ui/gtk/gtk_util.h" | 24 #include "chrome/browser/ui/gtk/gtk_util.h" |
| 25 #include "chrome/browser/ui/gtk/location_bar_view_gtk.h" | 25 #include "chrome/browser/ui/gtk/location_bar_view_gtk.h" |
| 26 #include "chrome/browser/ui/singleton_tabs.h" | 26 #include "chrome/browser/ui/singleton_tabs.h" |
| 27 #include "chrome/common/chrome_notification_types.h" | 27 #include "chrome/common/chrome_notification_types.h" |
| 28 #include "chrome/common/extensions/api/omnibox/omnibox_handler.h" |
| 28 #include "chrome/common/extensions/extension.h" | 29 #include "chrome/common/extensions/extension.h" |
| 29 #include "chrome/common/url_constants.h" | 30 #include "chrome/common/url_constants.h" |
| 30 #include "content/public/browser/notification_details.h" | 31 #include "content/public/browser/notification_details.h" |
| 31 #include "content/public/browser/notification_source.h" | 32 #include "content/public/browser/notification_source.h" |
| 32 #include "grit/chromium_strings.h" | 33 #include "grit/chromium_strings.h" |
| 33 #include "grit/generated_resources.h" | 34 #include "grit/generated_resources.h" |
| 34 #include "grit/theme_resources.h" | 35 #include "grit/theme_resources.h" |
| 35 #include "ui/base/gtk/gtk_hig_constants.h" | 36 #include "ui/base/gtk/gtk_hig_constants.h" |
| 36 #include "ui/base/l10n/l10n_util.h" | 37 #include "ui/base/l10n/l10n_util.h" |
| 37 #include "ui/base/resource/resource_bundle.h" | 38 #include "ui/base/resource/resource_bundle.h" |
| (...skipping 38 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 76 const Extension* extension, Browser *browser, const SkBitmap& icon) | 77 const Extension* extension, Browser *browser, const SkBitmap& icon) |
| 77 : extension_(extension), | 78 : extension_(extension), |
| 78 browser_(browser), | 79 browser_(browser), |
| 79 icon_(icon), | 80 icon_(icon), |
| 80 animation_wait_retries_(kAnimationWaitRetries) { | 81 animation_wait_retries_(kAnimationWaitRetries) { |
| 81 AddRef(); // Balanced in Close(). | 82 AddRef(); // Balanced in Close(). |
| 82 | 83 |
| 83 extensions::ExtensionActionManager* extension_action_manager = | 84 extensions::ExtensionActionManager* extension_action_manager = |
| 84 ExtensionActionManager::Get(browser_->profile()); | 85 ExtensionActionManager::Get(browser_->profile()); |
| 85 | 86 |
| 86 if (!extension_->omnibox_keyword().empty()) | 87 if (!extensions::OmniboxInfo::GetKeyword(extension_).empty()) |
| 87 type_ = OMNIBOX_KEYWORD; | 88 type_ = OMNIBOX_KEYWORD; |
| 88 else if (extension_action_manager->GetBrowserAction(*extension_)) | 89 else if (extension_action_manager->GetBrowserAction(*extension_)) |
| 89 type_ = BROWSER_ACTION; | 90 type_ = BROWSER_ACTION; |
| 90 else if (extension_action_manager->GetPageAction(*extension) && | 91 else if (extension_action_manager->GetPageAction(*extension) && |
| 91 extension->is_verbose_install_message()) | 92 extensions::OmniboxInfo::IsVerboseInstallMessage(extension)) |
| 92 type_ = PAGE_ACTION; | 93 type_ = PAGE_ACTION; |
| 93 else | 94 else |
| 94 type_ = GENERIC; | 95 type_ = GENERIC; |
| 95 | 96 |
| 96 // |extension| has been initialized but not loaded at this point. We need | 97 // |extension| has been initialized but not loaded at this point. We need |
| 97 // to wait on showing the Bubble until not only the EXTENSION_LOADED gets | 98 // to wait on showing the Bubble until not only the EXTENSION_LOADED gets |
| 98 // fired, but all of the EXTENSION_LOADED Observers have run. Only then can we | 99 // fired, but all of the EXTENSION_LOADED Observers have run. Only then can we |
| 99 // be sure that a browser action or page action has had views created which we | 100 // be sure that a browser action or page action has had views created which we |
| 100 // can inspect for the purpose of pointing to them. | 101 // can inspect for the purpose of pointing to them. |
| 101 registrar_.Add(this, chrome::NOTIFICATION_EXTENSION_LOADED, | 102 registrar_.Add(this, chrome::NOTIFICATION_EXTENSION_LOADED, |
| (...skipping 186 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 288 has_keybinding = true; | 289 has_keybinding = true; |
| 289 } | 290 } |
| 290 gtk_util::SetLabelWidth(info_label, kTextColumnWidth); | 291 gtk_util::SetLabelWidth(info_label, kTextColumnWidth); |
| 291 gtk_box_pack_start(GTK_BOX(text_column), info_label, FALSE, FALSE, 0); | 292 gtk_box_pack_start(GTK_BOX(text_column), info_label, FALSE, FALSE, 0); |
| 292 } | 293 } |
| 293 | 294 |
| 294 // Omnibox keyword label. | 295 // Omnibox keyword label. |
| 295 if (type_ == OMNIBOX_KEYWORD) { | 296 if (type_ == OMNIBOX_KEYWORD) { |
| 296 GtkWidget* info_label = gtk_label_new(l10n_util::GetStringFUTF8( | 297 GtkWidget* info_label = gtk_label_new(l10n_util::GetStringFUTF8( |
| 297 IDS_EXTENSION_INSTALLED_OMNIBOX_KEYWORD_INFO, | 298 IDS_EXTENSION_INSTALLED_OMNIBOX_KEYWORD_INFO, |
| 298 UTF8ToUTF16(extension_->omnibox_keyword())).c_str()); | 299 UTF8ToUTF16(extensions::OmniboxInfo::GetKeyword(extension_))).c_str()); |
| 299 gtk_util::SetLabelWidth(info_label, kTextColumnWidth); | 300 gtk_util::SetLabelWidth(info_label, kTextColumnWidth); |
| 300 gtk_box_pack_start(GTK_BOX(text_column), info_label, FALSE, FALSE, 0); | 301 gtk_box_pack_start(GTK_BOX(text_column), info_label, FALSE, FALSE, 0); |
| 301 } | 302 } |
| 302 | 303 |
| 303 if (has_keybinding) { | 304 if (has_keybinding) { |
| 304 GtkWidget* manage_link = theme_provider->BuildChromeLinkButton( | 305 GtkWidget* manage_link = theme_provider->BuildChromeLinkButton( |
| 305 l10n_util::GetStringUTF8(IDS_EXTENSION_INSTALLED_MANAGE_SHORTCUTS)); | 306 l10n_util::GetStringUTF8(IDS_EXTENSION_INSTALLED_MANAGE_SHORTCUTS)); |
| 306 GtkWidget* link_hbox = gtk_hbox_new(FALSE, 0); | 307 GtkWidget* link_hbox = gtk_hbox_new(FALSE, 0); |
| 307 // Stick it in an hbox so it doesn't expand to the whole width. | 308 // Stick it in an hbox so it doesn't expand to the whole width. |
| 308 gtk_box_pack_end(GTK_BOX(link_hbox), manage_link, FALSE, FALSE, 0); | 309 gtk_box_pack_end(GTK_BOX(link_hbox), manage_link, FALSE, FALSE, 0); |
| (...skipping 88 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 397 // on all references being cleared before it is destroyed. | 398 // on all references being cleared before it is destroyed. |
| 398 MessageLoopForUI::current()->PostTask( | 399 MessageLoopForUI::current()->PostTask( |
| 399 FROM_HERE, | 400 FROM_HERE, |
| 400 base::Bind(&ExtensionInstalledBubbleGtk::Close, this)); | 401 base::Bind(&ExtensionInstalledBubbleGtk::Close, this)); |
| 401 } | 402 } |
| 402 | 403 |
| 403 void ExtensionInstalledBubbleGtk::Close() { | 404 void ExtensionInstalledBubbleGtk::Close() { |
| 404 Release(); // Balanced in ctor. | 405 Release(); // Balanced in ctor. |
| 405 bubble_ = NULL; | 406 bubble_ = NULL; |
| 406 } | 407 } |
| OLD | NEW |