| 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" |
| (...skipping 132 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 143 void PanelExtensionWindowController::SetFullscreenMode( | 143 void PanelExtensionWindowController::SetFullscreenMode( |
| 144 bool is_fullscreen, const GURL& extension_url) const { | 144 bool is_fullscreen, const GURL& extension_url) const { |
| 145 // Do nothing. Panels cannot be fullscreen. | 145 // Do nothing. Panels cannot be fullscreen. |
| 146 } | 146 } |
| 147 | 147 |
| 148 bool PanelExtensionWindowController::IsVisibleToExtension( | 148 bool PanelExtensionWindowController::IsVisibleToExtension( |
| 149 const extensions::Extension* extension) const { | 149 const extensions::Extension* extension) const { |
| 150 return extension->id() == panel_->extension_id(); | 150 return extension->id() == panel_->extension_id(); |
| 151 } | 151 } |
| 152 | 152 |
| 153 } // namespace internal | 153 } // namespace panel_internal |
| 154 | 154 |
| 155 Panel::~Panel() { | 155 Panel::~Panel() { |
| 156 DCHECK(!collection_); | 156 DCHECK(!collection_); |
| 157 // Invoked by native panel destructor. Do not access native_panel_ here. | 157 // Invoked by native panel destructor. Do not access native_panel_ here. |
| 158 chrome::EndKeepAlive(); // Remove shutdown prevention. | 158 chrome::EndKeepAlive(); // Remove shutdown prevention. |
| 159 } | 159 } |
| 160 | 160 |
| 161 PanelManager* Panel::manager() const { | 161 PanelManager* Panel::manager() const { |
| 162 return PanelManager::GetInstance(); | 162 return PanelManager::GetInstance(); |
| 163 } | 163 } |
| (...skipping 260 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 424 default: | 424 default: |
| 425 LOG(WARNING) << "Received unimplemented command: " << id; | 425 LOG(WARNING) << "Received unimplemented command: " << id; |
| 426 break; | 426 break; |
| 427 } | 427 } |
| 428 } | 428 } |
| 429 | 429 |
| 430 void Panel::Observe(int type, | 430 void Panel::Observe(int type, |
| 431 const content::NotificationSource& source, | 431 const content::NotificationSource& source, |
| 432 const content::NotificationDetails& details) { | 432 const content::NotificationDetails& details) { |
| 433 switch (type) { | 433 switch (type) { |
| 434 case content::NOTIFICATION_WEB_CONTENTS_SWAPPED: | 434 case content::NOTIFICATION_RENDER_VIEW_HOST_CHANGED: |
| 435 ConfigureAutoResize(content::Source<content::WebContents>(source).ptr()); | 435 ConfigureAutoResize(content::Source<content::WebContents>(source).ptr()); |
| 436 break; | 436 break; |
| 437 case chrome::NOTIFICATION_EXTENSION_UNLOADED: | 437 case chrome::NOTIFICATION_EXTENSION_UNLOADED: |
| 438 if (content::Details<extensions::UnloadedExtensionInfo>( | 438 if (content::Details<extensions::UnloadedExtensionInfo>( |
| 439 details)->extension->id() == extension_id()) | 439 details)->extension->id() == extension_id()) |
| 440 Close(); | 440 Close(); |
| 441 break; | 441 break; |
| 442 case chrome::NOTIFICATION_APP_TERMINATING: | 442 case chrome::NOTIFICATION_APP_TERMINATING: |
| 443 Close(); | 443 Close(); |
| 444 break; | 444 break; |
| (...skipping 130 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 575 if (auto_resizable_ == resizable) | 575 if (auto_resizable_ == resizable) |
| 576 return; | 576 return; |
| 577 | 577 |
| 578 auto_resizable_ = resizable; | 578 auto_resizable_ = resizable; |
| 579 content::WebContents* web_contents = GetWebContents(); | 579 content::WebContents* web_contents = GetWebContents(); |
| 580 if (auto_resizable_) { | 580 if (auto_resizable_) { |
| 581 if (web_contents) | 581 if (web_contents) |
| 582 EnableWebContentsAutoResize(web_contents); | 582 EnableWebContentsAutoResize(web_contents); |
| 583 } else { | 583 } else { |
| 584 if (web_contents) { | 584 if (web_contents) { |
| 585 registrar_.Remove(this, content::NOTIFICATION_WEB_CONTENTS_SWAPPED, | 585 registrar_.Remove(this, content::NOTIFICATION_RENDER_VIEW_HOST_CHANGED, |
| 586 content::Source<content::WebContents>(web_contents)); | 586 content::Source<content::WebContents>(web_contents)); |
| 587 | 587 |
| 588 // NULL might be returned if the tab has not been added. | 588 // NULL might be returned if the tab has not been added. |
| 589 RenderViewHost* render_view_host = web_contents->GetRenderViewHost(); | 589 RenderViewHost* render_view_host = web_contents->GetRenderViewHost(); |
| 590 if (render_view_host) | 590 if (render_view_host) |
| 591 render_view_host->DisableAutoResize(full_size_); | 591 render_view_host->DisableAutoResize(full_size_); |
| 592 } | 592 } |
| 593 } | 593 } |
| 594 } | 594 } |
| 595 | 595 |
| 596 void Panel::EnableWebContentsAutoResize(content::WebContents* web_contents) { | 596 void Panel::EnableWebContentsAutoResize(content::WebContents* web_contents) { |
| 597 DCHECK(web_contents); | 597 DCHECK(web_contents); |
| 598 ConfigureAutoResize(web_contents); | 598 ConfigureAutoResize(web_contents); |
| 599 | 599 |
| 600 // We also need to know when the render view host changes in order | 600 // We also need to know when the render view host changes in order |
| 601 // to turn on auto-resize notifications in the new render view host. | 601 // to turn on auto-resize notifications in the new render view host. |
| 602 if (!registrar_.IsRegistered( | 602 if (!registrar_.IsRegistered( |
| 603 this, content::NOTIFICATION_WEB_CONTENTS_SWAPPED, | 603 this, content::NOTIFICATION_RENDER_VIEW_HOST_CHANGED, |
| 604 content::Source<content::WebContents>(web_contents))) { | 604 content::Source<content::WebContents>(web_contents))) { |
| 605 registrar_.Add( | 605 registrar_.Add( |
| 606 this, | 606 this, |
| 607 content::NOTIFICATION_WEB_CONTENTS_SWAPPED, | 607 content::NOTIFICATION_RENDER_VIEW_HOST_CHANGED, |
| 608 content::Source<content::WebContents>(web_contents)); | 608 content::Source<content::WebContents>(web_contents)); |
| 609 } | 609 } |
| 610 } | 610 } |
| 611 | 611 |
| 612 void Panel::OnContentsAutoResized(const gfx::Size& new_content_size) { | 612 void Panel::OnContentsAutoResized(const gfx::Size& new_content_size) { |
| 613 DCHECK(auto_resizable_); | 613 DCHECK(auto_resizable_); |
| 614 if (!collection_) | 614 if (!collection_) |
| 615 return; | 615 return; |
| 616 | 616 |
| 617 gfx::Size new_window_size = | 617 gfx::Size new_window_size = |
| (...skipping 271 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 889 | 889 |
| 890 // static | 890 // static |
| 891 void Panel::FormatTitleForDisplay(string16* title) { | 891 void Panel::FormatTitleForDisplay(string16* title) { |
| 892 size_t current_index = 0; | 892 size_t current_index = 0; |
| 893 size_t match_index; | 893 size_t match_index; |
| 894 while ((match_index = title->find(L'\n', current_index)) != string16::npos) { | 894 while ((match_index = title->find(L'\n', current_index)) != string16::npos) { |
| 895 title->replace(match_index, 1, string16()); | 895 title->replace(match_index, 1, string16()); |
| 896 current_index = match_index; | 896 current_index = match_index; |
| 897 } | 897 } |
| 898 } | 898 } |
| OLD | NEW |