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

Side by Side Diff: chrome/browser/ui/cocoa/content_settings/collected_cookies_mac.mm

Issue 866263008: MacViews: Unify web contents modal dialog types (Closed) Base URL: https://chromium.googlesource.com/chromium/src.git@ValidationMessageBubble
Patch Set: Another idea Created 5 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 #import "chrome/browser/ui/cocoa/content_settings/collected_cookies_mac.h" 5 #import "chrome/browser/ui/cocoa/content_settings/collected_cookies_mac.h"
6 6
7 #include <vector> 7 #include <vector>
8 8
9 #include "base/mac/bundle_locations.h" 9 #include "base/mac/bundle_locations.h"
10 #include "base/message_loop/message_loop.h" 10 #include "base/message_loop/message_loop.h"
11 #include "base/prefs/pref_service.h" 11 #include "base/prefs/pref_service.h"
12 #include "base/strings/sys_string_conversions.h" 12 #include "base/strings/sys_string_conversions.h"
13 #include "chrome/browser/chrome_notification_types.h" 13 #include "chrome/browser/chrome_notification_types.h"
14 #include "chrome/browser/content_settings/cookie_settings.h" 14 #include "chrome/browser/content_settings/cookie_settings.h"
15 #include "chrome/browser/content_settings/tab_specific_content_settings.h" 15 #include "chrome/browser/content_settings/tab_specific_content_settings.h"
16 #include "chrome/browser/infobars/infobar_service.h" 16 #include "chrome/browser/infobars/infobar_service.h"
17 #include "chrome/browser/profiles/profile.h" 17 #include "chrome/browser/profiles/profile.h"
18 #import "chrome/browser/ui/cocoa/constrained_window/constrained_window_custom_sh eet.h"
19 #import "chrome/browser/ui/cocoa/content_settings/cookie_details_view_controller .h" 18 #import "chrome/browser/ui/cocoa/content_settings/cookie_details_view_controller .h"
20 #import "chrome/browser/ui/cocoa/vertical_gradient_view.h" 19 #import "chrome/browser/ui/cocoa/vertical_gradient_view.h"
21 #include "chrome/browser/ui/collected_cookies_infobar_delegate.h" 20 #include "chrome/browser/ui/collected_cookies_infobar_delegate.h"
22 #include "chrome/common/pref_names.h" 21 #include "chrome/common/pref_names.h"
23 #include "chrome/grit/generated_resources.h" 22 #include "chrome/grit/generated_resources.h"
23 #include "components/web_modal/web_contents_modal_dialog_manager.h"
24 #include "content/public/browser/notification_details.h" 24 #include "content/public/browser/notification_details.h"
25 #include "content/public/browser/notification_source.h" 25 #include "content/public/browser/notification_source.h"
26 #include "content/public/browser/web_contents.h" 26 #include "content/public/browser/web_contents.h"
27 #include "grit/theme_resources.h" 27 #include "grit/theme_resources.h"
28 #include "third_party/apple_sample_code/ImageAndTextCell.h" 28 #include "third_party/apple_sample_code/ImageAndTextCell.h"
29 #import "third_party/google_toolbox_for_mac/src/AppKit/GTMNSAnimation+Duration.h " 29 #import "third_party/google_toolbox_for_mac/src/AppKit/GTMNSAnimation+Duration.h "
30 #import "third_party/google_toolbox_for_mac/src/AppKit/GTMUILocalizerAndLayoutTw eaker.h" 30 #import "third_party/google_toolbox_for_mac/src/AppKit/GTMUILocalizerAndLayoutTw eaker.h"
31 #include "ui/base/l10n/l10n_util_mac.h" 31 #include "ui/base/l10n/l10n_util_mac.h"
32 #include "ui/base/resource/resource_bundle.h" 32 #include "ui/base/resource/resource_bundle.h"
33 #include "ui/gfx/image/image.h" 33 #include "ui/gfx/image/image.h"
34 #include "ui/gfx/image/image_skia.h" 34 #include "ui/gfx/image/image_skia.h"
35 #include "ui/gfx/image/image_skia_util_mac.h" 35 #include "ui/gfx/image/image_skia_util_mac.h"
36 36
37 namespace { 37 namespace {
38 // Colors for the infobar. 38 // Colors for the infobar.
39 const double kBannerGradientColorTop[3] = 39 const double kBannerGradientColorTop[3] =
40 {255.0 / 255.0, 242.0 / 255.0, 183.0 / 255.0}; 40 {255.0 / 255.0, 242.0 / 255.0, 183.0 / 255.0};
41 const double kBannerGradientColorBottom[3] = 41 const double kBannerGradientColorBottom[3] =
42 {250.0 / 255.0, 230.0 / 255.0, 145.0 / 255.0}; 42 {250.0 / 255.0, 230.0 / 255.0, 145.0 / 255.0};
43 const double kBannerStrokeColor = 135.0 / 255.0; 43 const double kBannerStrokeColor = 135.0 / 255.0;
44 44
45 enum TabViewItemIndices { 45 enum TabViewItemIndices {
46 kAllowedCookiesTabIndex = 0, 46 kAllowedCookiesTabIndex = 0,
47 kBlockedCookiesTabIndex 47 kBlockedCookiesTabIndex
48 }; 48 };
49 49
50 } // namespace 50 } // namespace
51 51
52 #pragma mark Constrained window delegate 52 using web_modal::WebContentsModalDialogManager;
53 53
54 CollectedCookiesMac::CollectedCookiesMac(content::WebContents* web_contents) { 54 CollectedCookiesMac::CollectedCookiesMac(content::WebContents* web_contents)
55 : web_contents_(web_contents) {
55 TabSpecificContentSettings* content_settings = 56 TabSpecificContentSettings* content_settings =
56 TabSpecificContentSettings::FromWebContents(web_contents); 57 TabSpecificContentSettings::FromWebContents(web_contents);
57 registrar_.Add(this, chrome::NOTIFICATION_COLLECTED_COOKIES_SHOWN, 58 registrar_.Add(this, chrome::NOTIFICATION_COLLECTED_COOKIES_SHOWN,
58 content::Source<TabSpecificContentSettings>(content_settings)); 59 content::Source<TabSpecificContentSettings>(content_settings));
59 60
60 sheet_controller_.reset([[CollectedCookiesWindowController alloc] 61 sheet_controller_.reset([[CollectedCookiesWindowController alloc]
61 initWithWebContents:web_contents 62 initWithWebContents:web_contents
62 collectedCookiesMac:this]); 63 collectedCookiesMac:this]);
63 64
64 base::scoped_nsobject<CustomConstrainedWindowSheet> sheet( 65 WebContentsModalDialogManager::FromWebContents(web_contents)
65 [[CustomConstrainedWindowSheet alloc] 66 ->ShowModalDialog([sheet_controller_ window]);
66 initWithCustomWindow:[sheet_controller_ window]]);
67 window_.reset(new ConstrainedWindowMac(
68 this, web_contents, sheet));
69 } 67 }
70 68
71 CollectedCookiesMac::~CollectedCookiesMac() { 69 CollectedCookiesMac::~CollectedCookiesMac() {
72 } 70 }
73 71
74 void CollectedCookiesMac::Observe(int type, 72 void CollectedCookiesMac::Observe(int type,
75 const content::NotificationSource& source, 73 const content::NotificationSource& source,
76 const content::NotificationDetails& details) { 74 const content::NotificationDetails& details) {
77 DCHECK(type == chrome::NOTIFICATION_COLLECTED_COOKIES_SHOWN); 75 DCHECK(type == chrome::NOTIFICATION_COLLECTED_COOKIES_SHOWN);
78 window_->CloseWebContentsModalDialog(); 76 PerformClose();
79 } 77 }
80 78
81 void CollectedCookiesMac::PerformClose() { 79 void CollectedCookiesMac::PerformClose() {
82 window_->CloseWebContentsModalDialog(); 80 WebContentsModalDialogManager::FromWebContents(web_contents_)
83 } 81 ->WillClose([sheet_controller_ window]);
84
85 void CollectedCookiesMac::OnConstrainedWindowClosed(
86 ConstrainedWindowMac* window) {
87 base::MessageLoop::current()->DeleteSoon(FROM_HERE, this); 82 base::MessageLoop::current()->DeleteSoon(FROM_HERE, this);
tapted 2015/02/25 06:23:28 I'm not familiar with the CollectedCookies dialog.
88 } 83 }
89 84
90 #pragma mark Window Controller 85 #pragma mark Window Controller
91 86
92 @interface CollectedCookiesWindowController (Private) 87 @interface CollectedCookiesWindowController (Private)
93 - (void)showInfoBarForDomain:(const base::string16&)domain 88 - (void)showInfoBarForDomain:(const base::string16&)domain
94 setting:(ContentSetting)setting; 89 setting:(ContentSetting)setting;
95 - (void)showInfoBarForMultipleDomainsAndSetting:(ContentSetting)setting; 90 - (void)showInfoBarForMultipleDomainsAndSetting:(ContentSetting)setting;
96 - (void)animateInfoBar; 91 - (void)animateInfoBar;
97 @end 92 @end
(...skipping 407 matching lines...) Expand 10 before | Expand all | Expand 10 after
505 treeController = blockedTreeController_; 500 treeController = blockedTreeController_;
506 break; 501 break;
507 default: 502 default:
508 NOTREACHED(); 503 NOTREACHED();
509 return; 504 return;
510 } 505 }
511 [detailsViewController_ configureBindingsForTreeController:treeController]; 506 [detailsViewController_ configureBindingsForTreeController:treeController];
512 } 507 }
513 508
514 @end 509 @end
OLDNEW

Powered by Google App Engine
This is Rietveld 408576698