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

Side by Side Diff: chrome/browser/ui/cocoa/browser_window_cocoa.mm

Issue 151283006: Mac OS X: Show the Translate icon on Omnibox (Closed) Base URL: https://chromium.googlesource.com/chromium/src.git@issue-307352-translate-bubble-2
Patch Set: groby's review Created 6 years, 10 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
OLDNEW
1 // Copyright (c) 2012 The Chromium Authors. All rights reserved. 1 // Copyright (c) 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/cocoa/browser_window_cocoa.h" 5 #include "chrome/browser/ui/cocoa/browser_window_cocoa.h"
6 6
7 #include "base/bind.h" 7 #include "base/bind.h"
8 #include "base/command_line.h" 8 #include "base/command_line.h"
9 #include "base/logging.h" 9 #include "base/logging.h"
10 #include "base/mac/mac_util.h" 10 #include "base/mac/mac_util.h"
11 #import "base/mac/sdk_forward_declarations.h" 11 #import "base/mac/sdk_forward_declarations.h"
12 #include "base/message_loop/message_loop.h" 12 #include "base/message_loop/message_loop.h"
13 #include "base/prefs/pref_service.h" 13 #include "base/prefs/pref_service.h"
14 #include "base/strings/sys_string_conversions.h" 14 #include "base/strings/sys_string_conversions.h"
15 #include "chrome/app/chrome_command_ids.h" 15 #include "chrome/app/chrome_command_ids.h"
16 #include "chrome/browser/chrome_notification_types.h" 16 #include "chrome/browser/chrome_notification_types.h"
17 #include "chrome/browser/download/download_shelf.h" 17 #include "chrome/browser/download/download_shelf.h"
18 #include "chrome/browser/extensions/tab_helper.h" 18 #include "chrome/browser/extensions/tab_helper.h"
19 #include "chrome/browser/fullscreen.h" 19 #include "chrome/browser/fullscreen.h"
20 #include "chrome/browser/password_manager/chrome_password_manager_client.h" 20 #include "chrome/browser/password_manager/chrome_password_manager_client.h"
21 #include "chrome/browser/profiles/profile.h" 21 #include "chrome/browser/profiles/profile.h"
22 #include "chrome/browser/shell_integration.h" 22 #include "chrome/browser/shell_integration.h"
23 #include "chrome/browser/translate/translate_tab_helper.h"
23 #include "chrome/browser/ui/browser.h" 24 #include "chrome/browser/ui/browser.h"
24 #include "chrome/browser/ui/browser_command_controller.h" 25 #include "chrome/browser/ui/browser_command_controller.h"
25 #include "chrome/browser/ui/browser_commands_mac.h" 26 #include "chrome/browser/ui/browser_commands_mac.h"
26 #include "chrome/browser/ui/browser_list.h" 27 #include "chrome/browser/ui/browser_list.h"
27 #include "chrome/browser/ui/browser_window_state.h" 28 #include "chrome/browser/ui/browser_window_state.h"
28 #import "chrome/browser/ui/cocoa/browser/avatar_base_controller.h" 29 #import "chrome/browser/ui/cocoa/browser/avatar_base_controller.h"
29 #import "chrome/browser/ui/cocoa/browser/avatar_menu_bubble_controller.h" 30 #import "chrome/browser/ui/cocoa/browser/avatar_menu_bubble_controller.h"
30 #import "chrome/browser/ui/cocoa/browser/edit_search_engine_cocoa_controller.h" 31 #import "chrome/browser/ui/cocoa/browser/edit_search_engine_cocoa_controller.h"
31 #import "chrome/browser/ui/cocoa/browser/password_generation_bubble_controller.h " 32 #import "chrome/browser/ui/cocoa/browser/password_generation_bubble_controller.h "
32 #import "chrome/browser/ui/cocoa/browser_window_controller.h" 33 #import "chrome/browser/ui/cocoa/browser_window_controller.h"
(...skipping 239 matching lines...) Expand 10 before | Expand all | Expand 10 after
272 void BrowserWindowCocoa::UpdateDevTools() { 273 void BrowserWindowCocoa::UpdateDevTools() {
273 [controller_ updateDevToolsForContents: 274 [controller_ updateDevToolsForContents:
274 browser_->tab_strip_model()->GetActiveWebContents()]; 275 browser_->tab_strip_model()->GetActiveWebContents()];
275 } 276 }
276 277
277 void BrowserWindowCocoa::UpdateLoadingAnimations(bool should_animate) { 278 void BrowserWindowCocoa::UpdateLoadingAnimations(bool should_animate) {
278 // Do nothing on Mac. 279 // Do nothing on Mac.
279 } 280 }
280 281
281 void BrowserWindowCocoa::SetStarredState(bool is_starred) { 282 void BrowserWindowCocoa::SetStarredState(bool is_starred) {
282 [controller_ setStarredState:is_starred ? YES : NO]; 283 [controller_ setStarredState:is_starred];
283 } 284 }
284 285
285 void BrowserWindowCocoa::SetTranslateIconToggled(bool is_lit) { 286 void BrowserWindowCocoa::SetTranslateIconToggled(bool is_lit) {
286 NOTIMPLEMENTED(); 287 [controller_ setCurrentPageIsTranslated:is_lit];
287 } 288 }
288 289
289 void BrowserWindowCocoa::OnActiveTabChanged(content::WebContents* old_contents, 290 void BrowserWindowCocoa::OnActiveTabChanged(content::WebContents* old_contents,
290 content::WebContents* new_contents, 291 content::WebContents* new_contents,
291 int index, 292 int index,
292 int reason) { 293 int reason) {
293 // TODO(pkasting): Perhaps the code in 294 // TODO(pkasting): Perhaps the code in
294 // TabStripController::activateTabWithContents should move here? Or this 295 // TabStripController::activateTabWithContents should move here? Or this
295 // should call that (instead of TabStripModelObserverBridge doing so)? It's 296 // should call that (instead of TabStripModelObserverBridge doing so)? It's
296 // not obvious to me why Mac doesn't handle tab changes in BrowserWindow the 297 // not obvious to me why Mac doesn't handle tab changes in BrowserWindow the
(...skipping 184 matching lines...) Expand 10 before | Expand all | Expand 10 after
481 void BrowserWindowCocoa::ShowBookmarkAppBubble( 482 void BrowserWindowCocoa::ShowBookmarkAppBubble(
482 const WebApplicationInfo& web_app_info, 483 const WebApplicationInfo& web_app_info,
483 const std::string& extension_id) { 484 const std::string& extension_id) {
484 NOTIMPLEMENTED(); 485 NOTIMPLEMENTED();
485 } 486 }
486 487
487 void BrowserWindowCocoa::ShowTranslateBubble( 488 void BrowserWindowCocoa::ShowTranslateBubble(
488 content::WebContents* contents, 489 content::WebContents* contents,
489 TranslateTabHelper::TranslateStep step, 490 TranslateTabHelper::TranslateStep step,
490 TranslateErrors::Type error_type) { 491 TranslateErrors::Type error_type) {
491 NOTIMPLEMENTED(); 492 TranslateTabHelper* translate_tab_helper =
493 TranslateTabHelper::FromWebContents(contents);
494 LanguageState& language_state = translate_tab_helper->GetLanguageState();
495 language_state.SetTranslateEnabled(true);
496
497 [controller_ showTranslateBubbleForWebContents:contents
498 step:step
499 errorType:error_type];
492 } 500 }
493 501
494 #if defined(ENABLE_ONE_CLICK_SIGNIN) 502 #if defined(ENABLE_ONE_CLICK_SIGNIN)
495 void BrowserWindowCocoa::ShowOneClickSigninBubble( 503 void BrowserWindowCocoa::ShowOneClickSigninBubble(
496 OneClickSigninBubbleType type, 504 OneClickSigninBubbleType type,
497 const base::string16& email, 505 const base::string16& email,
498 const base::string16& error_message, 506 const base::string16& error_message,
499 const StartSyncCallback& start_sync_callback) { 507 const StartSyncCallback& start_sync_callback) {
500 WebContents* web_contents = 508 WebContents* web_contents =
501 browser_->tab_strip_model()->GetActiveWebContents(); 509 browser_->tab_strip_model()->GetActiveWebContents();
(...skipping 246 matching lines...) Expand 10 before | Expand all | Expand 10 after
748 // further, both by another H, i.e. WebContentsView's height becomes 756 // further, both by another H, i.e. WebContentsView's height becomes
749 // A.height() + H and RenderWidgetHostView's height becomes A.height() + 2H. 757 // A.height() + H and RenderWidgetHostView's height becomes A.height() + 2H.
750 // Strangely, the RenderWidgetHostView for the previous navigation entry also 758 // Strangely, the RenderWidgetHostView for the previous navigation entry also
751 // gets enlarged by H. 759 // gets enlarged by H.
752 // I believe these "automatic" resizing are caused by setAutoresizingMask of 760 // I believe these "automatic" resizing are caused by setAutoresizingMask of
753 // of the cocoa view in WebContentsViewMac, which defeats the purpose of 761 // of the cocoa view in WebContentsViewMac, which defeats the purpose of
754 // WebContentsDelegate::GetSizeForNewRenderView i.e. to prevent resizing of 762 // WebContentsDelegate::GetSizeForNewRenderView i.e. to prevent resizing of
755 // RenderWidgetHostView in (2) and (3). 763 // RenderWidgetHostView in (2) and (3).
756 return 0; 764 return 0;
757 } 765 }
OLDNEW

Powered by Google App Engine
This is Rietveld 408576698