| OLD | NEW |
| 1 // Copyright (c) 2011 The Chromium Authors. All rights reserved. | 1 // Copyright (c) 2011 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 | 8 |
| 9 #include "base/i18n/rtl.h" | 9 #include "base/i18n/rtl.h" |
| 10 #include "base/message_loop.h" | 10 #include "base/message_loop.h" |
| 11 #include "base/utf_string_conversions.h" | 11 #include "base/utf_string_conversions.h" |
| 12 #include "chrome/browser/profiles/profile.h" | 12 #include "chrome/browser/profiles/profile.h" |
| 13 #include "chrome/browser/ui/browser.h" | 13 #include "chrome/browser/ui/browser.h" |
| 14 #include "chrome/browser/ui/browser_window.h" | 14 #include "chrome/browser/ui/browser_window.h" |
| 15 #include "chrome/browser/ui/views/browser_actions_container.h" | 15 #include "chrome/browser/ui/views/browser_actions_container.h" |
| 16 #include "chrome/browser/ui/views/frame/browser_view.h" | 16 #include "chrome/browser/ui/views/frame/browser_view.h" |
| 17 #include "chrome/browser/ui/views/location_bar/location_bar_view.h" | 17 #include "chrome/browser/ui/views/location_bar/location_bar_view.h" |
| 18 #include "chrome/browser/ui/views/toolbar_view.h" | 18 #include "chrome/browser/ui/views/toolbar_view.h" |
| 19 #include "chrome/common/chrome_notification_types.h" |
| 19 #include "chrome/common/extensions/extension.h" | 20 #include "chrome/common/extensions/extension.h" |
| 20 #include "chrome/common/extensions/extension_action.h" | 21 #include "chrome/common/extensions/extension_action.h" |
| 21 #include "content/common/notification_details.h" | 22 #include "content/common/notification_details.h" |
| 22 #include "content/common/notification_source.h" | 23 #include "content/common/notification_source.h" |
| 23 #include "content/common/notification_type.h" | |
| 24 #include "grit/generated_resources.h" | 24 #include "grit/generated_resources.h" |
| 25 #include "grit/theme_resources_standard.h" | 25 #include "grit/theme_resources_standard.h" |
| 26 #include "ui/base/l10n/l10n_util.h" | 26 #include "ui/base/l10n/l10n_util.h" |
| 27 #include "ui/base/resource/resource_bundle.h" | 27 #include "ui/base/resource/resource_bundle.h" |
| 28 #include "views/controls/button/image_button.h" | 28 #include "views/controls/button/image_button.h" |
| 29 #include "views/controls/image_view.h" | 29 #include "views/controls/image_view.h" |
| 30 #include "views/controls/label.h" | 30 #include "views/controls/label.h" |
| 31 #include "views/layout/layout_constants.h" | 31 #include "views/layout/layout_constants.h" |
| 32 #include "views/view.h" | 32 #include "views/view.h" |
| 33 | 33 |
| (...skipping 223 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 257 type_ = PAGE_ACTION; | 257 type_ = PAGE_ACTION; |
| 258 } else { | 258 } else { |
| 259 type_ = GENERIC; | 259 type_ = GENERIC; |
| 260 } | 260 } |
| 261 | 261 |
| 262 // |extension| has been initialized but not loaded at this point. We need | 262 // |extension| has been initialized but not loaded at this point. We need |
| 263 // to wait on showing the Bubble until not only the EXTENSION_LOADED gets | 263 // to wait on showing the Bubble until not only the EXTENSION_LOADED gets |
| 264 // fired, but all of the EXTENSION_LOADED Observers have run. Only then can we | 264 // fired, but all of the EXTENSION_LOADED Observers have run. Only then can we |
| 265 // be sure that a BrowserAction or PageAction has had views created which we | 265 // be sure that a BrowserAction or PageAction has had views created which we |
| 266 // can inspect for the purpose of previewing of pointing to them. | 266 // can inspect for the purpose of previewing of pointing to them. |
| 267 registrar_.Add(this, NotificationType::EXTENSION_LOADED, | 267 registrar_.Add(this, chrome::NOTIFICATION_EXTENSION_LOADED, |
| 268 Source<Profile>(browser->profile())); | 268 Source<Profile>(browser->profile())); |
| 269 registrar_.Add(this, NotificationType::EXTENSION_UNLOADED, | 269 registrar_.Add(this, chrome::NOTIFICATION_EXTENSION_UNLOADED, |
| 270 Source<Profile>(browser->profile())); | 270 Source<Profile>(browser->profile())); |
| 271 } | 271 } |
| 272 | 272 |
| 273 ExtensionInstalledBubble::~ExtensionInstalledBubble() {} | 273 ExtensionInstalledBubble::~ExtensionInstalledBubble() {} |
| 274 | 274 |
| 275 void ExtensionInstalledBubble::Observe(NotificationType type, | 275 void ExtensionInstalledBubble::Observe(int type, |
| 276 const NotificationSource& source, | 276 const NotificationSource& source, |
| 277 const NotificationDetails& details) { | 277 const NotificationDetails& details) { |
| 278 if (type == NotificationType::EXTENSION_LOADED) { | 278 if (type == chrome::NOTIFICATION_EXTENSION_LOADED) { |
| 279 const Extension* extension = Details<const Extension>(details).ptr(); | 279 const Extension* extension = Details<const Extension>(details).ptr(); |
| 280 if (extension == extension_) { | 280 if (extension == extension_) { |
| 281 animation_wait_retries_ = 0; | 281 animation_wait_retries_ = 0; |
| 282 // PostTask to ourself to allow all EXTENSION_LOADED Observers to run. | 282 // PostTask to ourself to allow all EXTENSION_LOADED Observers to run. |
| 283 MessageLoopForUI::current()->PostTask(FROM_HERE, NewRunnableMethod(this, | 283 MessageLoopForUI::current()->PostTask(FROM_HERE, NewRunnableMethod(this, |
| 284 &ExtensionInstalledBubble::ShowInternal)); | 284 &ExtensionInstalledBubble::ShowInternal)); |
| 285 } | 285 } |
| 286 } else if (type == NotificationType::EXTENSION_UNLOADED) { | 286 } else if (type == chrome::NOTIFICATION_EXTENSION_UNLOADED) { |
| 287 const Extension* extension = | 287 const Extension* extension = |
| 288 Details<UnloadedExtensionInfo>(details)->extension; | 288 Details<UnloadedExtensionInfo>(details)->extension; |
| 289 if (extension == extension_) | 289 if (extension == extension_) |
| 290 extension_ = NULL; | 290 extension_ = NULL; |
| 291 } else { | 291 } else { |
| 292 NOTREACHED() << L"Received unexpected notification"; | 292 NOTREACHED() << L"Received unexpected notification"; |
| 293 } | 293 } |
| 294 } | 294 } |
| 295 | 295 |
| 296 void ExtensionInstalledBubble::ShowInternal() { | 296 void ExtensionInstalledBubble::ShowInternal() { |
| (...skipping 75 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 372 Release(); // Balanced in ctor. | 372 Release(); // Balanced in ctor. |
| 373 } | 373 } |
| 374 | 374 |
| 375 bool ExtensionInstalledBubble::CloseOnEscape() { | 375 bool ExtensionInstalledBubble::CloseOnEscape() { |
| 376 return true; | 376 return true; |
| 377 } | 377 } |
| 378 | 378 |
| 379 bool ExtensionInstalledBubble::FadeInOnShow() { | 379 bool ExtensionInstalledBubble::FadeInOnShow() { |
| 380 return true; | 380 return true; |
| 381 } | 381 } |
| OLD | NEW |