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

Unified Diff: chrome/browser/tab_contents/web_contents_view_mac.mm

Issue 20334: Sad Tab view for the Mac. (Closed) Base URL: svn://chrome-svn/chrome/trunk/src/
Patch Set: '' Created 11 years, 10 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 side-by-side diff with in-line comments
Download patch
« no previous file with comments | « chrome/browser/tab_contents/web_contents_view_mac.h ('k') | chrome/chrome.xcodeproj/project.pbxproj » ('j') | no next file with comments »
Expand Comments ('e') | Collapse Comments ('c') | Show Comments Hide Comments ('s')
Index: chrome/browser/tab_contents/web_contents_view_mac.mm
===================================================================
--- chrome/browser/tab_contents/web_contents_view_mac.mm (revision 9874)
+++ chrome/browser/tab_contents/web_contents_view_mac.mm (working copy)
@@ -5,6 +5,7 @@
#include "chrome/browser/tab_contents/web_contents_view_mac.h"
#include "chrome/browser/browser.h" // TODO(beng): this dependency is awful.
+#include "chrome/browser/cocoa/sad_tab_view.h"
#include "chrome/browser/renderer_host/render_widget_host.h"
#include "chrome/browser/renderer_host/render_widget_host_view_mac.h"
#include "chrome/browser/tab_contents/web_contents.h"
@@ -18,6 +19,10 @@
WebContentsViewMac::WebContentsViewMac(WebContents* web_contents)
: web_contents_(web_contents) {
+ registrar_.Add(this, NotificationType::WEB_CONTENTS_CONNECTED,
+ Source<WebContents>(web_contents));
+ registrar_.Add(this, NotificationType::WEB_CONTENTS_DISCONNECTED,
+ Source<WebContents>(web_contents));
}
WebContentsViewMac::~WebContentsViewMac() {
@@ -232,6 +237,34 @@
widget_host->Init();
}
+void WebContentsViewMac::Observe(NotificationType type,
+ const NotificationSource& source,
+ const NotificationDetails& details) {
+ switch (type.value) {
+ case NotificationType::WEB_CONTENTS_CONNECTED: {
+ if (sad_tab_.get()) {
+ [sad_tab_.get() removeFromSuperview];
+ sad_tab_.reset();
+ }
+ break;
+ }
+ case NotificationType::WEB_CONTENTS_DISCONNECTED: {
+ SadTabView* view = [[SadTabView alloc] initWithFrame:NSZeroRect];
+ CFRetain(view);
+ [view release];
+ sad_tab_.reset(view);
+
+ // Set as the dominant child.
+ [cocoa_view_.get() addSubview:view];
+ [view setFrame:[cocoa_view_.get() bounds]];
+ [view setAutoresizingMask:NSViewWidthSizable | NSViewHeightSizable];
+ break;
+ }
+ default:
+ NOTREACHED() << "Got a notification we didn't register for.";
+ }
+}
+
@implementation WebContentsViewCocoa
// Tons of stuff goes here, where we grab events going on in Cocoaland and send
« no previous file with comments | « chrome/browser/tab_contents/web_contents_view_mac.h ('k') | chrome/chrome.xcodeproj/project.pbxproj » ('j') | no next file with comments »

Powered by Google App Engine
This is Rietveld 408576698