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

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

Issue 765043002: Bookmark pop-up doesn't open if Ctrl+D is set as keyboard shortcut for added extensions. (Closed) Base URL: https://chromium.googlesource.com/chromium/src.git@master
Patch Set: Created 6 years 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
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 149 matching lines...) Expand 10 before | Expand all | Expand 10 after
160 *extension = i->get(); 160 *extension = i->get();
161 *command = prospective_command; 161 *command = prospective_command;
162 *command_type = prospective_command_type; 162 *command_type = prospective_command_type;
163 return true; 163 return true;
164 } 164 }
165 } 165 }
166 return false; 166 return false;
167 } 167 }
168 #endif 168 #endif
169 169
170 void BookmarkCurrentPageInternal(Browser* browser) {
171 content::RecordAction(UserMetricsAction("Star"));
172
173 BookmarkModel* model =
174 BookmarkModelFactory::GetForProfile(browser->profile());
175 if (!model || !model->loaded())
176 return; // Ignore requests until bookmarks are loaded.
177
178 GURL url;
179 base::string16 title;
180 WebContents* web_contents =
181 browser->tab_strip_model()->GetActiveWebContents();
182 GetURLAndTitleToBookmark(web_contents, &url, &title);
183 bool is_bookmarked_by_any = model->IsBookmarked(url);
184 if (!is_bookmarked_by_any &&
185 web_contents->GetBrowserContext()->IsOffTheRecord()) {
186 // If we're incognito the favicon may not have been saved. Save it now
187 // so that bookmarks have an icon for the page.
188 FaviconTabHelper::FromWebContents(web_contents)->SaveFavicon();
189 }
190 bool was_bookmarked_by_user = bookmarks::IsBookmarkedByUser(model, url);
191 bookmarks::AddIfNotBookmarked(model, url, title);
192 bool is_bookmarked_by_user = bookmarks::IsBookmarkedByUser(model, url);
193 // Make sure the model actually added a bookmark before showing the star. A
194 // bookmark isn't created if the url is invalid.
195 if (browser->window()->IsActive() && is_bookmarked_by_user) {
196 // Only show the bubble if the window is active, otherwise we may get into
197 // weird situations where the bubble is deleted as soon as it is shown.
198 browser->window()->ShowBookmarkBubble(url, was_bookmarked_by_user);
199 }
200 }
201
202 // Based on |disposition|, creates a new tab as necessary, and returns the 170 // Based on |disposition|, creates a new tab as necessary, and returns the
203 // appropriate tab to navigate. If that tab is the current tab, reverts the 171 // appropriate tab to navigate. If that tab is the current tab, reverts the
204 // location bar contents, since all browser-UI-triggered navigations should 172 // location bar contents, since all browser-UI-triggered navigations should
205 // revert any omnibox edits in the current tab. 173 // revert any omnibox edits in the current tab.
206 WebContents* GetTabAndRevertIfNecessary(Browser* browser, 174 WebContents* GetTabAndRevertIfNecessary(Browser* browser,
207 WindowOpenDisposition disposition) { 175 WindowOpenDisposition disposition) {
208 WebContents* current_tab = browser->tab_strip_model()->GetActiveWebContents(); 176 WebContents* current_tab = browser->tab_strip_model()->GetActiveWebContents();
209 switch (disposition) { 177 switch (disposition) {
210 case NEW_FOREGROUND_TAB: 178 case NEW_FOREGROUND_TAB:
211 case NEW_BACKGROUND_TAB: { 179 case NEW_BACKGROUND_TAB: {
(...skipping 63 matching lines...) Expand 10 before | Expand all | Expand 10 after
275 return controller && (controller->GetPrintPreviewForContents(contents) || 243 return controller && (controller->GetPrintPreviewForContents(contents) ||
276 controller->is_creating_print_preview_dialog()); 244 controller->is_creating_print_preview_dialog());
277 #else 245 #else
278 return false; 246 return false;
279 #endif 247 #endif
280 } 248 }
281 #endif // ENABLE_BASIC_PRINTING 249 #endif // ENABLE_BASIC_PRINTING
282 250
283 } // namespace 251 } // namespace
284 252
253 void BookmarkCurrentPageInternal(Browser* browser) {
254 content::RecordAction(UserMetricsAction("Star"));
255
256 BookmarkModel* model =
257 BookmarkModelFactory::GetForProfile(browser->profile());
258 if (!model || !model->loaded())
259 return; // Ignore requests until bookmarks are loaded.
260
261 GURL url;
262 base::string16 title;
263 WebContents* web_contents =
264 browser->tab_strip_model()->GetActiveWebContents();
265 GetURLAndTitleToBookmark(web_contents, &url, &title);
266 bool is_bookmarked_by_any = model->IsBookmarked(url);
267 if (!is_bookmarked_by_any &&
268 web_contents->GetBrowserContext()->IsOffTheRecord()) {
269 // If we're incognito the favicon may not have been saved. Save it now
270 // so that bookmarks have an icon for the page.
271 FaviconTabHelper::FromWebContents(web_contents)->SaveFavicon();
272 }
273 bool was_bookmarked_by_user = bookmarks::IsBookmarkedByUser(model, url);
274 bookmarks::AddIfNotBookmarked(model, url, title);
275 bool is_bookmarked_by_user = bookmarks::IsBookmarkedByUser(model, url);
276 // Make sure the model actually added a bookmark before showing the star. A
277 // bookmark isn't created if the url is invalid.
278 if (browser->window()->IsActive() && is_bookmarked_by_user) {
279 // Only show the bubble if the window is active, otherwise we may get into
280 // weird situations where the bubble is deleted as soon as it is shown.
281 browser->window()->ShowBookmarkBubble(url, was_bookmarked_by_user);
282 }
283 }
284
285 bool IsCommandEnabled(Browser* browser, int command) { 285 bool IsCommandEnabled(Browser* browser, int command) {
286 return browser->command_controller()->command_updater()->IsCommandEnabled( 286 return browser->command_controller()->command_updater()->IsCommandEnabled(
287 command); 287 command);
288 } 288 }
289 289
290 bool SupportsCommand(Browser* browser, int command) { 290 bool SupportsCommand(Browser* browser, int command) {
291 return browser->command_controller()->command_updater()->SupportsCommand( 291 return browser->command_controller()->command_updater()->SupportsCommand(
292 command); 292 command);
293 } 293 }
294 294
(...skipping 976 matching lines...) Expand 10 before | Expand all | Expand 10 after
1271 browser->host_desktop_type())); 1271 browser->host_desktop_type()));
1272 app_browser->tab_strip_model()->AppendWebContents(contents, true); 1272 app_browser->tab_strip_model()->AppendWebContents(contents, true);
1273 1273
1274 contents->GetMutableRendererPrefs()->can_accept_load_drops = false; 1274 contents->GetMutableRendererPrefs()->can_accept_load_drops = false;
1275 contents->GetRenderViewHost()->SyncRendererPrefs(); 1275 contents->GetRenderViewHost()->SyncRendererPrefs();
1276 app_browser->window()->Show(); 1276 app_browser->window()->Show();
1277 } 1277 }
1278 #endif // defined(ENABLE_EXTENSIONS) 1278 #endif // defined(ENABLE_EXTENSIONS)
1279 1279
1280 } // namespace chrome 1280 } // namespace chrome
OLDNEW

Powered by Google App Engine
This is Rietveld 408576698