| 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.h" | 8 #include "base/message_loop.h" |
| 9 #include "base/utf_string_conversions.h" | 9 #include "base/utf_string_conversions.h" |
| 10 #include "chrome/app/chrome_command_ids.h" | 10 #include "chrome/app/chrome_command_ids.h" |
| (...skipping 140 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 151 always_on_top_(false), | 151 always_on_top_(false), |
| 152 in_preview_mode_(false), | 152 in_preview_mode_(false), |
| 153 native_panel_(NULL), | 153 native_panel_(NULL), |
| 154 attention_mode_(USE_PANEL_ATTENTION), | 154 attention_mode_(USE_PANEL_ATTENTION), |
| 155 expansion_state_(EXPANDED), | 155 expansion_state_(EXPANDED), |
| 156 command_updater_(this) { | 156 command_updater_(this) { |
| 157 } | 157 } |
| 158 | 158 |
| 159 Panel::~Panel() { | 159 Panel::~Panel() { |
| 160 // Invoked by native panel destructor. Do not access native_panel_ here. | 160 // Invoked by native panel destructor. Do not access native_panel_ here. |
| 161 | 161 browser::EndKeepAlive(); // Remove shutdown prevention. |
| 162 // Remove shutdown prevention. | |
| 163 // TODO(jennb): remove guard after refactor | |
| 164 if (extension_window_controller_.get()) | |
| 165 browser::EndKeepAlive(); | |
| 166 } | |
| 167 | |
| 168 void Panel::Initialize(const gfx::Rect& bounds, Browser* browser) { | |
| 169 DCHECK(!initialized_); | |
| 170 DCHECK(!panel_strip_); // Cannot be added to a strip until fully created. | |
| 171 DCHECK_EQ(EXPANDED, expansion_state_); | |
| 172 DCHECK(!bounds.IsEmpty()); | |
| 173 initialized_ = true; | |
| 174 full_size_ = bounds.size(); | |
| 175 native_panel_ = CreateNativePanel(browser, this, bounds); | |
| 176 } | 162 } |
| 177 | 163 |
| 178 void Panel::Initialize(Profile* profile, const GURL& url, | 164 void Panel::Initialize(Profile* profile, const GURL& url, |
| 179 const gfx::Rect& bounds) { | 165 const gfx::Rect& bounds) { |
| 180 DCHECK(!initialized_); | 166 DCHECK(!initialized_); |
| 181 DCHECK(!panel_strip_); // Cannot be added to a strip until fully created. | 167 DCHECK(!panel_strip_); // Cannot be added to a strip until fully created. |
| 182 DCHECK_EQ(EXPANDED, expansion_state_); | 168 DCHECK_EQ(EXPANDED, expansion_state_); |
| 183 DCHECK(!bounds.IsEmpty()); | 169 DCHECK(!bounds.IsEmpty()); |
| 184 initialized_ = true; | 170 initialized_ = true; |
| 185 profile_ = profile; | 171 profile_ = profile; |
| (...skipping 50 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 236 | 222 |
| 237 void Panel::OnNativePanelClosed() { | 223 void Panel::OnNativePanelClosed() { |
| 238 manager()->OnPanelClosed(this); | 224 manager()->OnPanelClosed(this); |
| 239 DCHECK(!panel_strip_); | 225 DCHECK(!panel_strip_); |
| 240 } | 226 } |
| 241 | 227 |
| 242 PanelManager* Panel::manager() const { | 228 PanelManager* Panel::manager() const { |
| 243 return PanelManager::GetInstance(); | 229 return PanelManager::GetInstance(); |
| 244 } | 230 } |
| 245 | 231 |
| 246 Browser* Panel::browser() const { | |
| 247 return NULL; | |
| 248 } | |
| 249 | |
| 250 BrowserWindow* Panel::browser_window() const { | |
| 251 return NULL; | |
| 252 } | |
| 253 | |
| 254 CommandUpdater* Panel::command_updater() { | 232 CommandUpdater* Panel::command_updater() { |
| 255 return &command_updater_; | 233 return &command_updater_; |
| 256 } | 234 } |
| 257 | 235 |
| 258 Profile* Panel::profile() const { | 236 Profile* Panel::profile() const { |
| 259 return profile_; | 237 return profile_; |
| 260 } | 238 } |
| 261 | 239 |
| 262 const std::string Panel::extension_id() const { | 240 const std::string Panel::extension_id() const { |
| 263 return web_app::GetExtensionIdFromApplicationName(app_name_); | 241 return web_app::GetExtensionIdFromApplicationName(app_name_); |
| (...skipping 238 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 502 } | 480 } |
| 503 | 481 |
| 504 gfx::Rect Panel::GetBounds() const { | 482 gfx::Rect Panel::GetBounds() const { |
| 505 return native_panel_->GetPanelBounds(); | 483 return native_panel_->GetPanelBounds(); |
| 506 } | 484 } |
| 507 | 485 |
| 508 int Panel::TitleOnlyHeight() const { | 486 int Panel::TitleOnlyHeight() const { |
| 509 return native_panel_->TitleOnlyHeight(); | 487 return native_panel_->TitleOnlyHeight(); |
| 510 } | 488 } |
| 511 | 489 |
| 512 void Panel::EnsureFullyVisible() { | |
| 513 native_panel_->EnsurePanelFullyVisible(); | |
| 514 } | |
| 515 | |
| 516 bool Panel::IsMaximized() const { | 490 bool Panel::IsMaximized() const { |
| 517 // Size of panels is managed by PanelManager, they are never 'zoomed'. | 491 // Size of panels is managed by PanelManager, they are never 'zoomed'. |
| 518 return false; | 492 return false; |
| 519 } | 493 } |
| 520 | 494 |
| 521 bool Panel::IsMinimized() const { | 495 bool Panel::IsMinimized() const { |
| 522 return !panel_strip_ || panel_strip()->IsPanelMinimized(this); | 496 return !panel_strip_ || panel_strip()->IsPanelMinimized(this); |
| 523 } | 497 } |
| 524 | 498 |
| 525 void Panel::Maximize() { | 499 void Panel::Maximize() { |
| (...skipping 152 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 678 // contents are not visible. In that scenario, if the mouse-down results | 652 // contents are not visible. In that scenario, if the mouse-down results |
| 679 // in a mouse-click, draw attention will be cleared then. | 653 // in a mouse-click, draw attention will be cleared then. |
| 680 // See Panel::OnTitlebarClicked(). | 654 // See Panel::OnTitlebarClicked(). |
| 681 if (active && IsDrawingAttention() && !IsMinimized()) | 655 if (active && IsDrawingAttention() && !IsMinimized()) |
| 682 FlashFrame(false); | 656 FlashFrame(false); |
| 683 | 657 |
| 684 if (panel_strip_) | 658 if (panel_strip_) |
| 685 panel_strip_->OnPanelActiveStateChanged(this); | 659 panel_strip_->OnPanelActiveStateChanged(this); |
| 686 | 660 |
| 687 // Send extension event about window becoming active. | 661 // Send extension event about window becoming active. |
| 688 // TODO(jennb): remove extension_window_controller_ guard after refactor. | 662 if (active) { |
| 689 if (active && extension_window_controller_.get()) { | |
| 690 ExtensionService* service = | 663 ExtensionService* service = |
| 691 extensions::ExtensionSystem::Get(profile())->extension_service(); | 664 extensions::ExtensionSystem::Get(profile())->extension_service(); |
| 692 if (service) { | 665 if (service) { |
| 693 service->window_event_router()->OnActiveWindowChanged( | 666 service->window_event_router()->OnActiveWindowChanged( |
| 694 extension_window_controller_.get()); | 667 extension_window_controller_.get()); |
| 695 } | 668 } |
| 696 } | 669 } |
| 697 | 670 |
| 698 content::NotificationService::current()->Notify( | 671 content::NotificationService::current()->Notify( |
| 699 chrome::NOTIFICATION_PANEL_CHANGED_ACTIVE_STATUS, | 672 chrome::NOTIFICATION_PANEL_CHANGED_ACTIVE_STATUS, |
| (...skipping 107 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 807 | 780 |
| 808 void Panel::LoadingStateChanged(bool is_loading) { | 781 void Panel::LoadingStateChanged(bool is_loading) { |
| 809 command_updater_.UpdateCommandEnabled(IDC_STOP, is_loading); | 782 command_updater_.UpdateCommandEnabled(IDC_STOP, is_loading); |
| 810 native_panel_->UpdatePanelLoadingAnimations(is_loading); | 783 native_panel_->UpdatePanelLoadingAnimations(is_loading); |
| 811 UpdateTitleBar(); | 784 UpdateTitleBar(); |
| 812 } | 785 } |
| 813 | 786 |
| 814 void Panel::WebContentsFocused(content::WebContents* contents) { | 787 void Panel::WebContentsFocused(content::WebContents* contents) { |
| 815 native_panel_->PanelWebContentsFocused(contents); | 788 native_panel_->PanelWebContentsFocused(contents); |
| 816 } | 789 } |
| OLD | NEW |