Chromium Code Reviews
chromiumcodereview-hr@appspot.gserviceaccount.com (chromiumcodereview-hr) | Please choose your nickname with Settings | Help | Chromium Project | Gerrit Changes | Sign out
(449)

Side by Side Diff: chrome/browser/ui/panels/panel.cc

Issue 11669018: Support dragging panels to stack and snap. (Closed) Base URL: svn://svn.chromium.org/chrome/trunk/src
Patch Set: Fix per feedback Created 7 years, 11 months ago
Use n/p to move between diff chunks; N/P to move between comments. Draft comments are only viewable by you.
Jump to:
View unified diff | Download patch | Annotate | Revision Log
OLDNEW
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/devtools/devtools_window.h" 11 #include "chrome/browser/devtools/devtools_window.h"
12 #include "chrome/browser/extensions/api/tabs/tabs_constants.h" 12 #include "chrome/browser/extensions/api/tabs/tabs_constants.h"
13 #include "chrome/browser/extensions/api/tabs/tabs_windows_api.h" 13 #include "chrome/browser/extensions/api/tabs/tabs_windows_api.h"
14 #include "chrome/browser/extensions/api/tabs/windows_event_router.h" 14 #include "chrome/browser/extensions/api/tabs/windows_event_router.h"
15 #include "chrome/browser/extensions/extension_service.h" 15 #include "chrome/browser/extensions/extension_service.h"
16 #include "chrome/browser/extensions/extension_system.h" 16 #include "chrome/browser/extensions/extension_system.h"
17 #include "chrome/browser/extensions/extension_tab_util.h" 17 #include "chrome/browser/extensions/extension_tab_util.h"
18 #include "chrome/browser/extensions/window_controller.h" 18 #include "chrome/browser/extensions/window_controller.h"
19 #include "chrome/browser/extensions/window_controller_list.h" 19 #include "chrome/browser/extensions/window_controller_list.h"
20 #include "chrome/browser/lifetime/application_lifetime.h" 20 #include "chrome/browser/lifetime/application_lifetime.h"
21 #include "chrome/browser/profiles/profile.h" 21 #include "chrome/browser/profiles/profile.h"
22 #include "chrome/browser/themes/theme_service.h" 22 #include "chrome/browser/themes/theme_service.h"
23 #include "chrome/browser/themes/theme_service_factory.h" 23 #include "chrome/browser/themes/theme_service_factory.h"
24 #include "chrome/browser/ui/panels/native_panel.h" 24 #include "chrome/browser/ui/panels/native_panel.h"
25 #include "chrome/browser/ui/panels/panel_collection.h" 25 #include "chrome/browser/ui/panels/panel_collection.h"
26 #include "chrome/browser/ui/panels/panel_host.h" 26 #include "chrome/browser/ui/panels/panel_host.h"
27 #include "chrome/browser/ui/panels/panel_manager.h" 27 #include "chrome/browser/ui/panels/panel_manager.h"
28 #include "chrome/browser/ui/panels/stacked_panel_collection.h"
28 #include "chrome/browser/web_applications/web_app.h" 29 #include "chrome/browser/web_applications/web_app.h"
29 #include "chrome/common/chrome_notification_types.h" 30 #include "chrome/common/chrome_notification_types.h"
30 #include "chrome/common/extensions/extension.h" 31 #include "chrome/common/extensions/extension.h"
31 #include "content/public/browser/notification_service.h" 32 #include "content/public/browser/notification_service.h"
32 #include "content/public/browser/notification_source.h" 33 #include "content/public/browser/notification_source.h"
33 #include "content/public/browser/notification_types.h" 34 #include "content/public/browser/notification_types.h"
34 #include "content/public/browser/render_view_host.h" 35 #include "content/public/browser/render_view_host.h"
35 #include "content/public/browser/user_metrics.h" 36 #include "content/public/browser/user_metrics.h"
36 #include "content/public/browser/web_contents.h" 37 #include "content/public/browser/web_contents.h"
37 #include "ui/gfx/image/image.h" 38 #include "ui/gfx/image/image.h"
(...skipping 200 matching lines...) Expand 10 before | Expand all | Expand 10 after
238 } 239 }
239 240
240 Profile* Panel::profile() const { 241 Profile* Panel::profile() const {
241 return profile_; 242 return profile_;
242 } 243 }
243 244
244 const std::string Panel::extension_id() const { 245 const std::string Panel::extension_id() const {
245 return web_app::GetExtensionIdFromApplicationName(app_name_); 246 return web_app::GetExtensionIdFromApplicationName(app_name_);
246 } 247 }
247 248
249 StackedPanelCollection* Panel::stack() const {
250 return collection_ && collection_->type() == PanelCollection::STACKED ?
251 static_cast<StackedPanelCollection*>(collection_) : NULL;
252 }
253
248 content::WebContents* Panel::GetWebContents() const { 254 content::WebContents* Panel::GetWebContents() const {
249 return panel_host_.get() ? panel_host_->web_contents() : NULL; 255 return panel_host_.get() ? panel_host_->web_contents() : NULL;
250 } 256 }
251 257
252 bool Panel::CanMinimize() const { 258 bool Panel::CanMinimize() const {
253 return collection_ && collection_->CanMinimizePanel(this) && !IsMinimized(); 259 return collection_ && collection_->CanMinimizePanel(this) && !IsMinimized();
254 } 260 }
255 261
256 bool Panel::CanRestore() const { 262 bool Panel::CanRestore() const {
257 return collection_ && collection_->CanMinimizePanel(this) && IsMinimized(); 263 return collection_ && collection_->CanMinimizePanel(this) && IsMinimized();
(...skipping 544 matching lines...) Expand 10 before | Expand all | Expand 10 after
802 void Panel::LoadingStateChanged(bool is_loading) { 808 void Panel::LoadingStateChanged(bool is_loading) {
803 command_updater_.UpdateCommandEnabled(IDC_STOP, is_loading); 809 command_updater_.UpdateCommandEnabled(IDC_STOP, is_loading);
804 native_panel_->UpdatePanelLoadingAnimations(is_loading); 810 native_panel_->UpdatePanelLoadingAnimations(is_loading);
805 UpdateTitleBar(); 811 UpdateTitleBar();
806 } 812 }
807 813
808 void Panel::WebContentsFocused(content::WebContents* contents) { 814 void Panel::WebContentsFocused(content::WebContents* contents) {
809 native_panel_->PanelWebContentsFocused(contents); 815 native_panel_->PanelWebContentsFocused(contents);
810 } 816 }
811 817
818 void Panel::MoveByInstantly(const gfx::Vector2d& delta_origin) {
819 gfx::Rect bounds = GetBounds();
820 bounds.Offset(delta_origin);
821 SetPanelBoundsInstantly(bounds);
822 }
823
812 const extensions::Extension* Panel::GetExtension() const { 824 const extensions::Extension* Panel::GetExtension() const {
813 ExtensionService* extension_service = 825 ExtensionService* extension_service =
814 extensions::ExtensionSystem::Get(profile())->extension_service(); 826 extensions::ExtensionSystem::Get(profile())->extension_service();
815 if (!extension_service || !extension_service->is_ready()) 827 if (!extension_service || !extension_service->is_ready())
816 return NULL; 828 return NULL;
817 return extension_service->GetExtensionById(extension_id(), false); 829 return extension_service->GetExtensionById(extension_id(), false);
818 } 830 }
819 831
820 void Panel::UpdateAppIcon() { 832 void Panel::UpdateAppIcon() {
821 const extensions::Extension* extension = GetExtension(); 833 const extensions::Extension* extension = GetExtension();
(...skipping 17 matching lines...) Expand all
839 app_icon_ = image; 851 app_icon_ = image;
840 native_panel_->UpdatePanelTitleBar(); 852 native_panel_->UpdatePanelTitleBar();
841 } 853 }
842 app_icon_loader_.reset(); 854 app_icon_loader_.reset();
843 855
844 content::NotificationService::current()->Notify( 856 content::NotificationService::current()->Notify(
845 chrome::NOTIFICATION_PANEL_APP_ICON_LOADED, 857 chrome::NOTIFICATION_PANEL_APP_ICON_LOADED,
846 content::Source<Panel>(this), 858 content::Source<Panel>(this),
847 content::NotificationService::NoDetails()); 859 content::NotificationService::NoDetails());
848 } 860 }
OLDNEW

Powered by Google App Engine
This is Rietveld 408576698