| 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/extension_command_service.h" |
| 15 #include "chrome/browser/extensions/extension_command_service_factory.h" |
| 14 #include "chrome/browser/extensions/extension_install_ui.h" | 16 #include "chrome/browser/extensions/extension_install_ui.h" |
| 15 #include "chrome/browser/profiles/profile.h" | 17 #include "chrome/browser/profiles/profile.h" |
| 16 #include "chrome/browser/ui/browser.h" | 18 #include "chrome/browser/ui/browser.h" |
| 17 #include "chrome/browser/ui/browser_window.h" | 19 #include "chrome/browser/ui/browser_window.h" |
| 18 #include "chrome/browser/ui/views/browser_actions_container.h" | 20 #include "chrome/browser/ui/views/browser_actions_container.h" |
| 19 #include "chrome/browser/ui/views/frame/browser_view.h" | 21 #include "chrome/browser/ui/views/frame/browser_view.h" |
| 20 #include "chrome/browser/ui/views/location_bar/location_bar_view.h" | 22 #include "chrome/browser/ui/views/location_bar/location_bar_view.h" |
| 21 #include "chrome/browser/ui/views/tabs/tab_strip.h" | 23 #include "chrome/browser/ui/views/tabs/tab_strip.h" |
| 22 #include "chrome/browser/ui/views/toolbar_view.h" | 24 #include "chrome/browser/ui/views/toolbar_view.h" |
| 23 #include "chrome/browser/ui/webui/ntp/new_tab_ui.h" | 25 #include "chrome/browser/ui/webui/ntp/new_tab_ui.h" |
| (...skipping 111 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 135 IDS_EXTENSION_INSTALLED_HEADING, extension_name)); | 137 IDS_EXTENSION_INSTALLED_HEADING, extension_name)); |
| 136 heading_->SetFont(rb.GetFont(ui::ResourceBundle::MediumFont)); | 138 heading_->SetFont(rb.GetFont(ui::ResourceBundle::MediumFont)); |
| 137 heading_->SetMultiLine(true); | 139 heading_->SetMultiLine(true); |
| 138 heading_->SetHorizontalAlignment(views::Label::ALIGN_LEFT); | 140 heading_->SetHorizontalAlignment(views::Label::ALIGN_LEFT); |
| 139 AddChildView(heading_); | 141 AddChildView(heading_); |
| 140 | 142 |
| 141 bool has_keybinding = false; | 143 bool has_keybinding = false; |
| 142 | 144 |
| 143 switch (type_) { | 145 switch (type_) { |
| 144 case ExtensionInstalledBubble::BROWSER_ACTION: { | 146 case ExtensionInstalledBubble::BROWSER_ACTION: { |
| 147 ExtensionCommandService* command_service = |
| 148 ExtensionCommandServiceFactory::GetForProfile( |
| 149 browser_->profile()); |
| 145 const Extension::ExtensionKeybinding* browser_action_command = | 150 const Extension::ExtensionKeybinding* browser_action_command = |
| 146 extension->browser_action_command(); | 151 command_service->GetActiveBrowserActionCommand(extension->id()); |
| 147 if (!browser_action_command) { | 152 if (!browser_action_command) { |
| 148 info_ = new views::Label(l10n_util::GetStringUTF16( | 153 info_ = new views::Label(l10n_util::GetStringUTF16( |
| 149 IDS_EXTENSION_INSTALLED_BROWSER_ACTION_INFO)); | 154 IDS_EXTENSION_INSTALLED_BROWSER_ACTION_INFO)); |
| 150 } else { | 155 } else { |
| 151 has_keybinding = true; | 156 has_keybinding = true; |
| 152 info_ = new views::Label(l10n_util::GetStringFUTF16( | 157 info_ = new views::Label(l10n_util::GetStringFUTF16( |
| 153 IDS_EXTENSION_INSTALLED_BROWSER_ACTION_INFO_WITH_SHORTCUT, | 158 IDS_EXTENSION_INSTALLED_BROWSER_ACTION_INFO_WITH_SHORTCUT, |
| 154 browser_action_command->accelerator().GetShortcutText())); | 159 browser_action_command->accelerator().GetShortcutText())); |
| 155 } | 160 } |
| 161 |
| 156 info_->SetFont(font); | 162 info_->SetFont(font); |
| 157 info_->SetMultiLine(true); | 163 info_->SetMultiLine(true); |
| 158 info_->SetHorizontalAlignment(views::Label::ALIGN_LEFT); | 164 info_->SetHorizontalAlignment(views::Label::ALIGN_LEFT); |
| 159 AddChildView(info_); | 165 AddChildView(info_); |
| 160 break; | 166 break; |
| 161 } | 167 } |
| 162 case ExtensionInstalledBubble::PAGE_ACTION: { | 168 case ExtensionInstalledBubble::PAGE_ACTION: { |
| 169 ExtensionCommandService* command_service = |
| 170 ExtensionCommandServiceFactory::GetForProfile( |
| 171 browser_->profile()); |
| 163 const Extension::ExtensionKeybinding* page_action_command = | 172 const Extension::ExtensionKeybinding* page_action_command = |
| 164 extension->page_action_command(); | 173 command_service->GetActivePageActionCommand(extension->id()); |
| 165 if (!page_action_command) { | 174 if (!page_action_command) { |
| 166 info_ = new views::Label(l10n_util::GetStringUTF16( | 175 info_ = new views::Label(l10n_util::GetStringUTF16( |
| 167 IDS_EXTENSION_INSTALLED_PAGE_ACTION_INFO)); | 176 IDS_EXTENSION_INSTALLED_PAGE_ACTION_INFO)); |
| 168 } else { | 177 } else { |
| 169 has_keybinding = true; | 178 has_keybinding = true; |
| 170 info_ = new views::Label(l10n_util::GetStringFUTF16( | 179 info_ = new views::Label(l10n_util::GetStringFUTF16( |
| 171 IDS_EXTENSION_INSTALLED_PAGE_ACTION_INFO_WITH_SHORTCUT, | 180 IDS_EXTENSION_INSTALLED_PAGE_ACTION_INFO_WITH_SHORTCUT, |
| 172 page_action_command->accelerator().GetShortcutText())); | 181 page_action_command->accelerator().GetShortcutText())); |
| 173 } | 182 } |
| 174 | 183 |
| (...skipping 290 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 465 } | 474 } |
| 466 | 475 |
| 467 void ExtensionInstalledBubble::WindowClosing() { | 476 void ExtensionInstalledBubble::WindowClosing() { |
| 468 if (extension_ && type_ == PAGE_ACTION) { | 477 if (extension_ && type_ == PAGE_ACTION) { |
| 469 BrowserView* browser_view = BrowserView::GetBrowserViewForBrowser(browser_); | 478 BrowserView* browser_view = BrowserView::GetBrowserViewForBrowser(browser_); |
| 470 browser_view->GetLocationBarView()->SetPreviewEnabledPageAction( | 479 browser_view->GetLocationBarView()->SetPreviewEnabledPageAction( |
| 471 extension_->page_action(), | 480 extension_->page_action(), |
| 472 false); // preview_enabled | 481 false); // preview_enabled |
| 473 } | 482 } |
| 474 } | 483 } |
| OLD | NEW |