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

Side by Side Diff: chrome/browser/ui/browser_commands.cc

Issue 10831062: Removing instances of profile_->GetBookmarkModel() as part of converting BookmarkModel to a PKS. (Closed) Base URL: svn://chrome-svn/chrome/trunk/src/
Patch Set: Created 8 years, 4 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/browser_commands.h" 5 #include "chrome/browser/ui/browser_commands.h"
6 6
7 #include "base/command_line.h" 7 #include "base/command_line.h"
8 #include "base/metrics/histogram.h" 8 #include "base/metrics/histogram.h"
9 #include "base/utf_string_conversions.h" 9 #include "base/utf_string_conversions.h"
10 #include "chrome/browser/bookmarks/bookmark_editor.h" 10 #include "chrome/browser/bookmarks/bookmark_editor.h"
11 #include "chrome/browser/bookmarks/bookmark_model.h" 11 #include "chrome/browser/bookmarks/bookmark_model.h"
12 #include "chrome/browser/bookmarks/bookmark_model_factory.h"
12 #include "chrome/browser/bookmarks/bookmark_utils.h" 13 #include "chrome/browser/bookmarks/bookmark_utils.h"
13 #include "chrome/browser/browser_process.h" 14 #include "chrome/browser/browser_process.h"
14 #include "chrome/browser/browsing_data/browsing_data_helper.h" 15 #include "chrome/browser/browsing_data/browsing_data_helper.h"
15 #include "chrome/browser/browsing_data/browsing_data_remover.h" 16 #include "chrome/browser/browsing_data/browsing_data_remover.h"
16 #include "chrome/browser/chrome_page_zoom.h" 17 #include "chrome/browser/chrome_page_zoom.h"
17 #include "chrome/browser/debugger/devtools_window.h" 18 #include "chrome/browser/debugger/devtools_window.h"
18 #include "chrome/browser/download/download_util.h" 19 #include "chrome/browser/download/download_util.h"
19 #include "chrome/browser/extensions/extension_service.h" 20 #include "chrome/browser/extensions/extension_service.h"
20 #include "chrome/browser/extensions/tab_helper.h" 21 #include "chrome/browser/extensions/tab_helper.h"
21 #include "chrome/browser/favicon/favicon_tab_helper.h" 22 #include "chrome/browser/favicon/favicon_tab_helper.h"
(...skipping 531 matching lines...) Expand 10 before | Expand all | Expand 10 after
553 } 554 }
554 555
555 void Exit() { 556 void Exit() {
556 content::RecordAction(UserMetricsAction("Exit")); 557 content::RecordAction(UserMetricsAction("Exit"));
557 browser::AttemptUserExit(); 558 browser::AttemptUserExit();
558 } 559 }
559 560
560 void BookmarkCurrentPage(Browser* browser) { 561 void BookmarkCurrentPage(Browser* browser) {
561 content::RecordAction(UserMetricsAction("Star")); 562 content::RecordAction(UserMetricsAction("Star"));
562 563
563 BookmarkModel* model = browser->profile()->GetBookmarkModel(); 564 BookmarkModel* model = BookmarkModelFactory::GetForProfile(
Peter Kasting 2012/07/28 00:37:21 Nit: I would probably wrap after '=' instead (2 pl
565 browser->profile());
564 if (!model || !model->IsLoaded()) 566 if (!model || !model->IsLoaded())
565 return; // Ignore requests until bookmarks are loaded. 567 return; // Ignore requests until bookmarks are loaded.
566 568
567 GURL url; 569 GURL url;
568 string16 title; 570 string16 title;
569 TabContents* tab = GetActiveTabContents(browser); 571 TabContents* tab = GetActiveTabContents(browser);
570 bookmark_utils::GetURLAndTitleToBookmark(tab->web_contents(), &url, &title); 572 bookmark_utils::GetURLAndTitleToBookmark(tab->web_contents(), &url, &title);
571 bool was_bookmarked = model->IsBookmarked(url); 573 bool was_bookmarked = model->IsBookmarked(url);
572 if (!was_bookmarked && browser->profile()->IsOffTheRecord()) { 574 if (!was_bookmarked && browser->profile()->IsOffTheRecord()) {
573 // If we're incognito the favicon may not have been saved. Save it now 575 // If we're incognito the favicon may not have been saved. Save it now
574 // so that bookmarks have an icon for the page. 576 // so that bookmarks have an icon for the page.
575 tab->favicon_tab_helper()->SaveFavicon(); 577 tab->favicon_tab_helper()->SaveFavicon();
576 } 578 }
577 bookmark_utils::AddIfNotBookmarked(model, url, title); 579 bookmark_utils::AddIfNotBookmarked(model, url, title);
578 // Make sure the model actually added a bookmark before showing the star. A 580 // Make sure the model actually added a bookmark before showing the star. A
579 // bookmark isn't created if the url is invalid. 581 // bookmark isn't created if the url is invalid.
580 if (browser->window()->IsActive() && model->IsBookmarked(url)) { 582 if (browser->window()->IsActive() && model->IsBookmarked(url)) {
581 // Only show the bubble if the window is active, otherwise we may get into 583 // Only show the bubble if the window is active, otherwise we may get into
582 // weird situations where the bubble is deleted as soon as it is shown. 584 // weird situations where the bubble is deleted as soon as it is shown.
583 browser->window()->ShowBookmarkBubble(url, was_bookmarked); 585 browser->window()->ShowBookmarkBubble(url, was_bookmarked);
584 } 586 }
585 } 587 }
586 588
587 bool CanBookmarkCurrentPage(const Browser* browser) { 589 bool CanBookmarkCurrentPage(const Browser* browser) {
588 BookmarkModel* model = browser->profile()->GetBookmarkModel(); 590 BookmarkModel* model = BookmarkModelFactory::GetForProfile(
591 browser->profile());
589 return browser_defaults::bookmarks_enabled && 592 return browser_defaults::bookmarks_enabled &&
590 browser->profile()->GetPrefs()->GetBoolean( 593 browser->profile()->GetPrefs()->GetBoolean(
591 prefs::kEditBookmarksEnabled) && 594 prefs::kEditBookmarksEnabled) &&
592 model && model->IsLoaded() && browser->is_type_tabbed(); 595 model && model->IsLoaded() && browser->is_type_tabbed();
593 } 596 }
594 597
595 void BookmarkAllTabs(Browser* browser) { 598 void BookmarkAllTabs(Browser* browser) {
596 BookmarkEditor::ShowBookmarkAllTabsDialog(browser); 599 BookmarkEditor::ShowBookmarkAllTabsDialog(browser);
597 } 600 }
598 601
(...skipping 387 matching lines...) Expand 10 before | Expand all | Expand 10 after
986 if (!tab_contents) 989 if (!tab_contents)
987 tab_contents = new TabContents(contents); 990 tab_contents = new TabContents(contents);
988 app_browser->tab_strip_model()->AppendTabContents(tab_contents, true); 991 app_browser->tab_strip_model()->AppendTabContents(tab_contents, true);
989 992
990 contents->GetMutableRendererPrefs()->can_accept_load_drops = false; 993 contents->GetMutableRendererPrefs()->can_accept_load_drops = false;
991 contents->GetRenderViewHost()->SyncRendererPrefs(); 994 contents->GetRenderViewHost()->SyncRendererPrefs();
992 app_browser->window()->Show(); 995 app_browser->window()->Show();
993 } 996 }
994 997
995 } // namespace chrome 998 } // namespace chrome
OLDNEW
« no previous file with comments | « chrome/browser/ui/bookmarks/bookmark_tab_helper.cc ('k') | chrome/browser/ui/omnibox/omnibox_view_browsertest.cc » ('j') | no next file with comments »

Powered by Google App Engine
This is Rietveld 408576698