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

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: . 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/password_manager.h" 20 #include "chrome/browser/password_manager/password_manager.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 243 matching lines...) Expand 10 before | Expand all | Expand 10 after
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 ? YES : NO];
283 } 284 }
284 285
285 void BrowserWindowCocoa::SetTranslateIconToggled(bool is_lit) { 286 void BrowserWindowCocoa::SetTranslateIconToggled(bool is_lit) {
286 NOTIMPLEMENTED(); 287 [controller_ setTranslateIconToggled:is_lit ? YES : NO];
Nico 2014/02/05 06:07:18 I think you can omit ` ? YES : NO`
hajimehoshi 2014/02/05 11:08:03 Done.
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 178 matching lines...) Expand 10 before | Expand all | Expand 10 after
475 void BrowserWindowCocoa::ShowBookmarkBubble(const GURL& url, 476 void BrowserWindowCocoa::ShowBookmarkBubble(const GURL& url,
476 bool already_bookmarked) { 477 bool already_bookmarked) {
477 [controller_ showBookmarkBubbleForURL:url 478 [controller_ showBookmarkBubbleForURL:url
478 alreadyBookmarked:(already_bookmarked ? YES : NO)]; 479 alreadyBookmarked:(already_bookmarked ? YES : NO)];
479 } 480 }
480 481
481 void BrowserWindowCocoa::ShowTranslateBubble( 482 void BrowserWindowCocoa::ShowTranslateBubble(
482 content::WebContents* contents, 483 content::WebContents* contents,
483 TranslateBubbleModel::ViewState view_state, 484 TranslateBubbleModel::ViewState view_state,
484 TranslateErrors::Type error_type) { 485 TranslateErrors::Type error_type) {
485 NOTIMPLEMENTED(); 486 TranslateTabHelper* translate_tab_helper =
487 TranslateTabHelper::FromWebContents(contents);
488 LanguageState& language_state = translate_tab_helper->GetLanguageState();
489 language_state.SetTranslateEnabled(true);
490
491 [controller_ showTranslateBubbleForWebContents:contents
492 viewState:view_state
493 errorType:error_type];
486 } 494 }
487 495
488 #if defined(ENABLE_ONE_CLICK_SIGNIN) 496 #if defined(ENABLE_ONE_CLICK_SIGNIN)
489 void BrowserWindowCocoa::ShowOneClickSigninBubble( 497 void BrowserWindowCocoa::ShowOneClickSigninBubble(
490 OneClickSigninBubbleType type, 498 OneClickSigninBubbleType type,
491 const base::string16& email, 499 const base::string16& email,
492 const base::string16& error_message, 500 const base::string16& error_message,
493 const StartSyncCallback& start_sync_callback) { 501 const StartSyncCallback& start_sync_callback) {
494 WebContents* web_contents = 502 WebContents* web_contents =
495 browser_->tab_strip_model()->GetActiveWebContents(); 503 browser_->tab_strip_model()->GetActiveWebContents();
(...skipping 249 matching lines...) Expand 10 before | Expand all | Expand 10 after
745 // further, both by another H, i.e. WebContentsView's height becomes 753 // further, both by another H, i.e. WebContentsView's height becomes
746 // A.height() + H and RenderWidgetHostView's height becomes A.height() + 2H. 754 // A.height() + H and RenderWidgetHostView's height becomes A.height() + 2H.
747 // Strangely, the RenderWidgetHostView for the previous navigation entry also 755 // Strangely, the RenderWidgetHostView for the previous navigation entry also
748 // gets enlarged by H. 756 // gets enlarged by H.
749 // I believe these "automatic" resizing are caused by setAutoresizingMask of 757 // I believe these "automatic" resizing are caused by setAutoresizingMask of
750 // of the cocoa view in WebContentsViewMac, which defeats the purpose of 758 // of the cocoa view in WebContentsViewMac, which defeats the purpose of
751 // WebContentsDelegate::GetSizeForNewRenderView i.e. to prevent resizing of 759 // WebContentsDelegate::GetSizeForNewRenderView i.e. to prevent resizing of
752 // RenderWidgetHostView in (2) and (3). 760 // RenderWidgetHostView in (2) and (3).
753 return 0; 761 return 0;
754 } 762 }
OLDNEW

Powered by Google App Engine
This is Rietveld 408576698