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

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

Issue 409983002: Revert 284725 "Use ExtensionRegistryObserver instead of DEPRECAT..." (Closed) Base URL: svn://svn.chromium.org/chrome/
Patch Set: Created 6 years, 5 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/message_loop.h" 8 #include "base/message_loop/message_loop.h"
9 #include "base/strings/utf_string_conversions.h" 9 #include "base/strings/utf_string_conversions.h"
10 #include "chrome/app/chrome_command_ids.h" 10 #include "chrome/app/chrome_command_ids.h"
(...skipping 15 matching lines...) Expand all
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/ui/panels/stacked_panel_collection.h"
29 #include "chrome/browser/web_applications/web_app.h" 29 #include "chrome/browser/web_applications/web_app.h"
30 #include "content/public/browser/notification_service.h" 30 #include "content/public/browser/notification_service.h"
31 #include "content/public/browser/notification_source.h" 31 #include "content/public/browser/notification_source.h"
32 #include "content/public/browser/notification_types.h" 32 #include "content/public/browser/notification_types.h"
33 #include "content/public/browser/render_view_host.h" 33 #include "content/public/browser/render_view_host.h"
34 #include "content/public/browser/user_metrics.h" 34 #include "content/public/browser/user_metrics.h"
35 #include "content/public/browser/web_contents.h" 35 #include "content/public/browser/web_contents.h"
36 #include "extensions/browser/extension_registry.h"
37 #include "extensions/browser/extension_system.h" 36 #include "extensions/browser/extension_system.h"
38 #include "extensions/browser/image_loader.h" 37 #include "extensions/browser/image_loader.h"
39 #include "extensions/common/constants.h" 38 #include "extensions/common/constants.h"
40 #include "extensions/common/extension.h" 39 #include "extensions/common/extension.h"
41 #include "extensions/common/manifest_handlers/icons_handler.h" 40 #include "extensions/common/manifest_handlers/icons_handler.h"
42 #include "ui/gfx/image/image.h" 41 #include "ui/gfx/image/image.h"
43 #include "ui/gfx/rect.h" 42 #include "ui/gfx/rect.h"
44 43
45 using base::UserMetricsAction; 44 using base::UserMetricsAction;
46 using content::RenderViewHost; 45 using content::RenderViewHost;
(...skipping 386 matching lines...) Expand 10 before | Expand all | Expand 10 after
433 } 432 }
434 } 433 }
435 434
436 void Panel::Observe(int type, 435 void Panel::Observe(int type,
437 const content::NotificationSource& source, 436 const content::NotificationSource& source,
438 const content::NotificationDetails& details) { 437 const content::NotificationDetails& details) {
439 switch (type) { 438 switch (type) {
440 case content::NOTIFICATION_RENDER_VIEW_HOST_CHANGED: 439 case content::NOTIFICATION_RENDER_VIEW_HOST_CHANGED:
441 ConfigureAutoResize(content::Source<content::WebContents>(source).ptr()); 440 ConfigureAutoResize(content::Source<content::WebContents>(source).ptr());
442 break; 441 break;
442 case chrome::NOTIFICATION_EXTENSION_UNLOADED_DEPRECATED:
443 if (content::Details<extensions::UnloadedExtensionInfo>(
444 details)->extension->id() == extension_id())
445 Close();
446 break;
443 case chrome::NOTIFICATION_APP_TERMINATING: 447 case chrome::NOTIFICATION_APP_TERMINATING:
444 Close(); 448 Close();
445 break; 449 break;
446 default: 450 default:
447 NOTREACHED() << "Received unexpected notification " << type; 451 NOTREACHED() << "Received unexpected notification " << type;
448 } 452 }
449 } 453 }
450 454
451 void Panel::OnExtensionUnloaded(
452 content::BrowserContext* browser_context,
453 const extensions::Extension* extension,
454 extensions::UnloadedExtensionInfo::Reason reason) {
455 if (extension->id() == extension_id())
456 Close();
457 }
458
459 void Panel::OnTitlebarClicked(panel::ClickModifier modifier) { 455 void Panel::OnTitlebarClicked(panel::ClickModifier modifier) {
460 if (collection_) 456 if (collection_)
461 collection_->OnPanelTitlebarClicked(this, modifier); 457 collection_->OnPanelTitlebarClicked(this, modifier);
462 458
463 // Normally the system activates a window when the titlebar is clicked. 459 // Normally the system activates a window when the titlebar is clicked.
464 // However, we prevent system activation of minimized panels, thus the 460 // However, we prevent system activation of minimized panels, thus the
465 // activation may not have occurred. Also, some OSes (Windows) will 461 // activation may not have occurred. Also, some OSes (Windows) will
466 // activate a minimized panel on mouse-down regardless of our attempts to 462 // activate a minimized panel on mouse-down regardless of our attempts to
467 // prevent system activation. Attention state is not cleared in that case. 463 // prevent system activation. Attention state is not cleared in that case.
468 // See Panel::OnActiveStateChanged(). 464 // See Panel::OnActiveStateChanged().
(...skipping 60 matching lines...) Expand 10 before | Expand all | Expand 10 after
529 525
530 // Set up hosting for web contents. 526 // Set up hosting for web contents.
531 panel_host_.reset(new PanelHost(this, profile_)); 527 panel_host_.reset(new PanelHost(this, profile_));
532 panel_host_->Init(url); 528 panel_host_->Init(url);
533 content::WebContents* web_contents = GetWebContents(); 529 content::WebContents* web_contents = GetWebContents();
534 // The contents might be NULL for most of our tests. 530 // The contents might be NULL for most of our tests.
535 if (web_contents) 531 if (web_contents)
536 native_panel_->AttachWebContents(web_contents); 532 native_panel_->AttachWebContents(web_contents);
537 533
538 // Close when the extension is unloaded or the browser is exiting. 534 // Close when the extension is unloaded or the browser is exiting.
539 extension_registry_observer_.Add( 535 registrar_.Add(this, chrome::NOTIFICATION_EXTENSION_UNLOADED_DEPRECATED,
540 extensions::ExtensionRegistry::Get(profile_)); 536 content::Source<Profile>(profile_));
541 registrar_.Add(this, chrome::NOTIFICATION_APP_TERMINATING, 537 registrar_.Add(this, chrome::NOTIFICATION_APP_TERMINATING,
542 content::NotificationService::AllSources()); 538 content::NotificationService::AllSources());
543 registrar_.Add(this, chrome::NOTIFICATION_BROWSER_THEME_CHANGED, 539 registrar_.Add(this, chrome::NOTIFICATION_BROWSER_THEME_CHANGED,
544 content::Source<ThemeService>( 540 content::Source<ThemeService>(
545 ThemeServiceFactory::GetForProfile(profile_))); 541 ThemeServiceFactory::GetForProfile(profile_)));
546 542
547 #if !defined(USE_AURA) 543 #if !defined(USE_AURA)
548 // Keep alive for AURA has been moved to panel_view. 544 // Keep alive for AURA has been moved to panel_view.
549 // Prevent the browser process from shutting down while this window is open. 545 // Prevent the browser process from shutting down while this window is open.
550 chrome::IncrementKeepAliveCount(); 546 chrome::IncrementKeepAliveCount();
(...skipping 261 matching lines...) Expand 10 before | Expand all | Expand 10 after
812 initialized_(false), 808 initialized_(false),
813 min_size_(min_size), 809 min_size_(min_size),
814 max_size_(max_size), 810 max_size_(max_size),
815 max_size_policy_(DEFAULT_MAX_SIZE), 811 max_size_policy_(DEFAULT_MAX_SIZE),
816 auto_resizable_(false), 812 auto_resizable_(false),
817 in_preview_mode_(false), 813 in_preview_mode_(false),
818 native_panel_(NULL), 814 native_panel_(NULL),
819 attention_mode_(USE_PANEL_ATTENTION), 815 attention_mode_(USE_PANEL_ATTENTION),
820 expansion_state_(EXPANDED), 816 expansion_state_(EXPANDED),
821 command_updater_(this), 817 command_updater_(this),
822 extension_registry_observer_(this),
823 image_loader_ptr_factory_(this) { 818 image_loader_ptr_factory_(this) {
824 } 819 }
825 820
826 void Panel::OnImageLoaded(const gfx::Image& image) { 821 void Panel::OnImageLoaded(const gfx::Image& image) {
827 if (!image.IsEmpty()) { 822 if (!image.IsEmpty()) {
828 app_icon_ = image; 823 app_icon_ = image;
829 native_panel_->UpdatePanelTitleBar(); 824 native_panel_->UpdatePanelTitleBar();
830 } 825 }
831 826
832 content::NotificationService::current()->Notify( 827 content::NotificationService::current()->Notify(
(...skipping 66 matching lines...) Expand 10 before | Expand all | Expand 10 after
899 // static 894 // static
900 void Panel::FormatTitleForDisplay(base::string16* title) { 895 void Panel::FormatTitleForDisplay(base::string16* title) {
901 size_t current_index = 0; 896 size_t current_index = 0;
902 size_t match_index; 897 size_t match_index;
903 while ((match_index = title->find(L'\n', current_index)) != 898 while ((match_index = title->find(L'\n', current_index)) !=
904 base::string16::npos) { 899 base::string16::npos) {
905 title->replace(match_index, 1, base::string16()); 900 title->replace(match_index, 1, base::string16());
906 current_index = match_index; 901 current_index = match_index;
907 } 902 }
908 } 903 }
OLDNEW
« no previous file with comments | « trunk/src/chrome/browser/ui/panels/panel.h ('k') | trunk/src/chrome/browser/ui/panels/panel_browsertest.cc » ('j') | no next file with comments »

Powered by Google App Engine
This is Rietveld 408576698