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 316 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
545 case IDC_RELOAD: | 547 case IDC_RELOAD: |
546 panel_host_->Reload(); | 548 panel_host_->Reload(); |
547 break; | 549 break; |
548 case IDC_RELOAD_IGNORING_CACHE: | 550 case IDC_RELOAD_IGNORING_CACHE: |
549 panel_host_->ReloadIgnoringCache(); | 551 panel_host_->ReloadIgnoringCache(); |
550 break; | 552 break; |
551 case IDC_STOP: | 553 case IDC_STOP: |
552 panel_host_->StopLoading(); | 554 panel_host_->StopLoading(); |
553 break; | 555 break; |
554 | 556 |
| 557 // Window management. |
| 558 case IDC_CLOSE_WINDOW: |
| 559 content::RecordAction(UserMetricsAction("CloseWindow")); |
| 560 Close(); |
| 561 break; |
| 562 case IDC_EXIT: |
| 563 content::RecordAction(UserMetricsAction("Exit")); |
| 564 browser::AttemptUserExit(); |
| 565 break; |
| 566 |
555 // Clipboard | 567 // Clipboard |
556 case IDC_COPY: | 568 case IDC_COPY: |
557 content::RecordAction(UserMetricsAction("Copy")); | 569 content::RecordAction(UserMetricsAction("Copy")); |
558 native_panel_->PanelCopy(); | 570 native_panel_->PanelCopy(); |
559 break; | 571 break; |
560 case IDC_CUT: | 572 case IDC_CUT: |
561 content::RecordAction(UserMetricsAction("Cut")); | 573 content::RecordAction(UserMetricsAction("Cut")); |
562 native_panel_->PanelCut(); | 574 native_panel_->PanelCut(); |
563 break; | 575 break; |
564 case IDC_PASTE: | 576 case IDC_PASTE: |
(...skipping 186 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
751 | 763 |
752 void Panel::LoadingStateChanged(bool is_loading) { | 764 void Panel::LoadingStateChanged(bool is_loading) { |
753 command_updater_.UpdateCommandEnabled(IDC_STOP, is_loading); | 765 command_updater_.UpdateCommandEnabled(IDC_STOP, is_loading); |
754 native_panel_->UpdatePanelLoadingAnimations(is_loading); | 766 native_panel_->UpdatePanelLoadingAnimations(is_loading); |
755 UpdateTitleBar(); | 767 UpdateTitleBar(); |
756 } | 768 } |
757 | 769 |
758 void Panel::WebContentsFocused(content::WebContents* contents) { | 770 void Panel::WebContentsFocused(content::WebContents* contents) { |
759 native_panel_->PanelWebContentsFocused(contents); | 771 native_panel_->PanelWebContentsFocused(contents); |
760 } | 772 } |
OLD | NEW |