| 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.h" | 8 #include "base/metrics/histogram.h" |
| 9 #include "base/strings/utf_string_conversions.h" | 9 #include "base/strings/utf_string_conversions.h" |
| 10 #include "build/build_config.h" | 10 #include "build/build_config.h" |
| (...skipping 114 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 125 using content::OpenURLParams; | 125 using content::OpenURLParams; |
| 126 using content::Referrer; | 126 using content::Referrer; |
| 127 using content::WebContents; | 127 using content::WebContents; |
| 128 | 128 |
| 129 namespace chrome { | 129 namespace chrome { |
| 130 namespace { | 130 namespace { |
| 131 | 131 |
| 132 bool CanBookmarkCurrentPageInternal(const Browser* browser, | 132 bool CanBookmarkCurrentPageInternal(const Browser* browser, |
| 133 bool check_remove_bookmark_ui) { | 133 bool check_remove_bookmark_ui) { |
| 134 BookmarkModel* model = | 134 BookmarkModel* model = |
| 135 BookmarkModelFactory::GetForProfile(browser->profile()); | 135 BookmarkModelFactory::GetForBrowserContext(browser->profile()); |
| 136 return browser_defaults::bookmarks_enabled && | 136 return browser_defaults::bookmarks_enabled && |
| 137 browser->profile()->GetPrefs()->GetBoolean( | 137 browser->profile()->GetPrefs()->GetBoolean( |
| 138 bookmarks::prefs::kEditBookmarksEnabled) && | 138 bookmarks::prefs::kEditBookmarksEnabled) && |
| 139 model && model->loaded() && browser->is_type_tabbed() && | 139 model && model->loaded() && browser->is_type_tabbed() && |
| 140 (!check_remove_bookmark_ui || | 140 (!check_remove_bookmark_ui || |
| 141 !chrome::ShouldRemoveBookmarkThisPageUI(browser->profile())); | 141 !chrome::ShouldRemoveBookmarkThisPageUI(browser->profile())); |
| 142 } | 142 } |
| 143 | 143 |
| 144 #if defined(ENABLE_EXTENSIONS) | 144 #if defined(ENABLE_EXTENSIONS) |
| 145 bool GetBookmarkOverrideCommand( | 145 bool GetBookmarkOverrideCommand( |
| (...skipping 574 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 720 | 720 |
| 721 void Exit() { | 721 void Exit() { |
| 722 content::RecordAction(UserMetricsAction("Exit")); | 722 content::RecordAction(UserMetricsAction("Exit")); |
| 723 chrome::AttemptUserExit(); | 723 chrome::AttemptUserExit(); |
| 724 } | 724 } |
| 725 | 725 |
| 726 void BookmarkCurrentPageIgnoringExtensionOverrides(Browser* browser) { | 726 void BookmarkCurrentPageIgnoringExtensionOverrides(Browser* browser) { |
| 727 content::RecordAction(UserMetricsAction("Star")); | 727 content::RecordAction(UserMetricsAction("Star")); |
| 728 | 728 |
| 729 BookmarkModel* model = | 729 BookmarkModel* model = |
| 730 BookmarkModelFactory::GetForProfile(browser->profile()); | 730 BookmarkModelFactory::GetForBrowserContext(browser->profile()); |
| 731 if (!model || !model->loaded()) | 731 if (!model || !model->loaded()) |
| 732 return; // Ignore requests until bookmarks are loaded. | 732 return; // Ignore requests until bookmarks are loaded. |
| 733 | 733 |
| 734 GURL url; | 734 GURL url; |
| 735 base::string16 title; | 735 base::string16 title; |
| 736 WebContents* web_contents = | 736 WebContents* web_contents = |
| 737 browser->tab_strip_model()->GetActiveWebContents(); | 737 browser->tab_strip_model()->GetActiveWebContents(); |
| 738 GetURLAndTitleToBookmark(web_contents, &url, &title); | 738 GetURLAndTitleToBookmark(web_contents, &url, &title); |
| 739 bool is_bookmarked_by_any = model->IsBookmarked(url); | 739 bool is_bookmarked_by_any = model->IsBookmarked(url); |
| 740 if (!is_bookmarked_by_any && | 740 if (!is_bookmarked_by_any && |
| (...skipping 549 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 1290 app_name, true /* trusted_source */, gfx::Rect(), browser->profile())); | 1290 app_name, true /* trusted_source */, gfx::Rect(), browser->profile())); |
| 1291 app_browser->tab_strip_model()->AppendWebContents(contents, true); | 1291 app_browser->tab_strip_model()->AppendWebContents(contents, true); |
| 1292 | 1292 |
| 1293 contents->GetMutableRendererPrefs()->can_accept_load_drops = false; | 1293 contents->GetMutableRendererPrefs()->can_accept_load_drops = false; |
| 1294 contents->GetRenderViewHost()->SyncRendererPrefs(); | 1294 contents->GetRenderViewHost()->SyncRendererPrefs(); |
| 1295 app_browser->window()->Show(); | 1295 app_browser->window()->Show(); |
| 1296 } | 1296 } |
| 1297 #endif // defined(ENABLE_EXTENSIONS) | 1297 #endif // defined(ENABLE_EXTENSIONS) |
| 1298 | 1298 |
| 1299 } // namespace chrome | 1299 } // namespace chrome |
| OLD | NEW |