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/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/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/ui/browser.h" | 12 #include "chrome/browser/ui/browser.h" |
13 #include "chrome/browser/ui/browser_dialogs.h" | 13 #include "chrome/browser/ui/browser_dialogs.h" |
14 #include "chrome/browser/ui/gtk/browser_actions_toolbar_gtk.h" | 14 #include "chrome/browser/ui/gtk/browser_actions_toolbar_gtk.h" |
15 #include "chrome/browser/ui/gtk/browser_toolbar_gtk.h" | 15 #include "chrome/browser/ui/gtk/browser_toolbar_gtk.h" |
16 #include "chrome/browser/ui/gtk/browser_window_gtk.h" | 16 #include "chrome/browser/ui/gtk/browser_window_gtk.h" |
17 #include "chrome/browser/ui/gtk/gtk_theme_service.h" | 17 #include "chrome/browser/ui/gtk/gtk_theme_service.h" |
18 #include "chrome/browser/ui/gtk/gtk_util.h" | 18 #include "chrome/browser/ui/gtk/gtk_util.h" |
19 #include "chrome/browser/ui/gtk/location_bar_view_gtk.h" | 19 #include "chrome/browser/ui/gtk/location_bar_view_gtk.h" |
20 #include "chrome/common/extensions/extension.h" | 20 #include "chrome/common/extensions/extension.h" |
21 #include "chrome/common/extensions/extension_action.h" | 21 #include "chrome/common/extensions/extension_action.h" |
| 22 #include "content/common/content_notification_types.h" |
22 #include "content/common/notification_details.h" | 23 #include "content/common/notification_details.h" |
23 #include "content/common/notification_source.h" | 24 #include "content/common/notification_source.h" |
24 #include "content/common/notification_type.h" | |
25 #include "grit/generated_resources.h" | 25 #include "grit/generated_resources.h" |
26 #include "grit/theme_resources.h" | 26 #include "grit/theme_resources.h" |
27 #include "ui/base/l10n/l10n_util.h" | 27 #include "ui/base/l10n/l10n_util.h" |
28 #include "ui/base/resource/resource_bundle.h" | 28 #include "ui/base/resource/resource_bundle.h" |
29 #include "ui/gfx/gtk_util.h" | 29 #include "ui/gfx/gtk_util.h" |
30 | 30 |
31 namespace { | 31 namespace { |
32 | 32 |
33 const int kHorizontalColumnSpacing = 10; | 33 const int kHorizontalColumnSpacing = 10; |
34 const int kIconPadding = 3; | 34 const int kIconPadding = 3; |
(...skipping 47 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
82 type_ = PAGE_ACTION; | 82 type_ = PAGE_ACTION; |
83 } else { | 83 } else { |
84 type_ = GENERIC; | 84 type_ = GENERIC; |
85 } | 85 } |
86 | 86 |
87 // |extension| has been initialized but not loaded at this point. We need | 87 // |extension| has been initialized but not loaded at this point. We need |
88 // to wait on showing the Bubble until not only the EXTENSION_LOADED gets | 88 // to wait on showing the Bubble until not only the EXTENSION_LOADED gets |
89 // fired, but all of the EXTENSION_LOADED Observers have run. Only then can we | 89 // fired, but all of the EXTENSION_LOADED Observers have run. Only then can we |
90 // be sure that a browser action or page action has had views created which we | 90 // be sure that a browser action or page action has had views created which we |
91 // can inspect for the purpose of pointing to them. | 91 // can inspect for the purpose of pointing to them. |
92 registrar_.Add(this, NotificationType::EXTENSION_LOADED, | 92 registrar_.Add(this, chrome::NOTIFICATION_EXTENSION_LOADED, |
93 Source<Profile>(browser->profile())); | 93 Source<Profile>(browser->profile())); |
94 registrar_.Add(this, NotificationType::EXTENSION_UNLOADED, | 94 registrar_.Add(this, chrome::NOTIFICATION_EXTENSION_UNLOADED, |
95 Source<Profile>(browser->profile())); | 95 Source<Profile>(browser->profile())); |
96 } | 96 } |
97 | 97 |
98 ExtensionInstalledBubbleGtk::~ExtensionInstalledBubbleGtk() {} | 98 ExtensionInstalledBubbleGtk::~ExtensionInstalledBubbleGtk() {} |
99 | 99 |
100 void ExtensionInstalledBubbleGtk::Observe(NotificationType type, | 100 void ExtensionInstalledBubbleGtk::Observe(int type, |
101 const NotificationSource& source, | 101 const NotificationSource& source, |
102 const NotificationDetails& details) { | 102 const NotificationDetails& details) { |
103 if (type == NotificationType::EXTENSION_LOADED) { | 103 if (type == chrome::NOTIFICATION_EXTENSION_LOADED) { |
104 const Extension* extension = Details<const Extension>(details).ptr(); | 104 const Extension* extension = Details<const Extension>(details).ptr(); |
105 if (extension == extension_) { | 105 if (extension == extension_) { |
106 // PostTask to ourself to allow all EXTENSION_LOADED Observers to run. | 106 // PostTask to ourself to allow all EXTENSION_LOADED Observers to run. |
107 MessageLoopForUI::current()->PostTask(FROM_HERE, NewRunnableMethod(this, | 107 MessageLoopForUI::current()->PostTask(FROM_HERE, NewRunnableMethod(this, |
108 &ExtensionInstalledBubbleGtk::ShowInternal)); | 108 &ExtensionInstalledBubbleGtk::ShowInternal)); |
109 } | 109 } |
110 } else if (type == NotificationType::EXTENSION_UNLOADED) { | 110 } else if (type == chrome::NOTIFICATION_EXTENSION_UNLOADED) { |
111 const Extension* extension = | 111 const Extension* extension = |
112 Details<UnloadedExtensionInfo>(details)->extension; | 112 Details<UnloadedExtensionInfo>(details)->extension; |
113 if (extension == extension_) | 113 if (extension == extension_) |
114 extension_ = NULL; | 114 extension_ = NULL; |
115 } else { | 115 } else { |
116 NOTREACHED() << L"Received unexpected notification"; | 116 NOTREACHED() << L"Received unexpected notification"; |
117 } | 117 } |
118 } | 118 } |
119 | 119 |
120 void ExtensionInstalledBubbleGtk::ShowInternal() { | 120 void ExtensionInstalledBubbleGtk::ShowInternal() { |
(...skipping 192 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
313 // the window before we call Release() because close_button_ depends | 313 // the window before we call Release() because close_button_ depends |
314 // on all references being cleared before it is destroyed. | 314 // on all references being cleared before it is destroyed. |
315 MessageLoopForUI::current()->PostTask(FROM_HERE, NewRunnableMethod(this, | 315 MessageLoopForUI::current()->PostTask(FROM_HERE, NewRunnableMethod(this, |
316 &ExtensionInstalledBubbleGtk::Close)); | 316 &ExtensionInstalledBubbleGtk::Close)); |
317 } | 317 } |
318 | 318 |
319 void ExtensionInstalledBubbleGtk::Close() { | 319 void ExtensionInstalledBubbleGtk::Close() { |
320 Release(); // Balanced in ctor. | 320 Release(); // Balanced in ctor. |
321 bubble_ = NULL; | 321 bubble_ = NULL; |
322 } | 322 } |
OLD | NEW |