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/panels/panel.h" | 5 #include "chrome/browser/ui/panels/panel.h" |
6 | 6 |
7 #include "base/logging.h" | 7 #include "base/logging.h" |
8 #include "base/message_loop/message_loop.h" | 8 #include "base/message_loop/message_loop.h" |
9 #include "base/strings/utf_string_conversions.h" | 9 #include "base/strings/utf_string_conversions.h" |
10 #include "chrome/app/chrome_command_ids.h" | 10 #include "chrome/app/chrome_command_ids.h" |
11 #include "chrome/browser/chrome_notification_types.h" | 11 #include "chrome/browser/chrome_notification_types.h" |
12 #include "chrome/browser/devtools/devtools_window.h" | 12 #include "chrome/browser/devtools/devtools_window.h" |
13 #include "chrome/browser/extensions/api/tabs/tabs_constants.h" | 13 #include "chrome/browser/extensions/api/tabs/tabs_constants.h" |
14 #include "chrome/browser/extensions/api/tabs/tabs_windows_api.h" | 14 #include "chrome/browser/extensions/api/tabs/tabs_windows_api.h" |
15 #include "chrome/browser/extensions/api/tabs/windows_event_router.h" | 15 #include "chrome/browser/extensions/api/tabs/windows_event_router.h" |
16 #include "chrome/browser/extensions/extension_service.h" | 16 #include "chrome/browser/extensions/extension_service.h" |
17 #include "chrome/browser/extensions/extension_tab_util.h" | 17 #include "chrome/browser/extensions/extension_tab_util.h" |
18 #include "chrome/browser/extensions/window_controller.h" | 18 #include "chrome/browser/extensions/window_controller.h" |
19 #include "chrome/browser/extensions/window_controller_list.h" | 19 #include "chrome/browser/extensions/window_controller_list.h" |
20 #include "chrome/browser/lifetime/application_lifetime.h" | 20 #include "chrome/browser/lifetime/application_lifetime.h" |
| 21 #include "chrome/browser/lifetime/browser_keep_alive.h" |
21 #include "chrome/browser/profiles/profile.h" | 22 #include "chrome/browser/profiles/profile.h" |
22 #include "chrome/browser/sessions/session_tab_helper.h" | 23 #include "chrome/browser/sessions/session_tab_helper.h" |
23 #include "chrome/browser/task_management/web_contents_tags.h" | 24 #include "chrome/browser/task_management/web_contents_tags.h" |
24 #include "chrome/browser/themes/theme_service.h" | 25 #include "chrome/browser/themes/theme_service.h" |
25 #include "chrome/browser/themes/theme_service_factory.h" | 26 #include "chrome/browser/themes/theme_service_factory.h" |
26 #include "chrome/browser/ui/panels/native_panel.h" | 27 #include "chrome/browser/ui/panels/native_panel.h" |
27 #include "chrome/browser/ui/panels/panel_collection.h" | 28 #include "chrome/browser/ui/panels/panel_collection.h" |
28 #include "chrome/browser/ui/panels/panel_host.h" | 29 #include "chrome/browser/ui/panels/panel_host.h" |
29 #include "chrome/browser/ui/panels/panel_manager.h" | 30 #include "chrome/browser/ui/panels/panel_manager.h" |
30 #include "chrome/browser/ui/panels/stacked_panel_collection.h" | 31 #include "chrome/browser/ui/panels/stacked_panel_collection.h" |
(...skipping 122 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
153 DCHECK(extension); | 154 DCHECK(extension); |
154 return extension->id() == panel_->extension_id(); | 155 return extension->id() == panel_->extension_id(); |
155 } | 156 } |
156 | 157 |
157 } // namespace panel_internal | 158 } // namespace panel_internal |
158 | 159 |
159 Panel::~Panel() { | 160 Panel::~Panel() { |
160 DCHECK(!collection_); | 161 DCHECK(!collection_); |
161 #if !defined(USE_AURA) | 162 #if !defined(USE_AURA) |
162 // Invoked by native panel destructor. Do not access native_panel_ here. | 163 // Invoked by native panel destructor. Do not access native_panel_ here. |
163 chrome::DecrementKeepAliveCount(); // Remove shutdown prevention. | 164 keep_alive_.reset(); // Remove shutdown prevention. |
164 #endif | 165 #endif |
165 } | 166 } |
166 | 167 |
167 PanelManager* Panel::manager() const { | 168 PanelManager* Panel::manager() const { |
168 return PanelManager::GetInstance(); | 169 return PanelManager::GetInstance(); |
169 } | 170 } |
170 | 171 |
171 const std::string Panel::extension_id() const { | 172 const std::string Panel::extension_id() const { |
172 return web_app::GetExtensionIdFromApplicationName(app_name_); | 173 return web_app::GetExtensionIdFromApplicationName(app_name_); |
173 } | 174 } |
(...skipping 371 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
545 extension_registry_->AddObserver(this); | 546 extension_registry_->AddObserver(this); |
546 registrar_.Add(this, chrome::NOTIFICATION_APP_TERMINATING, | 547 registrar_.Add(this, chrome::NOTIFICATION_APP_TERMINATING, |
547 content::NotificationService::AllSources()); | 548 content::NotificationService::AllSources()); |
548 registrar_.Add(this, chrome::NOTIFICATION_BROWSER_THEME_CHANGED, | 549 registrar_.Add(this, chrome::NOTIFICATION_BROWSER_THEME_CHANGED, |
549 content::Source<ThemeService>( | 550 content::Source<ThemeService>( |
550 ThemeServiceFactory::GetForProfile(profile_))); | 551 ThemeServiceFactory::GetForProfile(profile_))); |
551 | 552 |
552 #if !defined(USE_AURA) | 553 #if !defined(USE_AURA) |
553 // Keep alive for AURA has been moved to panel_view. | 554 // Keep alive for AURA has been moved to panel_view. |
554 // Prevent the browser process from shutting down while this window is open. | 555 // Prevent the browser process from shutting down while this window is open. |
555 chrome::IncrementKeepAliveCount(); | 556 keep_alive_.reset(new browser_lifetime::ScopedKeepAlive); |
556 #endif | 557 #endif |
557 | 558 |
558 UpdateAppIcon(); | 559 UpdateAppIcon(); |
559 } | 560 } |
560 | 561 |
561 void Panel::SetPanelBounds(const gfx::Rect& bounds) { | 562 void Panel::SetPanelBounds(const gfx::Rect& bounds) { |
562 if (bounds != native_panel_->GetPanelBounds()) | 563 if (bounds != native_panel_->GetPanelBounds()) |
563 native_panel_->SetPanelBounds(bounds); | 564 native_panel_->SetPanelBounds(bounds); |
564 } | 565 } |
565 | 566 |
(...skipping 328 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
894 // static | 895 // static |
895 void Panel::FormatTitleForDisplay(base::string16* title) { | 896 void Panel::FormatTitleForDisplay(base::string16* title) { |
896 size_t current_index = 0; | 897 size_t current_index = 0; |
897 size_t match_index; | 898 size_t match_index; |
898 while ((match_index = title->find(L'\n', current_index)) != | 899 while ((match_index = title->find(L'\n', current_index)) != |
899 base::string16::npos) { | 900 base::string16::npos) { |
900 title->replace(match_index, 1, base::string16()); | 901 title->replace(match_index, 1, base::string16()); |
901 current_index = match_index; | 902 current_index = match_index; |
902 } | 903 } |
903 } | 904 } |
OLD | NEW |