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

Side by Side Diff: chrome/browser/ui/cocoa/history_menu_bridge.mm

Issue 10806022: Removing usage of profile_->GetHistory() from the codebase in order to remove that function. (Closed) Base URL: svn://chrome-svn/chrome/trunk/src/
Patch Set: Created 8 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 | « no previous file | chrome/browser/ui/omnibox/omnibox_view_browsertest.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) 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/cocoa/history_menu_bridge.h" 5 #include "chrome/browser/ui/cocoa/history_menu_bridge.h"
6 6
7 #include "base/bind.h" 7 #include "base/bind.h"
8 #include "base/bind_helpers.h" 8 #include "base/bind_helpers.h"
9 #include "base/stl_util.h" 9 #include "base/stl_util.h"
10 #include "base/string_number_conversions.h" 10 #include "base/string_number_conversions.h"
11 #include "base/string_util.h" 11 #include "base/string_util.h"
12 #include "base/sys_string_conversions.h" 12 #include "base/sys_string_conversions.h"
13 #include "chrome/app/chrome_command_ids.h" // IDC_HISTORY_MENU 13 #include "chrome/app/chrome_command_ids.h" // IDC_HISTORY_MENU
14 #import "chrome/browser/app_controller_mac.h" 14 #import "chrome/browser/app_controller_mac.h"
15 #include "chrome/browser/history/history_service_factory.h"
15 #include "chrome/browser/history/page_usage_data.h" 16 #include "chrome/browser/history/page_usage_data.h"
16 #include "chrome/browser/profiles/profile.h" 17 #include "chrome/browser/profiles/profile.h"
17 #include "chrome/browser/sessions/session_types.h" 18 #include "chrome/browser/sessions/session_types.h"
18 #include "chrome/browser/sessions/tab_restore_service_factory.h" 19 #include "chrome/browser/sessions/tab_restore_service_factory.h"
19 #import "chrome/browser/ui/cocoa/history_menu_cocoa_controller.h" 20 #import "chrome/browser/ui/cocoa/history_menu_cocoa_controller.h"
20 #include "chrome/common/chrome_notification_types.h" 21 #include "chrome/common/chrome_notification_types.h"
21 #include "chrome/common/url_constants.h" 22 #include "chrome/common/url_constants.h"
22 #include "content/public/browser/notification_registrar.h" 23 #include "content/public/browser/notification_registrar.h"
23 #include "content/public/browser/notification_source.h" 24 #include "content/public/browser/notification_source.h"
24 #include "grit/generated_resources.h" 25 #include "grit/generated_resources.h"
(...skipping 49 matching lines...) Expand 10 before | Expand all | Expand 10 after
74 history_service_(NULL), 75 history_service_(NULL),
75 tab_restore_service_(NULL), 76 tab_restore_service_(NULL),
76 create_in_progress_(false), 77 create_in_progress_(false),
77 need_recreate_(false) { 78 need_recreate_(false) {
78 // If we don't have a profile, do not bother initializing our data sources. 79 // If we don't have a profile, do not bother initializing our data sources.
79 // This shouldn't happen except in unit tests. 80 // This shouldn't happen except in unit tests.
80 if (profile_) { 81 if (profile_) {
81 // Check to see if the history service is ready. Because it loads async, it 82 // Check to see if the history service is ready. Because it loads async, it
82 // may not be ready when the Bridge is created. If this happens, register 83 // may not be ready when the Bridge is created. If this happens, register
83 // for a notification that tells us the HistoryService is ready. 84 // for a notification that tells us the HistoryService is ready.
84 HistoryService* hs = profile_->GetHistoryService(Profile::EXPLICIT_ACCESS); 85 HistoryService* hs = HistoryServiceFactory::GetForProfile(
86 profile_, Profile::EXPLICIT_ACCESS);
85 if (hs != NULL && hs->BackendLoaded()) { 87 if (hs != NULL && hs->BackendLoaded()) {
86 history_service_ = hs; 88 history_service_ = hs;
87 Init(); 89 Init();
88 } 90 }
89 91
90 tab_restore_service_ = TabRestoreServiceFactory::GetForProfile(profile_); 92 tab_restore_service_ = TabRestoreServiceFactory::GetForProfile(profile_);
91 if (tab_restore_service_) { 93 if (tab_restore_service_) {
92 tab_restore_service_->AddObserver(this); 94 tab_restore_service_->AddObserver(this);
93 tab_restore_service_->LoadTabsFromLastSession(); 95 tab_restore_service_->LoadTabsFromLastSession();
94 } 96 }
(...skipping 43 matching lines...) Expand 10 before | Expand all | Expand 10 after
138 delete item; 140 delete item;
139 } 141 }
140 } 142 }
141 143
142 void HistoryMenuBridge::Observe(int type, 144 void HistoryMenuBridge::Observe(int type,
143 const content::NotificationSource& source, 145 const content::NotificationSource& source,
144 const content::NotificationDetails& details) { 146 const content::NotificationDetails& details) {
145 // A history service is now ready. Check to see if it's the one for the main 147 // A history service is now ready. Check to see if it's the one for the main
146 // profile. If so, perform final initialization. 148 // profile. If so, perform final initialization.
147 if (type == chrome::NOTIFICATION_HISTORY_LOADED) { 149 if (type == chrome::NOTIFICATION_HISTORY_LOADED) {
148 HistoryService* hs = 150 HistoryService* hs = HistoryServiceFactory::GetForProfile(
149 profile_->GetHistoryService(Profile::EXPLICIT_ACCESS); 151 profile_, Profile::EXPLICIT_ACCESS);
150 if (hs != NULL && hs->BackendLoaded()) { 152 if (hs != NULL && hs->BackendLoaded()) {
151 history_service_ = hs; 153 history_service_ = hs;
152 Init(); 154 Init();
153 155
154 // Found our HistoryService, so stop listening for this notification. 156 // Found our HistoryService, so stop listening for this notification.
155 registrar_.Remove(this, 157 registrar_.Remove(this,
156 chrome::NOTIFICATION_HISTORY_LOADED, 158 chrome::NOTIFICATION_HISTORY_LOADED,
157 content::Source<Profile>(profile_)); 159 content::Source<Profile>(profile_));
158 } 160 }
159 } 161 }
(...skipping 323 matching lines...) Expand 10 before | Expand all | Expand 10 after
483 void HistoryMenuBridge::CancelFaviconRequest(HistoryItem* item) { 485 void HistoryMenuBridge::CancelFaviconRequest(HistoryItem* item) {
484 DCHECK(item); 486 DCHECK(item);
485 if (item->icon_requested) { 487 if (item->icon_requested) {
486 FaviconService* service = 488 FaviconService* service =
487 profile_->GetFaviconService(Profile::EXPLICIT_ACCESS); 489 profile_->GetFaviconService(Profile::EXPLICIT_ACCESS);
488 service->CancelRequest(item->icon_handle); 490 service->CancelRequest(item->icon_handle);
489 item->icon_requested = false; 491 item->icon_requested = false;
490 item->icon_handle = NULL; 492 item->icon_handle = NULL;
491 } 493 }
492 } 494 }
OLDNEW
« no previous file with comments | « no previous file | chrome/browser/ui/omnibox/omnibox_view_browsertest.cc » ('j') | no next file with comments »

Powered by Google App Engine
This is Rietveld 408576698