| 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 84 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 95 bool PanelExtensionWindowController::IsVisibleToExtension( | 95 bool PanelExtensionWindowController::IsVisibleToExtension( |
| 96 const extensions::Extension* extension) const { | 96 const extensions::Extension* extension) const { |
| 97 return extension->id() == panel_->extension_id(); | 97 return extension->id() == panel_->extension_id(); |
| 98 } | 98 } |
| 99 | 99 |
| 100 } // namespace internal | 100 } // namespace internal |
| 101 | 101 |
| 102 Panel::Panel(const std::string& app_name, | 102 Panel::Panel(const std::string& app_name, |
| 103 const gfx::Size& min_size, const gfx::Size& max_size) | 103 const gfx::Size& min_size, const gfx::Size& max_size) |
| 104 : app_name_(app_name), | 104 : app_name_(app_name), |
| 105 profile_(NULL), |
| 105 panel_strip_(NULL), | 106 panel_strip_(NULL), |
| 106 initialized_(false), | 107 initialized_(false), |
| 107 min_size_(min_size), | 108 min_size_(min_size), |
| 108 max_size_(max_size), | 109 max_size_(max_size), |
| 109 max_size_policy_(DEFAULT_MAX_SIZE), | 110 max_size_policy_(DEFAULT_MAX_SIZE), |
| 110 auto_resizable_(false), | 111 auto_resizable_(false), |
| 111 always_on_top_(false), | 112 always_on_top_(false), |
| 112 in_preview_mode_(false), | 113 in_preview_mode_(false), |
| 113 native_panel_(NULL), | 114 native_panel_(NULL), |
| 114 attention_mode_(USE_PANEL_ATTENTION), | 115 attention_mode_(USE_PANEL_ATTENTION), |
| (...skipping 20 matching lines...) Expand all Loading... |
| 135 native_panel_ = CreateNativePanel(browser, this, bounds); | 136 native_panel_ = CreateNativePanel(browser, this, bounds); |
| 136 } | 137 } |
| 137 | 138 |
| 138 void Panel::Initialize(Profile* profile, const GURL& url, | 139 void Panel::Initialize(Profile* profile, const GURL& url, |
| 139 const gfx::Rect& bounds) { | 140 const gfx::Rect& bounds) { |
| 140 DCHECK(!initialized_); | 141 DCHECK(!initialized_); |
| 141 DCHECK(!panel_strip_); // Cannot be added to a strip until fully created. | 142 DCHECK(!panel_strip_); // Cannot be added to a strip until fully created. |
| 142 DCHECK_EQ(EXPANDED, expansion_state_); | 143 DCHECK_EQ(EXPANDED, expansion_state_); |
| 143 DCHECK(!bounds.IsEmpty()); | 144 DCHECK(!bounds.IsEmpty()); |
| 144 initialized_ = true; | 145 initialized_ = true; |
| 146 profile_ = profile; |
| 145 full_size_ = bounds.size(); | 147 full_size_ = bounds.size(); |
| 146 native_panel_ = CreateNativePanel(this, bounds); | 148 native_panel_ = CreateNativePanel(this, bounds); |
| 147 | 149 |
| 148 extension_window_controller_.reset( | 150 extension_window_controller_.reset( |
| 149 new panel_internal::PanelExtensionWindowController(this, profile)); | 151 new panel_internal::PanelExtensionWindowController(this, profile)); |
| 150 | 152 |
| 151 InitCommandState(); | 153 InitCommandState(); |
| 152 | 154 |
| 153 // Set up hosting for web contents. | 155 // Set up hosting for web contents. |
| 154 panel_host_.reset(new PanelHost(this, profile)); | 156 panel_host_.reset(new PanelHost(this, profile)); |
| (...skipping 53 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 208 | 210 |
| 209 BrowserWindow* Panel::browser_window() const { | 211 BrowserWindow* Panel::browser_window() const { |
| 210 return NULL; | 212 return NULL; |
| 211 } | 213 } |
| 212 | 214 |
| 213 CommandUpdater* Panel::command_updater() { | 215 CommandUpdater* Panel::command_updater() { |
| 214 return &command_updater_; | 216 return &command_updater_; |
| 215 } | 217 } |
| 216 | 218 |
| 217 Profile* Panel::profile() const { | 219 Profile* Panel::profile() const { |
| 218 return extension_window_controller_->profile(); | 220 return profile_; |
| 219 } | 221 } |
| 220 | 222 |
| 221 const std::string Panel::extension_id() const { | 223 const std::string Panel::extension_id() const { |
| 222 return web_app::GetExtensionIdFromApplicationName(app_name_); | 224 return web_app::GetExtensionIdFromApplicationName(app_name_); |
| 223 } | 225 } |
| 224 | 226 |
| 225 content::WebContents* Panel::GetWebContents() const { | 227 content::WebContents* Panel::GetWebContents() const { |
| 226 return panel_host_.get() ? panel_host_->web_contents() : NULL; | 228 return panel_host_.get() ? panel_host_->web_contents() : NULL; |
| 227 } | 229 } |
| 228 | 230 |
| (...skipping 529 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 758 | 760 |
| 759 void Panel::LoadingStateChanged(bool is_loading) { | 761 void Panel::LoadingStateChanged(bool is_loading) { |
| 760 command_updater_.UpdateCommandEnabled(IDC_STOP, is_loading); | 762 command_updater_.UpdateCommandEnabled(IDC_STOP, is_loading); |
| 761 native_panel_->UpdatePanelLoadingAnimations(is_loading); | 763 native_panel_->UpdatePanelLoadingAnimations(is_loading); |
| 762 UpdateTitleBar(); | 764 UpdateTitleBar(); |
| 763 } | 765 } |
| 764 | 766 |
| 765 void Panel::WebContentsFocused(content::WebContents* contents) { | 767 void Panel::WebContentsFocused(content::WebContents* contents) { |
| 766 native_panel_->PanelWebContentsFocused(contents); | 768 native_panel_->PanelWebContentsFocused(contents); |
| 767 } | 769 } |
| OLD | NEW |