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

Side by Side Diff: chrome/browser/tabs/tab_strip_model.cc

Issue 7327007: Moving notification types which are chrome specific to a new header file chrome_notification_type... (Closed) Base URL: svn://svn.chromium.org/chrome/trunk/src/
Patch Set: '' Created 9 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
« no previous file with comments | « chrome/browser/tabs/tab_strip_model.h ('k') | chrome/browser/tabs/tab_strip_model_unittest.cc » ('j') | no next file with comments »
Toggle Intra-line Diffs ('i') | Expand Comments ('e') | Collapse Comments ('c') | Show Comments Hide Comments ('s')
OLDNEW
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/tabs/tab_strip_model.h" 5 #include "chrome/browser/tabs/tab_strip_model.h"
6 6
7 #include <algorithm> 7 #include <algorithm>
8 #include <map> 8 #include <map>
9 9
10 #include "base/command_line.h" 10 #include "base/command_line.h"
11 #include "base/stl_util-inl.h" 11 #include "base/stl_util-inl.h"
12 #include "base/string_util.h" 12 #include "base/string_util.h"
13 #include "build/build_config.h" 13 #include "build/build_config.h"
14 #include "chrome/app/chrome_command_ids.h" 14 #include "chrome/app/chrome_command_ids.h"
15 #include "chrome/browser/bookmarks/bookmark_model.h" 15 #include "chrome/browser/bookmarks/bookmark_model.h"
16 #include "chrome/browser/browser_shutdown.h" 16 #include "chrome/browser/browser_shutdown.h"
17 #include "chrome/browser/defaults.h" 17 #include "chrome/browser/defaults.h"
18 #include "chrome/browser/extensions/extension_service.h" 18 #include "chrome/browser/extensions/extension_service.h"
19 #include "chrome/browser/extensions/extension_tab_helper.h" 19 #include "chrome/browser/extensions/extension_tab_helper.h"
20 #include "chrome/browser/profiles/profile.h" 20 #include "chrome/browser/profiles/profile.h"
21 #include "chrome/browser/sessions/tab_restore_service.h" 21 #include "chrome/browser/sessions/tab_restore_service.h"
22 #include "chrome/browser/tabs/tab_strip_model_delegate.h" 22 #include "chrome/browser/tabs/tab_strip_model_delegate.h"
23 #include "chrome/browser/tabs/tab_strip_model_order_controller.h" 23 #include "chrome/browser/tabs/tab_strip_model_order_controller.h"
24 #include "chrome/browser/ui/tab_contents/tab_contents_wrapper.h" 24 #include "chrome/browser/ui/tab_contents/tab_contents_wrapper.h"
25 #include "chrome/common/chrome_notification_types.h"
25 #include "chrome/common/extensions/extension.h" 26 #include "chrome/common/extensions/extension.h"
26 #include "chrome/common/url_constants.h" 27 #include "chrome/common/url_constants.h"
27 #include "content/browser/renderer_host/render_process_host.h" 28 #include "content/browser/renderer_host/render_process_host.h"
28 #include "content/browser/tab_contents/navigation_controller.h" 29 #include "content/browser/tab_contents/navigation_controller.h"
29 #include "content/browser/tab_contents/tab_contents.h" 30 #include "content/browser/tab_contents/tab_contents.h"
30 #include "content/browser/tab_contents/tab_contents_delegate.h" 31 #include "content/browser/tab_contents/tab_contents_delegate.h"
31 #include "content/browser/tab_contents/tab_contents_view.h" 32 #include "content/browser/tab_contents/tab_contents_view.h"
32 #include "content/browser/user_metrics.h" 33 #include "content/browser/user_metrics.h"
33 #include "content/common/notification_service.h" 34 #include "content/common/notification_service.h"
34 35
(...skipping 24 matching lines...) Expand all
59 /////////////////////////////////////////////////////////////////////////////// 60 ///////////////////////////////////////////////////////////////////////////////
60 // TabStripModel, public: 61 // TabStripModel, public:
61 62
62 TabStripModel::TabStripModel(TabStripModelDelegate* delegate, Profile* profile) 63 TabStripModel::TabStripModel(TabStripModelDelegate* delegate, Profile* profile)
63 : delegate_(delegate), 64 : delegate_(delegate),
64 profile_(profile), 65 profile_(profile),
65 closing_all_(false), 66 closing_all_(false),
66 order_controller_(NULL) { 67 order_controller_(NULL) {
67 DCHECK(delegate_); 68 DCHECK(delegate_);
68 registrar_.Add(this, 69 registrar_.Add(this,
69 NotificationType::TAB_CONTENTS_DESTROYED, 70 content::NOTIFICATION_TAB_CONTENTS_DESTROYED,
70 NotificationService::AllSources()); 71 NotificationService::AllSources());
71 registrar_.Add(this, 72 registrar_.Add(this,
72 NotificationType::EXTENSION_UNLOADED, 73 chrome::NOTIFICATION_EXTENSION_UNLOADED,
73 Source<Profile>(profile_)); 74 Source<Profile>(profile_));
74 order_controller_ = new TabStripModelOrderController(this); 75 order_controller_ = new TabStripModelOrderController(this);
75 } 76 }
76 77
77 TabStripModel::~TabStripModel() { 78 TabStripModel::~TabStripModel() {
78 FOR_EACH_OBSERVER(TabStripModelObserver, observers_, 79 FOR_EACH_OBSERVER(TabStripModelObserver, observers_,
79 TabStripModelDeleted()); 80 TabStripModelDeleted());
80 STLDeleteContainerPointers(contents_data_.begin(), contents_data_.end()); 81 STLDeleteContainerPointers(contents_data_.begin(), contents_data_.end());
81 delete order_controller_; 82 delete order_controller_;
82 } 83 }
(...skipping 897 matching lines...) Expand 10 before | Expand all | Expand 10 after
980 for (size_t i = 0; i < indices.size() && all_pinned; ++i) { 981 for (size_t i = 0; i < indices.size() && all_pinned; ++i) {
981 if (!IsAppTab(index)) // We never change app tabs. 982 if (!IsAppTab(index)) // We never change app tabs.
982 all_pinned = IsTabPinned(indices[i]); 983 all_pinned = IsTabPinned(indices[i]);
983 } 984 }
984 return !all_pinned; 985 return !all_pinned;
985 } 986 }
986 987
987 /////////////////////////////////////////////////////////////////////////////// 988 ///////////////////////////////////////////////////////////////////////////////
988 // TabStripModel, NotificationObserver implementation: 989 // TabStripModel, NotificationObserver implementation:
989 990
990 void TabStripModel::Observe(NotificationType type, 991 void TabStripModel::Observe(int type,
991 const NotificationSource& source, 992 const NotificationSource& source,
992 const NotificationDetails& details) { 993 const NotificationDetails& details) {
993 switch (type.value) { 994 switch (type) {
994 case NotificationType::TAB_CONTENTS_DESTROYED: { 995 case content::NOTIFICATION_TAB_CONTENTS_DESTROYED: {
995 // Sometimes, on qemu, it seems like a TabContents object can be destroyed 996 // Sometimes, on qemu, it seems like a TabContents object can be destroyed
996 // while we still have a reference to it. We need to break this reference 997 // while we still have a reference to it. We need to break this reference
997 // here so we don't crash later. 998 // here so we don't crash later.
998 int index = GetWrapperIndex(Source<TabContents>(source).ptr()); 999 int index = GetWrapperIndex(Source<TabContents>(source).ptr());
999 if (index != TabStripModel::kNoTab) { 1000 if (index != TabStripModel::kNoTab) {
1000 // Note that we only detach the contents here, not close it - it's 1001 // Note that we only detach the contents here, not close it - it's
1001 // already been closed. We just want to undo our bookkeeping. 1002 // already been closed. We just want to undo our bookkeeping.
1002 DetachTabContentsAt(index); 1003 DetachTabContentsAt(index);
1003 } 1004 }
1004 break; 1005 break;
1005 } 1006 }
1006 1007
1007 case NotificationType::EXTENSION_UNLOADED: { 1008 case chrome::NOTIFICATION_EXTENSION_UNLOADED: {
1008 const Extension* extension = 1009 const Extension* extension =
1009 Details<UnloadedExtensionInfo>(details)->extension; 1010 Details<UnloadedExtensionInfo>(details)->extension;
1010 // Iterate backwards as we may remove items while iterating. 1011 // Iterate backwards as we may remove items while iterating.
1011 for (int i = count() - 1; i >= 0; i--) { 1012 for (int i = count() - 1; i >= 0; i--) {
1012 TabContentsWrapper* contents = GetTabContentsAt(i); 1013 TabContentsWrapper* contents = GetTabContentsAt(i);
1013 if (contents->extension_tab_helper()->extension_app() == extension) { 1014 if (contents->extension_tab_helper()->extension_app() == extension) {
1014 // The extension an app tab was created from has been nuked. Delete 1015 // The extension an app tab was created from has been nuked. Delete
1015 // the TabContents. Deleting a TabContents results in a notification 1016 // the TabContents. Deleting a TabContents results in a notification
1016 // of type TAB_CONTENTS_DESTROYED; we do the necessary cleanup in 1017 // of type TAB_CONTENTS_DESTROYED; we do the necessary cleanup in
1017 // handling that notification. 1018 // handling that notification.
(...skipping 299 matching lines...) Expand 10 before | Expand all | Expand 10 after
1317 void TabStripModel::ForgetOpenersAndGroupsReferencing( 1318 void TabStripModel::ForgetOpenersAndGroupsReferencing(
1318 const NavigationController* tab) { 1319 const NavigationController* tab) {
1319 for (TabContentsDataVector::const_iterator i = contents_data_.begin(); 1320 for (TabContentsDataVector::const_iterator i = contents_data_.begin();
1320 i != contents_data_.end(); ++i) { 1321 i != contents_data_.end(); ++i) {
1321 if ((*i)->group == tab) 1322 if ((*i)->group == tab)
1322 (*i)->group = NULL; 1323 (*i)->group = NULL;
1323 if ((*i)->opener == tab) 1324 if ((*i)->opener == tab)
1324 (*i)->opener = NULL; 1325 (*i)->opener = NULL;
1325 } 1326 }
1326 } 1327 }
OLDNEW
« no previous file with comments | « chrome/browser/tabs/tab_strip_model.h ('k') | chrome/browser/tabs/tab_strip_model_unittest.cc » ('j') | no next file with comments »

Powered by Google App Engine
This is Rietveld 408576698