| 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 20 matching lines...) Expand all Loading... |
| 31 #include "content/public/browser/notification_types.h" | 31 #include "content/public/browser/notification_types.h" |
| 32 #include "content/public/browser/render_view_host.h" | 32 #include "content/public/browser/render_view_host.h" |
| 33 #include "content/public/browser/user_metrics.h" | 33 #include "content/public/browser/user_metrics.h" |
| 34 #include "content/public/browser/web_contents.h" | 34 #include "content/public/browser/web_contents.h" |
| 35 #include "ui/gfx/image/image.h" | 35 #include "ui/gfx/image/image.h" |
| 36 #include "ui/gfx/rect.h" | 36 #include "ui/gfx/rect.h" |
| 37 | 37 |
| 38 using content::RenderViewHost; | 38 using content::RenderViewHost; |
| 39 using content::UserMetricsAction; | 39 using content::UserMetricsAction; |
| 40 | 40 |
| 41 namespace extensions { |
| 42 class Extension; |
| 43 } |
| 44 |
| 41 namespace panel_internal { | 45 namespace panel_internal { |
| 42 | 46 |
| 43 class PanelExtensionWindowController : public extensions::WindowController { | 47 class PanelExtensionWindowController : public extensions::WindowController { |
| 44 public: | 48 public: |
| 45 PanelExtensionWindowController(Panel* panel, Profile* profile); | 49 PanelExtensionWindowController(Panel* panel, Profile* profile); |
| 46 virtual ~PanelExtensionWindowController(); | 50 virtual ~PanelExtensionWindowController(); |
| 47 | 51 |
| 48 // Overridden from extensions::WindowController. | 52 // Overridden from extensions::WindowController. |
| 49 virtual int GetWindowId() const OVERRIDE; | 53 virtual int GetWindowId() const OVERRIDE; |
| 50 virtual std::string GetWindowTypeText() const OVERRIDE; | 54 virtual std::string GetWindowTypeText() const OVERRIDE; |
| 51 virtual base::DictionaryValue* CreateWindowValueWithTabs() const OVERRIDE; | 55 virtual base::DictionaryValue* CreateWindowValueWithTabs( |
| 56 const extensions::Extension* extension) const OVERRIDE; |
| 52 virtual bool CanClose(Reason* reason) const OVERRIDE; | 57 virtual bool CanClose(Reason* reason) const OVERRIDE; |
| 53 virtual void SetFullscreenMode(bool is_fullscreen, | 58 virtual void SetFullscreenMode(bool is_fullscreen, |
| 54 const GURL& extension_url) const OVERRIDE; | 59 const GURL& extension_url) const OVERRIDE; |
| 55 virtual bool IsVisibleToExtension( | 60 virtual bool IsVisibleToExtension( |
| 56 const extensions::Extension* extension) const OVERRIDE; | 61 const extensions::Extension* extension) const OVERRIDE; |
| 57 | 62 |
| 58 private: | 63 private: |
| 59 Panel* panel_; // Weak pointer. Owns us. | 64 Panel* panel_; // Weak pointer. Owns us. |
| 60 DISALLOW_COPY_AND_ASSIGN(PanelExtensionWindowController); | 65 DISALLOW_COPY_AND_ASSIGN(PanelExtensionWindowController); |
| 61 }; | 66 }; |
| (...skipping 11 matching lines...) Expand all Loading... |
| 73 | 78 |
| 74 int PanelExtensionWindowController::GetWindowId() const { | 79 int PanelExtensionWindowController::GetWindowId() const { |
| 75 return static_cast<int>(panel_->session_id().id()); | 80 return static_cast<int>(panel_->session_id().id()); |
| 76 } | 81 } |
| 77 | 82 |
| 78 std::string PanelExtensionWindowController::GetWindowTypeText() const { | 83 std::string PanelExtensionWindowController::GetWindowTypeText() const { |
| 79 return extensions::tabs_constants::kWindowTypeValuePanel; | 84 return extensions::tabs_constants::kWindowTypeValuePanel; |
| 80 } | 85 } |
| 81 | 86 |
| 82 base::DictionaryValue* | 87 base::DictionaryValue* |
| 83 PanelExtensionWindowController::CreateWindowValueWithTabs() const { | 88 PanelExtensionWindowController::CreateWindowValueWithTabs( |
| 89 const extensions::Extension* extension) const { |
| 84 base::DictionaryValue* result = CreateWindowValue(); | 90 base::DictionaryValue* result = CreateWindowValue(); |
| 85 | 91 |
| 86 // Safe to include info about the web contents as this is only called | 92 DCHECK(IsVisibleToExtension(extension)); |
| 87 // by the extension that owns this window. See IsVisibleToExtension(). | |
| 88 // TODO(jennb): DCHECK this after chebert's patch 10829186 lands. | |
| 89 content::WebContents* web_contents = panel_->GetWebContents(); | 93 content::WebContents* web_contents = panel_->GetWebContents(); |
| 90 if (web_contents) { | 94 if (web_contents) { |
| 91 DictionaryValue* tab_value = new DictionaryValue(); | 95 DictionaryValue* tab_value = new DictionaryValue(); |
| 92 // TabId must be >= 0. Use panel session id to avoid conflict with | 96 // TabId must be >= 0. Use panel session id to avoid conflict with |
| 93 // browser tab ids (which are also session ids). | 97 // browser tab ids (which are also session ids). |
| 94 tab_value->SetInteger(extensions::tabs_constants::kIdKey, | 98 tab_value->SetInteger(extensions::tabs_constants::kIdKey, |
| 95 panel_->session_id().id()); | 99 panel_->session_id().id()); |
| 96 tab_value->SetInteger(extensions::tabs_constants::kIndexKey, 0); | 100 tab_value->SetInteger(extensions::tabs_constants::kIndexKey, 0); |
| 97 tab_value->SetInteger( | 101 tab_value->SetInteger( |
| 98 extensions::tabs_constants::kWindowIdKey, GetWindowId()); | 102 extensions::tabs_constants::kWindowIdKey, GetWindowId()); |
| (...skipping 704 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 803 | 807 |
| 804 void Panel::LoadingStateChanged(bool is_loading) { | 808 void Panel::LoadingStateChanged(bool is_loading) { |
| 805 command_updater_.UpdateCommandEnabled(IDC_STOP, is_loading); | 809 command_updater_.UpdateCommandEnabled(IDC_STOP, is_loading); |
| 806 native_panel_->UpdatePanelLoadingAnimations(is_loading); | 810 native_panel_->UpdatePanelLoadingAnimations(is_loading); |
| 807 UpdateTitleBar(); | 811 UpdateTitleBar(); |
| 808 } | 812 } |
| 809 | 813 |
| 810 void Panel::WebContentsFocused(content::WebContents* contents) { | 814 void Panel::WebContentsFocused(content::WebContents* contents) { |
| 811 native_panel_->PanelWebContentsFocused(contents); | 815 native_panel_->PanelWebContentsFocused(contents); |
| 812 } | 816 } |
| OLD | NEW |