| OLD | NEW |
| 1 // Copyright 2012 The Chromium Authors. All rights reserved. | 1 // Copyright 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_macros.h" | 8 #include "base/metrics/histogram_macros.h" |
| 9 #include "base/metrics/user_metrics.h" | 9 #include "base/metrics/user_metrics.h" |
| 10 #include "base/strings/utf_string_conversions.h" | 10 #include "base/strings/utf_string_conversions.h" |
| (...skipping 748 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 759 GURL url; | 759 GURL url; |
| 760 base::string16 title; | 760 base::string16 title; |
| 761 WebContents* web_contents = | 761 WebContents* web_contents = |
| 762 browser->tab_strip_model()->GetActiveWebContents(); | 762 browser->tab_strip_model()->GetActiveWebContents(); |
| 763 GetURLAndTitleToBookmark(web_contents, &url, &title); | 763 GetURLAndTitleToBookmark(web_contents, &url, &title); |
| 764 bool is_bookmarked_by_any = model->IsBookmarked(url); | 764 bool is_bookmarked_by_any = model->IsBookmarked(url); |
| 765 if (!is_bookmarked_by_any && | 765 if (!is_bookmarked_by_any && |
| 766 web_contents->GetBrowserContext()->IsOffTheRecord()) { | 766 web_contents->GetBrowserContext()->IsOffTheRecord()) { |
| 767 // If we're incognito the favicon may not have been saved. Save it now | 767 // If we're incognito the favicon may not have been saved. Save it now |
| 768 // so that bookmarks have an icon for the page. | 768 // so that bookmarks have an icon for the page. |
| 769 favicon::ContentFaviconDriver::FromWebContents(web_contents)->SaveFavicon(); | 769 favicon::ContentFaviconDriver::FromWebContents(web_contents) |
| 770 ->SaveFaviconEvenIfInIncognito(); |
| 770 } | 771 } |
| 771 bool was_bookmarked_by_user = bookmarks::IsBookmarkedByUser(model, url); | 772 bool was_bookmarked_by_user = bookmarks::IsBookmarkedByUser(model, url); |
| 772 bookmarks::AddIfNotBookmarked(model, url, title); | 773 bookmarks::AddIfNotBookmarked(model, url, title); |
| 773 bool is_bookmarked_by_user = bookmarks::IsBookmarkedByUser(model, url); | 774 bool is_bookmarked_by_user = bookmarks::IsBookmarkedByUser(model, url); |
| 774 // Make sure the model actually added a bookmark before showing the star. A | 775 // Make sure the model actually added a bookmark before showing the star. A |
| 775 // bookmark isn't created if the url is invalid. | 776 // bookmark isn't created if the url is invalid. |
| 776 if (browser->window()->IsActive() && is_bookmarked_by_user) { | 777 if (browser->window()->IsActive() && is_bookmarked_by_user) { |
| 777 // Only show the bubble if the window is active, otherwise we may get into | 778 // Only show the bubble if the window is active, otherwise we may get into |
| 778 // weird situations where the bubble is deleted as soon as it is shown. | 779 // weird situations where the bubble is deleted as soon as it is shown. |
| 779 browser->window()->ShowBookmarkBubble(url, was_bookmarked_by_user); | 780 browser->window()->ShowBookmarkBubble(url, was_bookmarked_by_user); |
| (...skipping 490 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 1270 } | 1271 } |
| 1271 | 1272 |
| 1272 bool CanCreateBookmarkApp(const Browser* browser) { | 1273 bool CanCreateBookmarkApp(const Browser* browser) { |
| 1273 return extensions::TabHelper::FromWebContents( | 1274 return extensions::TabHelper::FromWebContents( |
| 1274 browser->tab_strip_model()->GetActiveWebContents()) | 1275 browser->tab_strip_model()->GetActiveWebContents()) |
| 1275 ->CanCreateBookmarkApp(); | 1276 ->CanCreateBookmarkApp(); |
| 1276 } | 1277 } |
| 1277 #endif // BUILDFLAG(ENABLE_EXTENSIONS) | 1278 #endif // BUILDFLAG(ENABLE_EXTENSIONS) |
| 1278 | 1279 |
| 1279 } // namespace chrome | 1280 } // namespace chrome |
| OLD | NEW |