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

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

Issue 302313005: Show the Managed Bookmarks folder in the views UI. (Closed) Base URL: svn://svn.chromium.org/chrome/trunk/src
Patch Set: rebased on components changes CL Created 6 years, 6 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 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/prefs/pref_service.h" 9 #include "base/prefs/pref_service.h"
10 #include "base/strings/utf_string_conversions.h" 10 #include "base/strings/utf_string_conversions.h"
(...skipping 156 matching lines...) Expand 10 before | Expand all | Expand 10 after
167 BookmarkModel* model = 167 BookmarkModel* model =
168 BookmarkModelFactory::GetForProfile(browser->profile()); 168 BookmarkModelFactory::GetForProfile(browser->profile());
169 if (!model || !model->loaded()) 169 if (!model || !model->loaded())
170 return; // Ignore requests until bookmarks are loaded. 170 return; // Ignore requests until bookmarks are loaded.
171 171
172 GURL url; 172 GURL url;
173 base::string16 title; 173 base::string16 title;
174 WebContents* web_contents = 174 WebContents* web_contents =
175 browser->tab_strip_model()->GetActiveWebContents(); 175 browser->tab_strip_model()->GetActiveWebContents();
176 GetURLAndTitleToBookmark(web_contents, &url, &title); 176 GetURLAndTitleToBookmark(web_contents, &url, &title);
177 bool was_bookmarked = model->IsBookmarked(url); 177 bool is_bookmarked_by_any = model->IsBookmarked(url);
178 if (!was_bookmarked && web_contents->GetBrowserContext()->IsOffTheRecord()) { 178 if (!is_bookmarked_by_any &&
179 web_contents->GetBrowserContext()->IsOffTheRecord()) {
179 // If we're incognito the favicon may not have been saved. Save it now 180 // If we're incognito the favicon may not have been saved. Save it now
180 // so that bookmarks have an icon for the page. 181 // so that bookmarks have an icon for the page.
181 FaviconTabHelper::FromWebContents(web_contents)->SaveFavicon(); 182 FaviconTabHelper::FromWebContents(web_contents)->SaveFavicon();
182 } 183 }
184 bool was_bookmarked_by_user = bookmark_utils::IsBookmarkedByUser(model, url);
183 bookmark_utils::AddIfNotBookmarked(model, url, title); 185 bookmark_utils::AddIfNotBookmarked(model, url, title);
186 bool is_bookmarked_by_user = bookmark_utils::IsBookmarkedByUser(model, url);
184 // Make sure the model actually added a bookmark before showing the star. A 187 // Make sure the model actually added a bookmark before showing the star. A
185 // bookmark isn't created if the url is invalid. 188 // bookmark isn't created if the url is invalid.
186 if (browser->window()->IsActive() && model->IsBookmarked(url)) { 189 if (browser->window()->IsActive() && is_bookmarked_by_user) {
187 // Only show the bubble if the window is active, otherwise we may get into 190 // Only show the bubble if the window is active, otherwise we may get into
188 // weird situations where the bubble is deleted as soon as it is shown. 191 // weird situations where the bubble is deleted as soon as it is shown.
189 browser->window()->ShowBookmarkBubble(url, was_bookmarked); 192 browser->window()->ShowBookmarkBubble(url, was_bookmarked_by_user);
190 } 193 }
191 } 194 }
192 195
193 // Based on |disposition|, creates a new tab as necessary, and returns the 196 // Based on |disposition|, creates a new tab as necessary, and returns the
194 // appropriate tab to navigate. If that tab is the current tab, reverts the 197 // appropriate tab to navigate. If that tab is the current tab, reverts the
195 // location bar contents, since all browser-UI-triggered navigations should 198 // location bar contents, since all browser-UI-triggered navigations should
196 // revert any omnibox edits in the current tab. 199 // revert any omnibox edits in the current tab.
197 WebContents* GetTabAndRevertIfNecessary(Browser* browser, 200 WebContents* GetTabAndRevertIfNecessary(Browser* browser,
198 WindowOpenDisposition disposition) { 201 WindowOpenDisposition disposition) {
199 WebContents* current_tab = browser->tab_strip_model()->GetActiveWebContents(); 202 WebContents* current_tab = browser->tab_strip_model()->GetActiveWebContents();
(...skipping 1060 matching lines...) Expand 10 before | Expand all | Expand 10 after
1260 browser->profile(), 1263 browser->profile(),
1261 browser->host_desktop_type())); 1264 browser->host_desktop_type()));
1262 app_browser->tab_strip_model()->AppendWebContents(contents, true); 1265 app_browser->tab_strip_model()->AppendWebContents(contents, true);
1263 1266
1264 contents->GetMutableRendererPrefs()->can_accept_load_drops = false; 1267 contents->GetMutableRendererPrefs()->can_accept_load_drops = false;
1265 contents->GetRenderViewHost()->SyncRendererPrefs(); 1268 contents->GetRenderViewHost()->SyncRendererPrefs();
1266 app_browser->window()->Show(); 1269 app_browser->window()->Show();
1267 } 1270 }
1268 1271
1269 } // namespace chrome 1272 } // namespace chrome
OLDNEW

Powered by Google App Engine
This is Rietveld 408576698