| 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" |
| 11 #include "chrome/browser/extensions/api/tabs/tabs_constants.h" | 11 #include "chrome/browser/extensions/api/tabs/tabs_constants.h" |
| 12 #include "chrome/browser/extensions/extension_service.h" |
| 13 #include "chrome/browser/extensions/extension_system.h" |
| 12 #include "chrome/browser/extensions/window_controller.h" | 14 #include "chrome/browser/extensions/window_controller.h" |
| 15 #include "chrome/browser/extensions/window_controller_list.h" |
| 16 #include "chrome/browser/extensions/window_event_router.h" |
| 13 #include "chrome/browser/lifetime/application_lifetime.h" | 17 #include "chrome/browser/lifetime/application_lifetime.h" |
| 14 #include "chrome/browser/profiles/profile.h" | 18 #include "chrome/browser/profiles/profile.h" |
| 15 #include "chrome/browser/themes/theme_service.h" | 19 #include "chrome/browser/themes/theme_service.h" |
| 16 #include "chrome/browser/themes/theme_service_factory.h" | 20 #include "chrome/browser/themes/theme_service_factory.h" |
| 17 #include "chrome/browser/ui/panels/native_panel.h" | 21 #include "chrome/browser/ui/panels/native_panel.h" |
| 18 #include "chrome/browser/ui/panels/panel_host.h" | 22 #include "chrome/browser/ui/panels/panel_host.h" |
| 19 #include "chrome/browser/ui/panels/panel_manager.h" | 23 #include "chrome/browser/ui/panels/panel_manager.h" |
| 20 #include "chrome/browser/ui/panels/panel_strip.h" | 24 #include "chrome/browser/ui/panels/panel_strip.h" |
| 21 #include "chrome/browser/web_applications/web_app.h" | 25 #include "chrome/browser/web_applications/web_app.h" |
| 22 #include "chrome/common/chrome_notification_types.h" | 26 #include "chrome/common/chrome_notification_types.h" |
| 23 #include "chrome/common/extensions/extension.h" | 27 #include "chrome/common/extensions/extension.h" |
| 24 #include "content/public/browser/notification_service.h" | 28 #include "content/public/browser/notification_service.h" |
| 25 #include "content/public/browser/notification_source.h" | 29 #include "content/public/browser/notification_source.h" |
| 26 #include "content/public/browser/notification_types.h" | 30 #include "content/public/browser/notification_types.h" |
| 27 #include "content/public/browser/render_view_host.h" | 31 #include "content/public/browser/render_view_host.h" |
| 28 #include "content/public/browser/user_metrics.h" | 32 #include "content/public/browser/user_metrics.h" |
| 29 #include "content/public/browser/web_contents.h" | 33 #include "content/public/browser/web_contents.h" |
| 30 #include "third_party/skia/include/core/SkBitmap.h" | 34 #include "third_party/skia/include/core/SkBitmap.h" |
| 31 #include "ui/gfx/rect.h" | 35 #include "ui/gfx/rect.h" |
| 32 | 36 |
| 33 using content::RenderViewHost; | 37 using content::RenderViewHost; |
| 34 using content::UserMetricsAction; | 38 using content::UserMetricsAction; |
| 35 | 39 |
| 36 namespace panel_internal { | 40 namespace panel_internal { |
| 37 | 41 |
| 38 class PanelExtensionWindowController : public extensions::WindowController { | 42 class PanelExtensionWindowController : public extensions::WindowController { |
| 39 public: | 43 public: |
| 40 PanelExtensionWindowController(Panel* panel, Profile* profile); | 44 PanelExtensionWindowController(Panel* panel, Profile* profile); |
| 45 virtual ~PanelExtensionWindowController(); |
| 41 | 46 |
| 42 // Overridden from extensions::WindowController. | 47 // Overridden from extensions::WindowController. |
| 43 virtual int GetWindowId() const OVERRIDE; | 48 virtual int GetWindowId() const OVERRIDE; |
| 44 virtual std::string GetWindowTypeText() const OVERRIDE; | 49 virtual std::string GetWindowTypeText() const OVERRIDE; |
| 45 virtual base::DictionaryValue* CreateWindowValueWithTabs() const OVERRIDE; | 50 virtual base::DictionaryValue* CreateWindowValueWithTabs() const OVERRIDE; |
| 46 virtual bool CanClose(Reason* reason) const OVERRIDE; | 51 virtual bool CanClose(Reason* reason) const OVERRIDE; |
| 47 virtual void SetFullscreenMode(bool is_fullscreen, | 52 virtual void SetFullscreenMode(bool is_fullscreen, |
| 48 const GURL& extension_url) const OVERRIDE; | 53 const GURL& extension_url) const OVERRIDE; |
| 49 virtual bool IsVisibleToExtension( | 54 virtual bool IsVisibleToExtension( |
| 50 const extensions::Extension* extension) const OVERRIDE; | 55 const extensions::Extension* extension) const OVERRIDE; |
| 51 | 56 |
| 52 private: | 57 private: |
| 53 Panel* panel_; // Weak pointer. Owns us. | 58 Panel* panel_; // Weak pointer. Owns us. |
| 54 DISALLOW_COPY_AND_ASSIGN(PanelExtensionWindowController); | 59 DISALLOW_COPY_AND_ASSIGN(PanelExtensionWindowController); |
| 55 }; | 60 }; |
| 56 | 61 |
| 57 PanelExtensionWindowController::PanelExtensionWindowController( | 62 PanelExtensionWindowController::PanelExtensionWindowController( |
| 58 Panel* panel, Profile* profile) | 63 Panel* panel, Profile* profile) |
| 59 : extensions::WindowController(panel, profile), | 64 : extensions::WindowController(panel, profile), |
| 60 panel_(panel) { | 65 panel_(panel) { |
| 66 extensions::WindowControllerList::GetInstance()->AddExtensionWindow(this); |
| 67 } |
| 68 |
| 69 PanelExtensionWindowController::~PanelExtensionWindowController() { |
| 70 extensions::WindowControllerList::GetInstance()->RemoveExtensionWindow(this); |
| 61 } | 71 } |
| 62 | 72 |
| 63 int PanelExtensionWindowController::GetWindowId() const { | 73 int PanelExtensionWindowController::GetWindowId() const { |
| 64 return static_cast<int>(panel_->session_id().id()); | 74 return static_cast<int>(panel_->session_id().id()); |
| 65 } | 75 } |
| 66 | 76 |
| 67 std::string PanelExtensionWindowController::GetWindowTypeText() const { | 77 std::string PanelExtensionWindowController::GetWindowTypeText() const { |
| 68 return extensions::tabs_constants::kWindowTypeValuePanel; | 78 return extensions::tabs_constants::kWindowTypeValuePanel; |
| 69 } | 79 } |
| 70 | 80 |
| (...skipping 540 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 611 // its expansion state. However, we don't want to clear draw attention if | 621 // its expansion state. However, we don't want to clear draw attention if |
| 612 // contents are not visible. In that scenario, if the mouse-down results | 622 // contents are not visible. In that scenario, if the mouse-down results |
| 613 // in a mouse-click, draw attention will be cleared then. | 623 // in a mouse-click, draw attention will be cleared then. |
| 614 // See Panel::OnTitlebarClicked(). | 624 // See Panel::OnTitlebarClicked(). |
| 615 if (active && IsDrawingAttention() && !IsMinimized()) | 625 if (active && IsDrawingAttention() && !IsMinimized()) |
| 616 FlashFrame(false); | 626 FlashFrame(false); |
| 617 | 627 |
| 618 if (panel_strip_) | 628 if (panel_strip_) |
| 619 panel_strip_->OnPanelActiveStateChanged(this); | 629 panel_strip_->OnPanelActiveStateChanged(this); |
| 620 | 630 |
| 631 // Send extension event about window becoming active. |
| 632 // TODO(jennb): remove extension_window_controller_ guard after refactor. |
| 633 if (active && extension_window_controller_.get()) { |
| 634 ExtensionService* service = |
| 635 extensions::ExtensionSystem::Get(profile())->extension_service(); |
| 636 if (service) { |
| 637 service->window_event_router()->OnActiveWindowChanged( |
| 638 extension_window_controller_.get()); |
| 639 } |
| 640 } |
| 641 |
| 621 content::NotificationService::current()->Notify( | 642 content::NotificationService::current()->Notify( |
| 622 chrome::NOTIFICATION_PANEL_CHANGED_ACTIVE_STATUS, | 643 chrome::NOTIFICATION_PANEL_CHANGED_ACTIVE_STATUS, |
| 623 content::Source<Panel>(this), | 644 content::Source<Panel>(this), |
| 624 content::NotificationService::NoDetails()); | 645 content::NotificationService::NoDetails()); |
| 625 } | 646 } |
| 626 | 647 |
| 627 void Panel::ConfigureAutoResize(content::WebContents* web_contents) { | 648 void Panel::ConfigureAutoResize(content::WebContents* web_contents) { |
| 628 if (!auto_resizable_ || !web_contents) | 649 if (!auto_resizable_ || !web_contents) |
| 629 return; | 650 return; |
| 630 | 651 |
| (...skipping 99 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 730 | 751 |
| 731 void Panel::LoadingStateChanged(bool is_loading) { | 752 void Panel::LoadingStateChanged(bool is_loading) { |
| 732 command_updater_.UpdateCommandEnabled(IDC_STOP, is_loading); | 753 command_updater_.UpdateCommandEnabled(IDC_STOP, is_loading); |
| 733 native_panel_->UpdatePanelLoadingAnimations(is_loading); | 754 native_panel_->UpdatePanelLoadingAnimations(is_loading); |
| 734 UpdateTitleBar(); | 755 UpdateTitleBar(); |
| 735 } | 756 } |
| 736 | 757 |
| 737 void Panel::WebContentsFocused(content::WebContents* contents) { | 758 void Panel::WebContentsFocused(content::WebContents* contents) { |
| 738 native_panel_->PanelWebContentsFocused(contents); | 759 native_panel_->PanelWebContentsFocused(contents); |
| 739 } | 760 } |
| OLD | NEW |