Skip to content

Commit

Permalink
Rename widget to search widget and use new bundleid to always build.
Browse files Browse the repository at this point in the history
Using the newly created bundleid and mobileprovision, the search widget
can be integrated in the application alongside the current today widget.
When running on device after this check-in, it is necessary to install
the SearchTodayExtension mobileprovision.

BUG=622743, 682230

Review-Url: https://codereview.chromium.org/2814783003
Cr-Commit-Position: refs/heads/master@{#465606}
  • Loading branch information
lod authored and Commit bot committed Apr 19, 2017
1 parent 2855bed commit f31fea5
Show file tree
Hide file tree
Showing 14 changed files with 62 additions and 71 deletions.
1 change: 1 addition & 0 deletions docs/ios/build_instructions.md
Original file line number Diff line number Diff line change
Expand Up @@ -142,6 +142,7 @@ application extensions:
- `${prefix}.chrome.ios.herebedragons`
- `${prefix}.chrome.ios.herebedragons.ShareExtension`
- `${prefix}.chrome.ios.herebedragons.TodayExtension`
- `${prefix}.chrome.ios.herebedragons.SearchTodayExtension`
All these certificates need to have the "App Groups"
(`com.apple.security.application-groups`) capability enabled for
Expand Down
2 changes: 1 addition & 1 deletion ios/BUILD.gn
Original file line number Diff line number Diff line change
Expand Up @@ -40,9 +40,9 @@ group("all") {
deps = [
# List all the targets that need to be build on iOS by default.
"//ios/chrome/app:chrome",
"//ios/chrome/search_widget_extension",
"//ios/chrome/share_extension",
"//ios/chrome/today_extension",
"//ios/chrome/widget_extension",
"//ios/clean/chrome/app:chrome_clean_skeleton",
"//ios/showcase",
"//ios/web/shell:ios_web_shell",
Expand Down
4 changes: 1 addition & 3 deletions ios/build/chrome_build.gni
Original file line number Diff line number Diff line change
Expand Up @@ -9,7 +9,7 @@ import("//build/config/mac/symbols.gni")
declare_args() {
# Enable today extension.
ios_enable_today_extension = true
ios_enable_widget_extension = false
ios_enable_search_widget_extension = true

# Enable share extension.
ios_enable_share_extension = true
Expand All @@ -29,8 +29,6 @@ declare_args() {
# entitlements.
ios_egtests_entitlements_additions = []
}
assert(!(ios_enable_today_extension && ios_enable_widget_extension),
"Both today extensions cannot be enabled simultaneously.")

# Configure whether breakpad support is enabled.
breakpad_enabled = is_official_build && is_chrome_branded
Expand Down
20 changes: 7 additions & 13 deletions ios/chrome/app/BUILD.gn
Original file line number Diff line number Diff line change
Expand Up @@ -274,8 +274,8 @@ ios_app_bundle("chrome") {
if (ios_enable_today_extension) {
deps += [ ":today_extension_bundle" ]
}
if (ios_enable_widget_extension) {
deps += [ ":widget_extension_bundle" ]
if (ios_enable_search_widget_extension) {
deps += [ ":search_widget_extension_bundle" ]
}
if (ios_enable_share_extension) {
deps += [ ":share_extension_bundle" ]
Expand Down Expand Up @@ -314,22 +314,16 @@ if (current_toolchain == default_toolchain) {
}
}

if (ios_enable_widget_extension) {
bundle_data("widget_extension_bundle") {
if (ios_enable_search_widget_extension) {
bundle_data("search_widget_extension_bundle") {
public_deps = [
"//ios/chrome/widget_extension",
"//ios/chrome/search_widget_extension",
]
sources = [
"$root_out_dir/widget_extension.appex",
"$root_out_dir/search_widget_extension.appex",
]

# The output is renamed today_extension.appex so that signing in canary
# works and clobbering is not necessary when switching between this
# extension and the today extension.
# TODO(crbug.com/682230) : Rename this when widget gets its own
# mobileprovision.
outputs = [
"{{bundle_plugins_dir}}/today_extension.appex",
"{{bundle_plugins_dir}}/{{source_file_part}}",
]
}
}
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -14,17 +14,17 @@ tweak_info_plist("tweak_info_plist") {
compile_plist("entitlements") {
format = "xml1"
substitutions = [ "IOS_BUNDLE_ID_PREFIX=$ios_app_bundle_id_prefix" ]
output_name = "$target_gen_dir/today_extension.appex.entitlements"
output_name = "$target_gen_dir/search_widget_extension.appex.entitlements"
plist_templates =
[ "entitlements/external/widget_extension.appex.entitlements" ]
[ "entitlements/external/search_widget_extension.appex.entitlements" ]
}

ios_appex_bundle("widget_extension") {
ios_appex_bundle("search_widget_extension") {
sources = [
"widget_view.h",
"widget_view.mm",
"widget_view_controller.h",
"widget_view_controller.mm",
"search_widget_view.h",
"search_widget_view.mm",
"search_widget_view_controller.h",
"search_widget_view_controller.mm",
]

deps = [
Expand Down Expand Up @@ -52,11 +52,7 @@ ios_appex_bundle("widget_extension") {
extra_substitutions = [
"CHROME_CHANNEL_SCHEME=$url_channel_scheme",
"CHROMIUM_SHORT_NAME=$chromium_short_name",

# The widget_extension and today_extension are using the same provisioning
# profile during development work.
# TODO(crbug.com/682238) : Request provisioning profile if widget is kept.
"WIDGET_EXTENSION_BUNDLE_ID=$chromium_bundle_id.TodayExtension",
"WIDGET_EXTENSION_BUNDLE_ID=$chromium_bundle_id.SearchTodayExtension",
]

configs += [ "//build/config/compiler:enable_arc" ]
Expand Down
File renamed without changes.
Original file line number Diff line number Diff line change
Expand Up @@ -7,13 +7,13 @@
<key>CFBundleDisplayName</key>
<string>${CHROMIUM_SHORT_NAME}</string>
<key>CFBundleExecutable</key>
<string>widget_extension</string>
<string>search_widget_extension</string>
<key>CFBundleIdentifier</key>
<string>${IOS_BUNDLE_ID_PREFIX}.${WIDGET_EXTENSION_BUNDLE_ID}</string>
<key>CFBundleInfoDictionaryVersion</key>
<string>6.0</string>
<key>CFBundleName</key>
<string>widget_extension</string>
<string>search_widget_extension</string>
<key>CFBundlePackageType</key>
<string>XPC!</string>
<key>CFBundleShortVersionString</key>
Expand All @@ -25,7 +25,7 @@
<key>NSExtension</key>
<dict>
<key>NSExtensionPrincipalClass</key>
<string>WidgetViewController</string>
<string>SearchWidgetViewController</string>
<key>NSExtensionPointIdentifier</key>
<string>com.apple.widget-extension</string>
</dict>
Expand Down
File renamed without changes.
Original file line number Diff line number Diff line change
Expand Up @@ -2,14 +2,14 @@
// Use of this source code is governed by a BSD-style license that can be
// found in the LICENSE file.

#ifndef IOS_CHROME_WIDGET_EXTENSION_WIDGET_VIEW_H_
#define IOS_CHROME_WIDGET_EXTENSION_WIDGET_VIEW_H_
#ifndef IOS_CHROME_SEARCH_WIDGET_EXTENSION_SEARCH_WIDGET_VIEW_H_
#define IOS_CHROME_SEARCH_WIDGET_EXTENSION_SEARCH_WIDGET_VIEW_H_

#import <UIKit/UIKit.h>

// Protocol to be implemented by targets for user actions coming from the widget
// view.
@protocol WidgetViewActionTarget
// Protocol to be implemented by targets for user actions coming from the search
// widget view.
@protocol SearchWidgetViewActionTarget

// Called when the user taps the Search button.
- (void)openSearch:(id)sender;
Expand All @@ -24,13 +24,13 @@

@end

// View for the widget. Shows a blinking cursor for a fake omnibox and calls the
// target when tapped.
@interface WidgetView : UIView
// View for the search widget. Shows a blinking cursor for a fake omnibox and
// calls the target when tapped.
@interface SearchWidgetView : UIView

// Designated initializer, creates the widget view with a |target| for user
// actions.
- (instancetype)initWithActionTarget:(id<WidgetViewActionTarget>)target
- (instancetype)initWithActionTarget:(id<SearchWidgetViewActionTarget>)target
NS_DESIGNATED_INITIALIZER;
- (instancetype)initWithFrame:(CGRect)frame NS_UNAVAILABLE;
- (instancetype)initWithCoder:(NSCoder*)aDecoder NS_UNAVAILABLE;
Expand All @@ -40,4 +40,4 @@

@end

#endif // IOS_CHROME_WIDGET_EXTENSION_WIDGET_VIEW_H_
#endif // IOS_CHROME_SEARCH_WIDGET_EXTENSION_SEARCH_WIDGET_VIEW_H_
Original file line number Diff line number Diff line change
Expand Up @@ -2,7 +2,7 @@
// Use of this source code is governed by a BSD-style license that can be
// found in the LICENSE file.

#import "ios/chrome/widget_extension/widget_view.h"
#import "ios/chrome/search_widget_extension/search_widget_view.h"

#include "base/logging.h"

Expand All @@ -21,8 +21,8 @@

} // namespace

@interface WidgetView () {
__weak id<WidgetViewActionTarget> _target;
@interface SearchWidgetView () {
__weak id<SearchWidgetViewActionTarget> _target;
}

@property(nonatomic, copy) NSString* copiedURL;
Expand All @@ -35,14 +35,14 @@ - (void)addFakebox;

@end

@implementation WidgetView
@implementation SearchWidgetView

@synthesize copiedURL = _copiedURL;
@synthesize copiedURLLabel = _copiedURLLabel;

@synthesize cursor = _cursor;

- (instancetype)initWithActionTarget:(id<WidgetViewActionTarget>)target {
- (instancetype)initWithActionTarget:(id<SearchWidgetViewActionTarget>)target {
self = [super initWithFrame:CGRectZero];
if (self) {
DCHECK(target);
Expand Down
15 changes: 15 additions & 0 deletions ios/chrome/search_widget_extension/search_widget_view_controller.h
Original file line number Diff line number Diff line change
@@ -0,0 +1,15 @@
// Copyright 2017 The Chromium Authors. All rights reserved.
// Use of this source code is governed by a BSD-style license that can be
// found in the LICENSE file.

#ifndef IOS_CHROME_SEARCH_WIDGET_EXTENSION_SEARCH_WIDGET_VIEW_CONTROLLER_H_
#define IOS_CHROME_SEARCH_WIDGET_EXTENSION_SEARCH_WIDGET_VIEW_CONTROLLER_H_

#import <NotificationCenter/NotificationCenter.h>
#import <UIKit/UIKit.h>

@interface SearchWidgetViewController : UIViewController<NCWidgetProviding>

@end

#endif // IOS_CHROME_SEARCH_WIDGET_EXTENSION_SEARCH_WIDGET_VIEW_CONTROLLER_H_
Original file line number Diff line number Diff line change
Expand Up @@ -2,7 +2,7 @@
// Use of this source code is governed by a BSD-style license that can be
// found in the LICENSE file.

#import "ios/chrome/widget_extension/widget_view_controller.h"
#import "ios/chrome/search_widget_extension/search_widget_view_controller.h"

#import <NotificationCenter/NotificationCenter.h>

Expand All @@ -11,7 +11,7 @@
#include "base/strings/sys_string_conversions.h"
#include "components/open_from_clipboard/clipboard_recent_content_impl_ios.h"
#include "ios/chrome/common/app_group/app_group_constants.h"
#import "ios/chrome/widget_extension/widget_view.h"
#import "ios/chrome/search_widget_extension/search_widget_view.h"

#if !defined(__has_feature) || !__has_feature(objc_arc)
#error "This file requires ARC support."
Expand All @@ -25,8 +25,8 @@
NSString* const kXCallbackURLHost = @"x-callback-url";
} // namespace

@interface WidgetViewController ()<WidgetViewActionTarget>
@property(nonatomic, weak) WidgetView* widgetView;
@interface SearchWidgetViewController ()<SearchWidgetViewActionTarget>
@property(nonatomic, weak) SearchWidgetView* widgetView;
@property(nonatomic, strong) NSURL* copiedURL;
@property(nonatomic, strong)
ClipboardRecentContentImplIOS* clipboardRecentContent;
Expand All @@ -45,7 +45,7 @@ + (NSDictionary*)dictForCommand:(NSString*)command

@end

@implementation WidgetViewController
@implementation SearchWidgetViewController

@synthesize widgetView = _widgetView;
@synthesize copiedURL = _copiedURL;
Expand All @@ -70,7 +70,8 @@ - (void)viewDidLoad {

// A local variable is necessary here as the property is declared weak and the
// object would be deallocated before being retained by the addSubview call.
WidgetView* widgetView = [[WidgetView alloc] initWithActionTarget:self];
SearchWidgetView* widgetView =
[[SearchWidgetView alloc] initWithActionTarget:self];
self.widgetView = widgetView;
[self.view addSubview:self.widgetView];

Expand Down Expand Up @@ -172,9 +173,10 @@ - (void)openAppWithCommand:(NSString*)command parameter:(NSString*)parameter {
[[NSUserDefaults alloc] initWithSuiteName:app_group::ApplicationGroup()];
NSString* defaultsKey =
base::SysUTF8ToNSString(app_group::kChromeAppGroupCommandPreference);
[sharedDefaults setObject:[WidgetViewController dictForCommand:command
parameter:parameter]
forKey:defaultsKey];
[sharedDefaults
setObject:[SearchWidgetViewController dictForCommand:command
parameter:parameter]
forKey:defaultsKey];
[sharedDefaults synchronize];

NSString* scheme = base::mac::ObjCCast<NSString>([[NSBundle mainBundle]
Expand Down
15 changes: 0 additions & 15 deletions ios/chrome/widget_extension/widget_view_controller.h

This file was deleted.

0 comments on commit f31fea5

Please sign in to comment.