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

Side by Side Diff: ios/chrome/browser/ui/bookmarks/bookmark_interaction_controller.mm

Issue 2929993002: Refactoring bookmark viewcontrollers (Closed)
Patch Set: Created 3 years, 6 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
« no previous file with comments | « ios/chrome/browser/ui/bookmarks/bookmark_home_view_controller_unittest.mm ('k') | no next file » | no next file with comments »
Toggle Intra-line Diffs ('i') | Expand Comments ('e') | Collapse Comments ('c') | Show Comments Hide Comments ('s')
OLDNEW
1 // Copyright 2013 The Chromium Authors. All rights reserved. 1 // Copyright 2013 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 "ios/chrome/browser/ui/bookmarks/bookmark_interaction_controller.h" 5 #import "ios/chrome/browser/ui/bookmarks/bookmark_interaction_controller.h"
6 6
7 #include <stdint.h> 7 #include <stdint.h>
8 8
9 #include "base/logging.h" 9 #include "base/logging.h"
10 #include "base/mac/bind_objc_block.h" 10 #include "base/mac/bind_objc_block.h"
11 #include "base/metrics/user_metrics.h" 11 #include "base/metrics/user_metrics.h"
12 #include "base/metrics/user_metrics_action.h" 12 #include "base/metrics/user_metrics_action.h"
13 #include "base/strings/sys_string_conversions.h" 13 #include "base/strings/sys_string_conversions.h"
14 #include "base/strings/utf_string_conversions.h" 14 #include "base/strings/utf_string_conversions.h"
15 #include "base/time/time.h" 15 #include "base/time/time.h"
16 #include "components/bookmarks/browser/bookmark_model.h" 16 #include "components/bookmarks/browser/bookmark_model.h"
17 #include "components/bookmarks/browser/bookmark_utils.h" 17 #include "components/bookmarks/browser/bookmark_utils.h"
18 #include "components/pref_registry/pref_registry_syncable.h" 18 #include "components/pref_registry/pref_registry_syncable.h"
19 #include "components/prefs/pref_service.h" 19 #include "components/prefs/pref_service.h"
20 #include "ios/chrome/browser/bookmarks/bookmark_model_factory.h" 20 #include "ios/chrome/browser/bookmarks/bookmark_model_factory.h"
21 #include "ios/chrome/browser/browser_state/chrome_browser_state.h" 21 #include "ios/chrome/browser/browser_state/chrome_browser_state.h"
22 #import "ios/chrome/browser/metrics/new_tab_page_uma.h" 22 #import "ios/chrome/browser/metrics/new_tab_page_uma.h"
23 #include "ios/chrome/browser/pref_names.h" 23 #include "ios/chrome/browser/pref_names.h"
24 #import "ios/chrome/browser/tabs/tab.h" 24 #import "ios/chrome/browser/tabs/tab.h"
25 #import "ios/chrome/browser/ui/bookmarks/bookmark_controller_factory.h" 25 #import "ios/chrome/browser/ui/bookmarks/bookmark_controller_factory.h"
26 #import "ios/chrome/browser/ui/bookmarks/bookmark_edit_view_controller.h" 26 #import "ios/chrome/browser/ui/bookmarks/bookmark_edit_view_controller.h"
27 #import "ios/chrome/browser/ui/bookmarks/bookmark_home_view_controller.h" 27 #import "ios/chrome/browser/ui/bookmarks/bookmark_home_handset_view_controller.h "
28 #import "ios/chrome/browser/ui/bookmarks/bookmark_navigation_controller.h" 28 #import "ios/chrome/browser/ui/bookmarks/bookmark_navigation_controller.h"
29 #import "ios/chrome/browser/ui/bookmarks/bookmark_utils_ios.h" 29 #import "ios/chrome/browser/ui/bookmarks/bookmark_utils_ios.h"
30 #include "ios/chrome/browser/ui/uikit_ui_util.h" 30 #include "ios/chrome/browser/ui/uikit_ui_util.h"
31 #include "ios/chrome/browser/ui/url_loader.h" 31 #include "ios/chrome/browser/ui/url_loader.h"
32 #include "ios/chrome/grit/ios_strings.h" 32 #include "ios/chrome/grit/ios_strings.h"
33 #import "ios/third_party/material_components_ios/src/components/Snackbar/src/Mat erialSnackbar.h" 33 #import "ios/third_party/material_components_ios/src/components/Snackbar/src/Mat erialSnackbar.h"
34 #include "ios/web/public/referrer.h" 34 #include "ios/web/public/referrer.h"
35 #include "ui/base/l10n/l10n_util.h" 35 #include "ui/base/l10n/l10n_util.h"
36 36
37 #if !defined(__has_feature) || !__has_feature(objc_arc) 37 #if !defined(__has_feature) || !__has_feature(objc_arc)
38 #error "This file requires ARC support." 38 #error "This file requires ARC support."
39 #endif 39 #endif
40 40
41 using bookmarks::BookmarkModel; 41 using bookmarks::BookmarkModel;
42 using bookmarks::BookmarkNode; 42 using bookmarks::BookmarkNode;
43 43
44 namespace { 44 namespace {
45 const int64_t kLastUsedFolderNone = -1; 45 const int64_t kLastUsedFolderNone = -1;
46 } // namespace 46 } // namespace
47 47
48 @interface BookmarkInteractionController ()< 48 @interface BookmarkInteractionController ()<
49 BookmarkEditViewControllerDelegate, 49 BookmarkEditViewControllerDelegate,
50 BookmarkHomeViewControllerDelegate> { 50 BookmarkHomeHandsetViewControllerDelegate> {
51 // The browser state of the current user. 51 // The browser state of the current user.
52 ios::ChromeBrowserState* _currentBrowserState; // weak 52 ios::ChromeBrowserState* _currentBrowserState; // weak
53 53
54 // The browser state to use, might be different from _currentBrowserState if 54 // The browser state to use, might be different from _currentBrowserState if
55 // it is incognito. 55 // it is incognito.
56 ios::ChromeBrowserState* _browserState; // weak 56 ios::ChromeBrowserState* _browserState; // weak
57 57
58 // The designated url loader. 58 // The designated url loader.
59 __weak id<UrlLoader> _loader; 59 __weak id<UrlLoader> _loader;
60 60
61 // The parent controller on top of which the UI needs to be presented. 61 // The parent controller on top of which the UI needs to be presented.
62 __weak UIViewController* _parentController; 62 __weak UIViewController* _parentController;
63 } 63 }
64 64
65 // The bookmark model in use. 65 // The bookmark model in use.
66 @property(nonatomic, assign) BookmarkModel* bookmarkModel; 66 @property(nonatomic, assign) BookmarkModel* bookmarkModel;
67 67
68 // A reference to the potentially presented bookmark browser. 68 // A reference to the potentially presented bookmark browser.
69 @property(nonatomic, strong) BookmarkHomeViewController* bookmarkBrowser; 69 @property(nonatomic, strong) BookmarkHomeHandsetViewController* bookmarkBrowser;
70 70
71 // A reference to the potentially presented single bookmark editor. 71 // A reference to the potentially presented single bookmark editor.
72 @property(nonatomic, strong) BookmarkEditViewController* bookmarkEditor; 72 @property(nonatomic, strong) BookmarkEditViewController* bookmarkEditor;
73 73
74 // The user wants to bookmark the current tab. 74 // The user wants to bookmark the current tab.
75 - (void)addBookmarkForTab:(Tab*)tab; 75 - (void)addBookmarkForTab:(Tab*)tab;
76 76
77 // Builds a controller and brings it on screen. 77 // Builds a controller and brings it on screen.
78 - (void)presentBookmarkForTab:(Tab*)tab; 78 - (void)presentBookmarkForTab:(Tab*)tab;
79 79
(...skipping 192 matching lines...) Expand 10 before | Expand all | Expand 10 after
272 272
273 - (BOOL)bookmarkEditor:(BookmarkEditViewController*)controller 273 - (BOOL)bookmarkEditor:(BookmarkEditViewController*)controller
274 shoudDeleteAllOccurencesOfBookmark:(const BookmarkNode*)bookmark { 274 shoudDeleteAllOccurencesOfBookmark:(const BookmarkNode*)bookmark {
275 return YES; 275 return YES;
276 } 276 }
277 277
278 - (void)bookmarkEditorWantsDismissal:(BookmarkEditViewController*)controller { 278 - (void)bookmarkEditorWantsDismissal:(BookmarkEditViewController*)controller {
279 [self dismissBookmarkEditorAnimated:YES]; 279 [self dismissBookmarkEditorAnimated:YES];
280 } 280 }
281 281
282 #pragma mark - BookmarkHomeViewControllerDelegate 282 #pragma mark - BookmarkHomeHandsetViewControllerDelegate
283 283
284 - (void)bookmarkHomeViewControllerWantsDismissal: 284 - (void)bookmarkHomeHandsetViewControllerWantsDismissal:
285 (BookmarkHomeViewController*)controller 285 (BookmarkHomeHandsetViewController*)controller
286 navigationToUrl:(const GURL&)url { 286 navigationToUrl:(const GURL&)url {
287 [self dismissBookmarkBrowserAnimated:YES]; 287 [self dismissBookmarkBrowserAnimated:YES];
288 288
289 if (url != GURL()) { 289 if (url != GURL()) {
290 new_tab_page_uma::RecordAction(_browserState, 290 new_tab_page_uma::RecordAction(_browserState,
291 new_tab_page_uma::ACTION_OPENED_BOOKMARK); 291 new_tab_page_uma::ACTION_OPENED_BOOKMARK);
292 base::RecordAction( 292 base::RecordAction(
293 base::UserMetricsAction("MobileBookmarkManagerEntryOpened")); 293 base::UserMetricsAction("MobileBookmarkManagerEntryOpened"));
294 294
295 if (url.SchemeIs(url::kJavaScriptScheme)) { // bookmarklet 295 if (url.SchemeIs(url::kJavaScriptScheme)) { // bookmarklet
296 NSString* jsToEval = [base::SysUTF8ToNSString(url.GetContent()) 296 NSString* jsToEval = [base::SysUTF8ToNSString(url.GetContent())
297 stringByRemovingPercentEncoding]; 297 stringByRemovingPercentEncoding];
298 [_loader loadJavaScriptFromLocationBar:jsToEval]; 298 [_loader loadJavaScriptFromLocationBar:jsToEval];
299 } else { 299 } else {
300 [_loader loadURL:url 300 [_loader loadURL:url
301 referrer:web::Referrer() 301 referrer:web::Referrer()
302 transition:ui::PAGE_TRANSITION_AUTO_BOOKMARK 302 transition:ui::PAGE_TRANSITION_AUTO_BOOKMARK
303 rendererInitiated:NO]; 303 rendererInitiated:NO];
304 } 304 }
305 } 305 }
306 } 306 }
307 307
308 @end 308 @end
OLDNEW
« no previous file with comments | « ios/chrome/browser/ui/bookmarks/bookmark_home_view_controller_unittest.mm ('k') | no next file » | no next file with comments »

Powered by Google App Engine
This is Rietveld 408576698