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

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

Issue 11011002: Switch FaviconTabHelper to use WebContentsUserData. (Closed) Base URL: svn://svn.chromium.org/chrome/trunk/src
Patch Set: fix Created 8 years, 2 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/ui/browser.cc ('k') | chrome/browser/ui/cocoa/tab_contents/favicon_util_mac.mm » ('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/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"
(...skipping 580 matching lines...) Expand 10 before | Expand all | Expand 10 after
591 void BookmarkCurrentPage(Browser* browser) { 591 void BookmarkCurrentPage(Browser* browser) {
592 content::RecordAction(UserMetricsAction("Star")); 592 content::RecordAction(UserMetricsAction("Star"));
593 593
594 BookmarkModel* model = 594 BookmarkModel* model =
595 BookmarkModelFactory::GetForProfile(browser->profile()); 595 BookmarkModelFactory::GetForProfile(browser->profile());
596 if (!model || !model->IsLoaded()) 596 if (!model || !model->IsLoaded())
597 return; // Ignore requests until bookmarks are loaded. 597 return; // Ignore requests until bookmarks are loaded.
598 598
599 GURL url; 599 GURL url;
600 string16 title; 600 string16 title;
601 TabContents* tab = GetActiveTabContents(browser); 601 WebContents* web_contents = GetActiveWebContents(browser);
602 bookmark_utils::GetURLAndTitleToBookmark(tab->web_contents(), &url, &title); 602 bookmark_utils::GetURLAndTitleToBookmark(web_contents, &url, &title);
603 bool was_bookmarked = model->IsBookmarked(url); 603 bool was_bookmarked = model->IsBookmarked(url);
604 if (!was_bookmarked && browser->profile()->IsOffTheRecord()) { 604 if (!was_bookmarked && web_contents->GetBrowserContext()->IsOffTheRecord()) {
605 // If we're incognito the favicon may not have been saved. Save it now 605 // If we're incognito the favicon may not have been saved. Save it now
606 // so that bookmarks have an icon for the page. 606 // so that bookmarks have an icon for the page.
607 tab->favicon_tab_helper()->SaveFavicon(); 607 FaviconTabHelper::FromWebContents(web_contents)->SaveFavicon();
608 } 608 }
609 bookmark_utils::AddIfNotBookmarked(model, url, title); 609 bookmark_utils::AddIfNotBookmarked(model, url, title);
610 // Make sure the model actually added a bookmark before showing the star. A 610 // Make sure the model actually added a bookmark before showing the star. A
611 // bookmark isn't created if the url is invalid. 611 // bookmark isn't created if the url is invalid.
612 if (browser->window()->IsActive() && model->IsBookmarked(url)) { 612 if (browser->window()->IsActive() && model->IsBookmarked(url)) {
613 // Only show the bubble if the window is active, otherwise we may get into 613 // Only show the bubble if the window is active, otherwise we may get into
614 // weird situations where the bubble is deleted as soon as it is shown. 614 // weird situations where the bubble is deleted as soon as it is shown.
615 browser->window()->ShowBookmarkBubble(url, was_bookmarked); 615 browser->window()->ShowBookmarkBubble(url, was_bookmarked);
616 } 616 }
617 } 617 }
(...skipping 448 matching lines...) Expand 10 before | Expand all | Expand 10 after
1066 BrowserCommandsTabContentsCreator::CreateTabContents(contents); 1066 BrowserCommandsTabContentsCreator::CreateTabContents(contents);
1067 } 1067 }
1068 app_browser->tab_strip_model()->AppendTabContents(tab_contents, true); 1068 app_browser->tab_strip_model()->AppendTabContents(tab_contents, true);
1069 1069
1070 contents->GetMutableRendererPrefs()->can_accept_load_drops = false; 1070 contents->GetMutableRendererPrefs()->can_accept_load_drops = false;
1071 contents->GetRenderViewHost()->SyncRendererPrefs(); 1071 contents->GetRenderViewHost()->SyncRendererPrefs();
1072 app_browser->window()->Show(); 1072 app_browser->window()->Show();
1073 } 1073 }
1074 1074
1075 } // namespace chrome 1075 } // namespace chrome
OLDNEW
« no previous file with comments | « chrome/browser/ui/browser.cc ('k') | chrome/browser/ui/cocoa/tab_contents/favicon_util_mac.mm » ('j') | no next file with comments »

Powered by Google App Engine
This is Rietveld 408576698