OLD | NEW |
1 // Copyright (c) 2011 The Chromium Authors. All rights reserved. | 1 // Copyright (c) 2011 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 "chrome/browser/extensions/extension_prefs.h" | 8 #include "chrome/browser/extensions/extension_prefs.h" |
9 #include "chrome/browser/extensions/extension_service.h" | 9 #include "chrome/browser/extensions/extension_service.h" |
10 #include "chrome/browser/profiles/profile.h" | 10 #include "chrome/browser/profiles/profile.h" |
11 #include "chrome/browser/ui/browser.h" | 11 #include "chrome/browser/ui/browser.h" |
12 #include "chrome/browser/ui/panels/native_panel.h" | 12 #include "chrome/browser/ui/panels/native_panel.h" |
13 #include "chrome/browser/ui/panels/panel_manager.h" | 13 #include "chrome/browser/ui/panels/panel_manager.h" |
14 #include "chrome/browser/web_applications/web_app.h" | 14 #include "chrome/browser/web_applications/web_app.h" |
15 #include "chrome/common/extensions/extension.h" | 15 #include "chrome/common/extensions/extension.h" |
16 #include "ui/gfx/rect.h" | 16 #include "ui/gfx/rect.h" |
17 | 17 |
18 // static | 18 // static |
19 const Extension* Panel::GetExtension(Browser* browser) { | 19 const Extension* Panel::GetExtension(Browser* browser) { |
20 // Find the extension. When we create a panel from an extension, the extension | 20 // Find the extension. When we create a panel from an extension, the extension |
21 // ID is passed as the app name to the Browser. | 21 // ID is passed as the app name to the Browser. |
22 ExtensionService* extension_service = | 22 ExtensionService* extension_service = |
23 browser->GetProfile()->GetExtensionService(); | 23 browser->GetProfile()->GetExtensionService(); |
24 return extension_service->GetExtensionById( | 24 return extension_service->GetExtensionById( |
25 web_app::GetExtensionIdFromApplicationName(browser->app_name()), false); | 25 web_app::GetExtensionIdFromApplicationName(browser->app_name()), false); |
26 } | 26 } |
27 | 27 |
28 Panel::Panel(Browser* browser, const gfx::Rect& bounds) { | 28 Panel::Panel(Browser* browser, const gfx::Rect& bounds) |
| 29 : native_panel_(NULL), |
| 30 expansion_state_(EXPANDED) { |
29 native_panel_ = CreateNativePanel(browser, this, bounds); | 31 native_panel_ = CreateNativePanel(browser, this, bounds); |
30 } | 32 } |
31 | 33 |
32 Panel::~Panel() { | 34 Panel::~Panel() { |
33 // Invoked by native panel so do not access native_panel_ here. | 35 // Invoked by native panel so do not access native_panel_ here. |
34 } | 36 } |
35 | 37 |
36 PanelManager* Panel::manager() const { | 38 PanelManager* Panel::manager() const { |
37 return PanelManager::GetInstance(); | 39 return PanelManager::GetInstance(); |
38 } | 40 } |
39 | 41 |
40 void Panel::SetPanelBounds(const gfx::Rect& bounds) { | 42 void Panel::SetPanelBounds(const gfx::Rect& bounds) { |
41 native_panel_->SetPanelBounds(bounds); | 43 native_panel_->SetPanelBounds(bounds); |
42 } | 44 } |
43 | 45 |
44 void Panel::Minimize() { | 46 void Panel::SetExpansionState(ExpansionState new_expansion_state) { |
45 native_panel_->MinimizePanel(); | 47 if (expansion_state_ == new_expansion_state) |
| 48 return; |
| 49 expansion_state_ = new_expansion_state; |
| 50 |
| 51 native_panel_->OnPanelExpansionStateChanged(expansion_state_); |
46 } | 52 } |
47 | 53 |
48 void Panel::Restore() { | 54 bool Panel::ShouldBringUpTitleBar(int mouse_x, int mouse_y) const { |
49 native_panel_->RestorePanel(); | 55 // Skip the expanded panel. |
| 56 if (expansion_state_ == Panel::EXPANDED) |
| 57 return false; |
| 58 |
| 59 // Let the native panel decide. |
| 60 return native_panel_->ShouldBringUpPanelTitleBar(mouse_x, mouse_y); |
50 } | 61 } |
51 | 62 |
52 void Panel::Show() { | 63 void Panel::Show() { |
53 native_panel_->ShowPanel(); | 64 native_panel_->ShowPanel(); |
54 } | 65 } |
55 | 66 |
56 void Panel::ShowInactive() { | 67 void Panel::ShowInactive() { |
57 native_panel_->ShowPanelInactive(); | 68 native_panel_->ShowPanelInactive(); |
58 } | 69 } |
59 | 70 |
(...skipping 313 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
373 | 384 |
374 #if defined(OS_CHROMEOS) | 385 #if defined(OS_CHROMEOS) |
375 void Panel::ShowKeyboardOverlay(gfx::NativeWindow owning_window) { | 386 void Panel::ShowKeyboardOverlay(gfx::NativeWindow owning_window) { |
376 NOTIMPLEMENTED(); | 387 NOTIMPLEMENTED(); |
377 } | 388 } |
378 #endif | 389 #endif |
379 | 390 |
380 void Panel::DestroyBrowser() { | 391 void Panel::DestroyBrowser() { |
381 native_panel_->DestroyPanelBrowser(); | 392 native_panel_->DestroyPanelBrowser(); |
382 } | 393 } |
OLD | NEW |