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/ui/browser.h" | 16 #include "chrome/browser/ui/browser.h" |
17 #include "chrome/browser/ui/browser_dialogs.h" | 17 #include "chrome/browser/ui/browser_dialogs.h" |
18 #include "chrome/browser/ui/gtk/browser_actions_toolbar_gtk.h" | 18 #include "chrome/browser/ui/gtk/browser_actions_toolbar_gtk.h" |
19 #include "chrome/browser/ui/gtk/browser_toolbar_gtk.h" | 19 #include "chrome/browser/ui/gtk/browser_toolbar_gtk.h" |
20 #include "chrome/browser/ui/gtk/browser_window_gtk.h" | 20 #include "chrome/browser/ui/gtk/browser_window_gtk.h" |
21 #include "chrome/browser/ui/gtk/gtk_theme_service.h" | 21 #include "chrome/browser/ui/gtk/gtk_theme_service.h" |
22 #include "chrome/browser/ui/gtk/gtk_util.h" | 22 #include "chrome/browser/ui/gtk/gtk_util.h" |
23 #include "chrome/browser/ui/gtk/location_bar_view_gtk.h" | 23 #include "chrome/browser/ui/gtk/location_bar_view_gtk.h" |
24 #include "chrome/browser/ui/singleton_tabs.h" | 24 #include "chrome/browser/ui/singleton_tabs.h" |
25 #include "chrome/common/chrome_notification_types.h" | 25 #include "chrome/common/chrome_notification_types.h" |
26 #include "chrome/common/extensions/extension.h" | 26 #include "chrome/common/extensions/extension.h" |
27 #include "chrome/common/extensions/extension_action.h" | 27 #include "chrome/browser/extensions/extension_action.h" |
28 #include "chrome/common/url_constants.h" | 28 #include "chrome/common/url_constants.h" |
29 #include "content/public/browser/notification_details.h" | 29 #include "content/public/browser/notification_details.h" |
30 #include "content/public/browser/notification_source.h" | 30 #include "content/public/browser/notification_source.h" |
31 #include "grit/chromium_strings.h" | 31 #include "grit/chromium_strings.h" |
32 #include "grit/generated_resources.h" | 32 #include "grit/generated_resources.h" |
33 #include "grit/theme_resources.h" | 33 #include "grit/theme_resources.h" |
34 #include "ui/base/l10n/l10n_util.h" | 34 #include "ui/base/l10n/l10n_util.h" |
35 #include "ui/base/resource/resource_bundle.h" | 35 #include "ui/base/resource/resource_bundle.h" |
36 #include "ui/gfx/gtk_util.h" | 36 #include "ui/gfx/gtk_util.h" |
37 | 37 |
(...skipping 114 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
152 // If the widget is not visible then browser_window could be incognito | 152 // If the widget is not visible then browser_window could be incognito |
153 // with this extension disabled. Try showing it on the chevron. | 153 // with this extension disabled. Try showing it on the chevron. |
154 // If that fails, fall back to default position. | 154 // If that fails, fall back to default position. |
155 if (reference_widget && !gtk_widget_get_visible(reference_widget)) { | 155 if (reference_widget && !gtk_widget_get_visible(reference_widget)) { |
156 reference_widget = gtk_widget_get_visible(toolbar->chevron()) ? | 156 reference_widget = gtk_widget_get_visible(toolbar->chevron()) ? |
157 toolbar->chevron() : NULL; | 157 toolbar->chevron() : NULL; |
158 } | 158 } |
159 } else if (type_ == PAGE_ACTION) { | 159 } else if (type_ == PAGE_ACTION) { |
160 LocationBarViewGtk* location_bar_view = | 160 LocationBarViewGtk* location_bar_view = |
161 browser_window->GetToolbar()->GetLocationBarView(); | 161 browser_window->GetToolbar()->GetLocationBarView(); |
162 location_bar_view->SetPreviewEnabledPageAction(extension_->page_action(), | 162 ExtensionAction* page_action = GetPageAction(browser_->profile(), |
| 163 *extension_); |
| 164 location_bar_view->SetPreviewEnabledPageAction(page_action, |
163 true); // preview_enabled | 165 true); // preview_enabled |
164 reference_widget = location_bar_view->GetPageActionWidget( | 166 reference_widget = location_bar_view->GetPageActionWidget(page_action); |
165 extension_->page_action()); | |
166 // glib delays recalculating layout, but we need reference_widget to know | 167 // glib delays recalculating layout, but we need reference_widget to know |
167 // its coordinates, so we force a check_resize here. | 168 // its coordinates, so we force a check_resize here. |
168 gtk_container_check_resize(GTK_CONTAINER( | 169 gtk_container_check_resize(GTK_CONTAINER( |
169 browser_window->GetToolbar()->widget())); | 170 browser_window->GetToolbar()->widget())); |
170 DCHECK(reference_widget); | 171 DCHECK(reference_widget); |
171 } else if (type_ == OMNIBOX_KEYWORD) { | 172 } else if (type_ == OMNIBOX_KEYWORD) { |
172 LocationBarViewGtk* location_bar_view = | 173 LocationBarViewGtk* location_bar_view = |
173 browser_window->GetToolbar()->GetLocationBarView(); | 174 browser_window->GetToolbar()->GetLocationBarView(); |
174 reference_widget = location_bar_view->location_entry_widget(); | 175 reference_widget = location_bar_view->location_entry_widget(); |
175 DCHECK(reference_widget); | 176 DCHECK(reference_widget); |
(...skipping 196 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
372 | 373 |
373 void ExtensionInstalledBubbleGtk::BubbleClosing(BubbleGtk* bubble, | 374 void ExtensionInstalledBubbleGtk::BubbleClosing(BubbleGtk* bubble, |
374 bool closed_by_escape) { | 375 bool closed_by_escape) { |
375 if (extension_ && type_ == PAGE_ACTION) { | 376 if (extension_ && type_ == PAGE_ACTION) { |
376 // Turn the page action preview off. | 377 // Turn the page action preview off. |
377 BrowserWindowGtk* browser_window = | 378 BrowserWindowGtk* browser_window = |
378 BrowserWindowGtk::GetBrowserWindowForNativeWindow( | 379 BrowserWindowGtk::GetBrowserWindowForNativeWindow( |
379 browser_->window()->GetNativeWindow()); | 380 browser_->window()->GetNativeWindow()); |
380 LocationBarViewGtk* location_bar_view = | 381 LocationBarViewGtk* location_bar_view = |
381 browser_window->GetToolbar()->GetLocationBarView(); | 382 browser_window->GetToolbar()->GetLocationBarView(); |
382 location_bar_view->SetPreviewEnabledPageAction(extension_->page_action(), | 383 ExtensionAction* page_action = GetPageAction(browser_->profile(), |
| 384 *extension_); |
| 385 location_bar_view->SetPreviewEnabledPageAction(page_action, |
383 false); // preview_enabled | 386 false); // preview_enabled |
384 } | 387 } |
385 | 388 |
386 // We need to allow the bubble to close and remove the widgets from | 389 // We need to allow the bubble to close and remove the widgets from |
387 // the window before we call Release() because close_button_ depends | 390 // the window before we call Release() because close_button_ depends |
388 // on all references being cleared before it is destroyed. | 391 // on all references being cleared before it is destroyed. |
389 MessageLoopForUI::current()->PostTask( | 392 MessageLoopForUI::current()->PostTask( |
390 FROM_HERE, | 393 FROM_HERE, |
391 base::Bind(&ExtensionInstalledBubbleGtk::Close, this)); | 394 base::Bind(&ExtensionInstalledBubbleGtk::Close, this)); |
392 } | 395 } |
393 | 396 |
394 void ExtensionInstalledBubbleGtk::Close() { | 397 void ExtensionInstalledBubbleGtk::Close() { |
395 Release(); // Balanced in ctor. | 398 Release(); // Balanced in ctor. |
396 bubble_ = NULL; | 399 bubble_ = NULL; |
397 } | 400 } |
OLD | NEW |