| OLD | NEW |
| 1 // Copyright (c) 2006-2008 The Chromium Authors. All rights reserved. | 1 // Copyright (c) 2006-2008 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/bookmark_bar_context_menu_controller.h" | 5 #include "chrome/browser/bookmark_bar_context_menu_controller.h" |
| 6 | 6 |
| 7 #include "chrome/browser/bookmarks/bookmark_model.h" | 7 #include "chrome/browser/bookmarks/bookmark_model.h" |
| 8 #include "chrome/browser/browser.h" | 8 #include "chrome/browser/browser.h" |
| 9 #include "chrome/browser/browser_list.h" | 9 #include "chrome/browser/browser_list.h" |
| 10 #include "chrome/browser/page_navigator.h" | 10 #include "chrome/browser/page_navigator.h" |
| (...skipping 35 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 46 void OpenAllImpl(BookmarkNode* node, | 46 void OpenAllImpl(BookmarkNode* node, |
| 47 WindowOpenDisposition initial_disposition, | 47 WindowOpenDisposition initial_disposition, |
| 48 PageNavigator** navigator, | 48 PageNavigator** navigator, |
| 49 bool* opened_url) { | 49 bool* opened_url) { |
| 50 if (node->GetType() == history::StarredEntry::URL) { | 50 if (node->GetType() == history::StarredEntry::URL) { |
| 51 WindowOpenDisposition disposition; | 51 WindowOpenDisposition disposition; |
| 52 if (*opened_url) | 52 if (*opened_url) |
| 53 disposition = NEW_BACKGROUND_TAB; | 53 disposition = NEW_BACKGROUND_TAB; |
| 54 else | 54 else |
| 55 disposition = initial_disposition; | 55 disposition = initial_disposition; |
| 56 (*navigator)->OpenURL(node->GetURL(), disposition, | 56 (*navigator)->OpenURL(node->GetURL(), GURL(), disposition, |
| 57 PageTransition::AUTO_BOOKMARK); | 57 PageTransition::AUTO_BOOKMARK); |
| 58 if (!*opened_url) { | 58 if (!*opened_url) { |
| 59 *opened_url = true; | 59 *opened_url = true; |
| 60 // We opened the first URL which may have opened a new window or clobbered | 60 // We opened the first URL which may have opened a new window or clobbered |
| 61 // the current page, reset the navigator just to be sure. | 61 // the current page, reset the navigator just to be sure. |
| 62 Browser* new_browser = BrowserList::GetLastActive(); | 62 Browser* new_browser = BrowserList::GetLastActive(); |
| 63 if (new_browser) { | 63 if (new_browser) { |
| 64 TabContents* current_tab = new_browser->GetSelectedTabContents(); | 64 TabContents* current_tab = new_browser->GetSelectedTabContents(); |
| 65 DCHECK(new_browser && current_tab); | 65 DCHECK(new_browser && current_tab); |
| 66 if (new_browser && current_tab) | 66 if (new_browser && current_tab) |
| (...skipping 210 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 277 } | 277 } |
| 278 | 278 |
| 279 void BookmarkBarContextMenuController::ExecuteCommand(int id) { | 279 void BookmarkBarContextMenuController::ExecuteCommand(int id) { |
| 280 Profile* profile = view_->GetProfile(); | 280 Profile* profile = view_->GetProfile(); |
| 281 | 281 |
| 282 switch (id) { | 282 switch (id) { |
| 283 case IDS_BOOMARK_BAR_OPEN_INCOGNITO: | 283 case IDS_BOOMARK_BAR_OPEN_INCOGNITO: |
| 284 UserMetrics::RecordAction(L"BookmarkBar_ContextMenu_OpenInIncognito", | 284 UserMetrics::RecordAction(L"BookmarkBar_ContextMenu_OpenInIncognito", |
| 285 profile); | 285 profile); |
| 286 | 286 |
| 287 view_->GetPageNavigator()->OpenURL(node_->GetURL(), OFF_THE_RECORD, | 287 view_->GetPageNavigator()->OpenURL(node_->GetURL(), GURL(), |
| 288 OFF_THE_RECORD, |
| 288 PageTransition::AUTO_BOOKMARK); | 289 PageTransition::AUTO_BOOKMARK); |
| 289 break; | 290 break; |
| 290 | 291 |
| 291 case IDS_BOOMARK_BAR_OPEN_IN_NEW_WINDOW: | 292 case IDS_BOOMARK_BAR_OPEN_IN_NEW_WINDOW: |
| 292 UserMetrics::RecordAction(L"BookmarkBar_ContextMenu_OpenInNewWindow", | 293 UserMetrics::RecordAction(L"BookmarkBar_ContextMenu_OpenInNewWindow", |
| 293 profile); | 294 profile); |
| 294 | 295 |
| 295 view_->GetPageNavigator()->OpenURL(node_->GetURL(), NEW_WINDOW, | 296 view_->GetPageNavigator()->OpenURL(node_->GetURL(), GURL(), NEW_WINDOW, |
| 296 PageTransition::AUTO_BOOKMARK); | 297 PageTransition::AUTO_BOOKMARK); |
| 297 break; | 298 break; |
| 298 | 299 |
| 299 case IDS_BOOMARK_BAR_OPEN_IN_NEW_TAB: | 300 case IDS_BOOMARK_BAR_OPEN_IN_NEW_TAB: |
| 300 UserMetrics::RecordAction(L"BookmarkBar_ContextMenu_OpenInNewTab", | 301 UserMetrics::RecordAction(L"BookmarkBar_ContextMenu_OpenInNewTab", |
| 301 profile); | 302 profile); |
| 302 | 303 |
| 303 view_->GetPageNavigator()->OpenURL(node_->GetURL(), NEW_FOREGROUND_TAB, | 304 view_->GetPageNavigator()->OpenURL(node_->GetURL(), GURL(), |
| 305 NEW_FOREGROUND_TAB, |
| 304 PageTransition::AUTO_BOOKMARK); | 306 PageTransition::AUTO_BOOKMARK); |
| 305 break; | 307 break; |
| 306 | 308 |
| 307 case IDS_BOOMARK_BAR_OPEN_ALL: | 309 case IDS_BOOMARK_BAR_OPEN_ALL: |
| 308 case IDS_BOOMARK_BAR_OPEN_ALL_INCOGNITO: | 310 case IDS_BOOMARK_BAR_OPEN_ALL_INCOGNITO: |
| 309 case IDS_BOOMARK_BAR_OPEN_ALL_NEW_WINDOW: { | 311 case IDS_BOOMARK_BAR_OPEN_ALL_NEW_WINDOW: { |
| 310 WindowOpenDisposition initial_disposition; | 312 WindowOpenDisposition initial_disposition; |
| 311 if (id == IDS_BOOMARK_BAR_OPEN_ALL) { | 313 if (id == IDS_BOOMARK_BAR_OPEN_ALL) { |
| 312 initial_disposition = CURRENT_TAB; | 314 initial_disposition = CURRENT_TAB; |
| 313 UserMetrics::RecordAction(L"BookmarkBar_ContextMenu_OpenAll", | 315 UserMetrics::RecordAction(L"BookmarkBar_ContextMenu_OpenAll", |
| (...skipping 98 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 412 if (node_->GetType() != history::StarredEntry::URL) { | 414 if (node_->GetType() != history::StarredEntry::URL) { |
| 413 // Adding to a group always adds to the end. | 415 // Adding to a group always adds to the end. |
| 414 *visual_order = node_->GetChildCount(); | 416 *visual_order = node_->GetChildCount(); |
| 415 return node_; | 417 return node_; |
| 416 } else { | 418 } else { |
| 417 DCHECK(node_->GetParent()); | 419 DCHECK(node_->GetParent()); |
| 418 *visual_order = node_->GetParent()->IndexOfChild(node_) + 1; | 420 *visual_order = node_->GetParent()->IndexOfChild(node_) + 1; |
| 419 return node_->GetParent(); | 421 return node_->GetParent(); |
| 420 } | 422 } |
| 421 } | 423 } |
| OLD | NEW |